Hello --

On Sat, 4 Aug 2001, MikkelFJ wrote:

> Then there is : prefix. It kind of naturally extends the attr : x syntax.
>
> class Scalar
>   attr : value
>   def initialize value
>     :value = value
>   end
> end

Except that's really the symbol syntax, not specific to arguments
of attr.  So you're suddenly using a symbol as an lvalue.

> BTW: my primary interest in the @@ syntax was not to make class member
> access easier - but if you start fiddling with @, you'd naturally have to
> think about @@ as well for consistency reasons.
>
> However, the notion of using <classname>.<membername> is not a good for
> mixins and general moving code around (the very bad copy-paste we all do).
> The explicit name reference is a very annoying feature in for example C++
> constructors, which is avoided in Ruby's initialize constructor. That is why
> I suggested 'class' or 'shared' and not the class name as in Thing.cvar in
> your example.


You could do:

  class Thing
    cl_attr_accessor :thing

    def initialize
      type.thing = 123
    end
  end

to avoid hard-coding the class.

My problem with "shared" is that I don't get what it is.  Is it a
synonym for #type?


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav