Gavin Kistner
9/30/2004 1:22:00 PM
On Sep 30, 2004, at 4:04 AM, David A. Black wrote:
> On Thu, 30 Sep 2004, Robert Klemme wrote:
>>> results = my_array.collect{ ... }
>>> results = my_array.map{ ... }
>>
>> IMHO these were introduced to match other languages notations. I
>> think it
>> makes life easier for newcomers.
>
> If only the things that make life easier for newcomers could disappear
> later, like training wheels on a bicycle.... :-)
I suppose that's my wish, too. As unrealistic as it may be.
("Sorry, play time is over. All your existing code may crash and burn,
but in the end it'll make you a better programmer.")
What I'd think was nice is if a bunch of things were officially
deprecated; no runtime warning (although perhaps with a -w or
something) but where exact duplicates exist, the King from on High
would say "thou shalt use #foo and not #bar". (I was even thinking of
removing the deprecated names from the documentation, but then that's
no good for someone needing to decipher existing code.)
> Proc.new and lambda aren't the same as each other, though:
Whoa, that I didn't know.
So a lambda is more like a method (currently)?
Actually, I'd say this is an argument for merging, or something. My
personal principle of least surprise was violated when I found that I
couldn't create a block with default parameters. Procs, blocks,
methods, lambdas ... four ways to do almost exactly the same thing.
On Thu, 30 Sep 2004, Robert Klemme wrote:
>> On the whole I feel pretty comfortable with the way Ruby does things
>> although I recognize a certain tendency to increase redundancy
>> ("lambda" and "proc" comes to mind). As far as I remember I wasn't
>> confused when I was a RubyNuby. But then again, everybody feels
>> different about this.
I'm not sure if I'm a nuby or not; I certainly am when it comes to
grokking lambdas. The concepts are all pretty clear (not confusing when
learning), but when I was designing the EventTarget module, I kept
waffling between:
def add_event_listener( evt_type, callback_proc )
and
def add_event_listener( evt_type, &callback_proc )
Proc-as-param allows multiple params to be procs, and makes it easy to
pass methods/procs/lambdas (which are what would most likely be used
for a callback: an existing, centrally-defined procedure)...but
prevents blocks from being used without Proc.new. That's bad, because
Ruby people LIKE blocks. I know I do.
Proc-as-block allows no more than one 'proc', and requires &foo to be
used when passing method references or procs or lambdas..but *does*
allow blocks.
I suppose this is a case where subtle flexibility is important
(different functionality), but it's the case of the blank canvas
scaring and stymying the novice artist: "Where do I begin?" There's so
much/too much flexibility; so much overlap muddled in with the
tradeoffs it's frustrating. But now I'm getting onto the specific topic
of merging the features and fun of both sides, instead of the general
"I'd like to see a little less duplication in the future, please"
topic.
--
(-, /\ \/ / /\/