Hello to all,

Phrogz wrote:
>> $ ruby_yarv -ve 'p({foo: "bar", baz: "bar"})'
>> {:foo=>"bar", :baz=>"bar"}
> Yeehaw! Thanks, powers-that-be! :)
> Whoa! And auto-symbolizing keys, too? Very, very exciting.

Yes, I think this is useful
and I fully suport it.

And I am 100% in favour of a order-preserving hash in the Ruby core.

And actually, I would prefer the behavior of Hash to be *replaced*
by the behavior of "HistoryHash".
Enough people do want this feature,
a history-preserving hash does not cost much more (in terms of memory 
and execution time)
and it is consistent with tho old hash behavior.
So, for the sake of simplicity, no new class, let's just replace
Hash by a "better" Hash.

This brings me to a point that I is very important to me:

          Ruby crystallization.

I believe it is worth not only to add new useful syntax or features,
but also to strip less useful syntax/features.
Perhaps my plea comes a little bit late, now that Ruby already is
among the Tiobe top 20, but I think it is still worth some effort
to bring out the Ruby crystal more clearly.

[For a horror example, think of
the semantics of the switch statement in C.
- Historically (from the assembler point of view) it was logical
to have the option of omitting the break statement after a case,
but later it became a pain for generations of programmers.]

I am glad that some efforts towards "crystallization"
have already been happening:
For example, the use of parallel assignment is permitted in more places.

So as an example of what I think of in terms of syntax unification,
consider this:
Arrays are already very much integrated in the core syntax of Ruby,
but what about Hashes?
Given
  def foo(a, b, c)
it is possible to call
  array=[1,2,3]; foo(*array)  # of course...
but why not
  hash={:a=>1,:b=>2,:c=>3}; foo(**hash) # take any new symbol instead of 
**

I mean, can we have a Hash-splat operator?
Extend the notion of parallel assignment in
such a way that it not only operates with position
but with name?
Then it would be much more straightforward to use
named paramters (as in Rails).

Is this useful or crazy?
  name = "Paul"
  city = "Paris"
  **hash = name, city
  => {:name="Paul",:city="Paris"}

Of course, questions arise how to deal with unnamed values, ...
But my point is "Closer integration of Hashes in the language".

(And actually, order-preserving hashes would be a more suitable to do 
that.)


OK, I got a bit carried away by this example,
the bottom line I was trying to make is:
just as already: every paramerter-list can be an array
let every paramter-list be useable like a hash.

And furthermore: simplification of proc/lambda/method/block.

Of course while/repeat simplification.

So much for now

Sven






-- 
Posted via http://www.ruby-forum.com/.