Finer-grained modules (like Enumarable) for Collections?

Discussion in 'Ruby' started by Its Me, Sep 12, 2003.

  1. Its Me

    Its Me Guest

    I've been wondering what fine-grained module structure (like Enumerable)
    would make sense for collections, and just came across this work where the
    Smalltalk collections were refactored using somthing they called Traits (for
    all practical purposes, these are like Ruby modules).

    http://www.iam.unibe.ch/~scg/Archive/Papers/Blac02aTraitsHierarchy.pdf

    There were some very useful ideas in this re-factoring. e.g.

    module TEmptiness
    #requires "size"
    def isEmpty () ...
    def notEmpty () ...
    def ifEmpty (&block)
    def ifNotEmpty (&block)
    etc.
    end

    Beyond this, there are many other candidates for module-like refactoring
    e.g. see Larch traits http://www.cs.iastate.edu/~leavens/Handbooks.html.

    Any thoughts on the benefits / possibility of using some ideas from here to
    provide more fine-grained modules in Ruby libraries?

    Cheers ....
     
    Its Me, Sep 12, 2003
    #1
    1. Advertising

  2. "Its Me" <> schrieb im Newsbeitrag
    news:pLm8b.12869$...
    > I've been wondering what fine-grained module structure (like Enumerable)
    > would make sense for collections, and just came across this work where

    the
    > Smalltalk collections were refactored using somthing they called Traits

    (for
    > all practical purposes, these are like Ruby modules).
    >
    > http://www.iam.unibe.ch/~scg/Archive/Papers/Blac02aTraitsHierarchy.pdf
    >
    > There were some very useful ideas in this re-factoring. e.g.
    >
    > module TEmptiness
    > #requires "size"
    > def isEmpty () ...
    > def notEmpty () ...
    > def ifEmpty (&block)
    > def ifNotEmpty (&block)
    > etc.
    > end


    Interesting approach. I like these kind of things because they increase
    modularity and improve reusability though I can't comment on efficiency
    issues with Ruby in this case. (We'd get lot's of modules that are
    included in Enumerable which in turn is included in std collection types.)

    The question remains whether it is worthwile. Because of Ruby's nature it
    does not hurt to include Enumerable - even if it would depend on more than
    just a single method and not all of these methods were present. IMHO the
    small gain would be expressions like "obj.kind_of? TEmptiness" but we'd
    get a lot more modules at the same time. This need not necessary mean
    "more readable documentation" and it can mean slower execution.

    > Any thoughts on the benefits / possibility of using some ideas from here

    to
    > provide more fine-grained modules in Ruby libraries?


    While we're at it: I'd suggest to include size and empty? in Enumerable.
    It would not hurt IMHO and there might be custom collections which can't
    implement size and empty? more efficiently than via iterating all
    elements.

    Regards

    robert
     
    Robert Klemme, Sep 12, 2003
    #2
    1. Advertising

  3. On Sat, Sep 13, 2003 at 02:17:54AM +0900, Robert Klemme wrote:
    > > There were some very useful ideas in this re-factoring. e.g.
    > >
    > > module TEmptiness
    > > #requires "size"
    > > def isEmpty () ...
    > > def notEmpty () ...
    > > def ifEmpty (&block)
    > > def ifNotEmpty (&block)
    > > etc.
    > > end

    >
    > Interesting approach. I like these kind of things because they increase
    > modularity and improve reusability though I can't comment on efficiency
    > issues with Ruby in this case. (We'd get lot's of modules that are
    > included in Enumerable which in turn is included in std collection types.)


    This can be leveraged to ease Ruby-in-Ruby or to reimplement the
    interpreter: see matju's MetaRuby.


    --
    _ _
    | |__ __ _| |_ ___ _ __ ___ __ _ _ __
    | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
    | |_) | (_| | |_\__ \ | | | | | (_| | | | |
    |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
    Running Debian GNU/Linux Sid (unstable)
    batsman dot geo at yahoo dot com

    * LG loves czech girls.
    <vincent> LG: do they have additional interesting "features" other girls don't have? ;)
    -- #Debian
     
    Mauricio Fernández, Sep 12, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug Poland
    Replies:
    9
    Views:
    744
    VisionSet
    Sep 27, 2003
  2. Chris Berg

    A finer-grain -Xrs option

    Chris Berg, Jul 28, 2004, in forum: Java
    Replies:
    1
    Views:
    5,380
    Tris Orendorff
    Jul 30, 2004
  3. Daniel Parker

    FINE,FINER,FINEST

    Daniel Parker, Nov 24, 2004, in forum: Java
    Replies:
    6
    Views:
    6,261
    call_naveen
    Aug 26, 2009
  4. Jon Leighton
    Replies:
    12
    Views:
    183
    Robert Klemme
    Jan 26, 2011
  5. James Marshall

    Determining object type, finer-grained than typeof

    James Marshall, Nov 6, 2003, in forum: Javascript
    Replies:
    3
    Views:
    155
    Jim Ley
    Nov 6, 2003
Loading...

Share This Page