What's wrong with making them all implicit instead of forcing me to add
this extra, ugly syntax?
People that support explicit syntax for keyword arguments in method
definitions shall be damned to the committee that combs over every
single method in the core and standard library and figures out which
parameters will support keywords and which ones won't. They will also
be responsible for explaining their rationale to the rest of us, and
dealing with all subsequent arguments that result. They will ALSO be
relegated to answering all future emails from newbies wondering why some
parameters support keywords and some don't.
Regards,
Dan
···
-----Original Message-----
From: Louis J Scoras [mailto:louis.j.scoras@gmail.com]
Sent: Monday, October 24, 2005 2:51 PM
To: ruby-talk ML
Subject: Re: A comparison by example of keyword argument styles
On 10/24/05, Trans <transfire@gmail.com> wrote:
>
> Widdle it:
*agrees*
def foo( required :bar, :baz ; optional :request=>'useless' ; named
> :side, :meat=>'fish' )
>
> def foo( bar, baz ; optional :request=>'useless' ; named :side,
> :meat=>'fish' )
>
That one is very much like the lisp defun if I'm not mistaken.
def foo( bar, baz, request='useless', keys: side, meat=>'fish' )
>
> def foo( bar, baz, request='useless', side=>nil, meat=>'fish' )
That looks reasonable. What's wrong with that?
What's wrong with making them all implicit instead of forcing me to add
this extra, ugly syntax?
Well, my gut instinct was that this is breaking encapsulation: you didn't
intend for that symbol to be in the public interface. But the more I think
about it, how often do you changed the name of a parameter like this after
the API is solidified? The parameter in that position can't change it's
semantic meaning anyway. So you're probably right.
It just feels wrong, as I'm sure being forced to explicitly define how
arguments are specified feels wrong to you.
···
--
Lou
Berger, Daniel wrote:
They will ALSO be relegated to answering all future emails from
newbies wondering why some parameters support keywords and some don't.
I don’t quite understand what you mean here, but if you mean why not all
methods will support them then that’s simple to answer: most methods
don’t need keyword parameters. Just like most methods don’t need
optional parameters. To me, keyword parameters is all about getting
around defaults, i.e., the Common Lisp way. I don’t see the point of
writing
ary.grep(regex: /…/)
I do see a point in writing
ary.grep(/…/, start: 3, end:5)
as an alternative to
ary[3..5].grep(/…/)
for when I’m searching a large array and I know that the elements I’m
looking for are in a certain range. But I’m repeating myself…
nikolai
···
--
Nikolai Weibull: now available free of charge at http://bitwi.se/\!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}