Hey David, I think that we've had some misunderstandings due to
talking about different ruby versions. Some of the concerns that
you've brought up are not a part of the proposed new hash syntax ([:],
etc), but part of the new hash construct already in 1.9. I addressed
one of those concerns in an email I sent to this list last week:
http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-core/4614
But I see another misunderstanding now. Forget the whole [hash] idea
for the moment and let's just use the current 1.9 {key:value} syntax
(with the {}, you notice). You're example:
a = SomeClass.new
b = 100
{a:'apple', b:'orange'}
would give you {:a=>'apple', :b=>'orange'}. If you want the 'a' and
'b' to refer to the _objects_ that 'a' and 'b' refer to, not the
symbols :a and :b, you can't use the ':' syntax, you have to fall back
on the => syntax. That has been a part of 1.9 for a while now (AFAIK).
>All of this just seems like so much upheaval to avoid the
>(comparatively unusual [compared to hash literals, that is]) keyword
>'lambda'.
Actually, so far, your points have been against the {:} syntax, which
has it's origins far before the whole no-lambda proc syntax idea.
Just want to make sure that we're on the same page.
Dan
On Wed, 30 Mar 2005 22:04:52 +0900, David A. Black <dblack / wobblini.net> wrote:
> Hi --
>
> On Wed, 30 Mar 2005, Sean E. Russell wrote:
>
> > On Monday 21 March 2005 16:17, David A. Black wrote:
> >
> >> whitespace would be required before a symbol argument to a method, and
> >
> > Isn't it already? Whitespace, or a token character, is required before a
> > symbol argument, AFAIK. Are you looking at a different version of Ruby than
> > I am?
>
> Possibly.
>
> $ ruby -ve 'def x(y); p y; end; x:a'
> ruby 1.8.2 (2004-12-25) [i686-linux]
> :a
>
> (It may have changed in one or more 1.9's, but I'm treating it, like
> all of this, as in flux and under discussion.)
>
> >> so on. So writing a Hash correctly would involved threading a much
> >> narrower needle.
> >
> > Any reduction of typing does this, but that isn't an argument for having a
> > terse syntax.
>
> I don't quite follow.
>
> > Ruby has always played it fast and loose. This syntax isn't
> > more obfuscated; it is still clear what is being meant with:
> >
> > h = [ one: 'me', two: 'you', something: 'else' ]
> >
> > Well, at least, to me this seems pretty natural, and much easier to type than
> > hashes defined with =>, and much clearer than hashes defined with ','. With
> > long comma-separated hashes, it can be difficult to associate keys with
> > values; this syntax is more clear.
>
> Except for the [] part :-) That's the thing: I'm really talking about
> the {} constructor, and the implications of pressing [] into service
> as a part-time hash literal. I don't feel strongly about the commas,
> except that for tests it's nice to type h = { 1,2,3,4 }, since it's
> fast.
>
>
> David
>
> --
> David A. Black
> dblack / wobblini.net
>
>