Re: Closures versus objects

Gary King <[email protected]>
Newsgroups gmane.comp.lang.lightweight
Message-ID <[email protected]>
If Lisp was re-written today, I'd guess that there would be more use  
of generic functions for things like length. Then we would have:

(length "butter")  ==> 6
(length #(1 2 3))  ==> 3

and so on...

Unfortunately, Common Lisp had to incorporate 30-years of working  
implementations into its standard without offending anyone (too  
much!). Though lacking in elegance, this gives it the nutty crunchy  
kruft many of us have come to love <smile>.

that's my two cents,

On Feb 16, 2007, at 1:00 PM, Matt Hellige wrote:

> On 2/16/07, Joe Marshall <[email protected]> wrote:
>> But Ruby syntax has a major disadvantage!  Suppose you wanted to  
>> late-bind the
>> method name?  In Scheme you'd do this:
>>
>> (let ((method   (select-method  len first last)))
>>   (method "abcd"))
>>
>> but you can't bind the name of a method identifier in Ruby:
>>
>>   method = select-method (len, first, last)
>>   s = "abcd"
>>   s.method
>>
>> won't work.
>
> To be fair, the ease of this kind of thing is usually considered a
> major advantage of Python, Ruby and friends:
>
> method = "length"
> s = "abcd"
> s.send(method)
>
> so the syntax is a bit different, but I'm not sure that's a bad thing,
> in this case. It's clear to me that literal method names (length) and
> variables holding method names (method) should appear different in
> code. It's also clear to me that calling literal method names is so
> overwhelmingly the norm that there should be convenient syntax for it.
> It seems to me that Ruby and ilk find a good balance here.
>
> Matt
>

--
Gary Warren King, metabang.com
Cell: (413) 885 9127
Fax: (206) 338-4052
gwkkwg on Skype * garethsan on AIM
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.