[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Duck Typing

Michael Campbell

9/13/2003 7:33:00 PM


> > It's not a coding style or technique; it's an attribute of the
> > language.
>
> I disagree, with some proof by counterexample.
...

> Therefore: Based on statements 1-5, "duck typing" is not specific
> to ruby...

That was never asserted.

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder...

2 Answers

Ryan Pavlik

9/13/2003 7:44:00 PM

0

On Sun, 14 Sep 2003 04:32:49 +0900
Michael Campbell <michael_s_campbell@yahoo.com> wrote:

> > Therefore: Based on statements 1-5, "duck typing" is not specific
> > to ruby...
>
> That was never asserted.

Yes, but it _was_ asserted that it was a language attribute of ruby,
when you can practice it in other languages, which have no specific
provisions, any mention of "duck typing", or common practice thereof.

(Although, in JavaScript, and most prototype-based languages, you
usually practice ''duck-typing'' because that''s the way things are.
Pure prototype-OOP has no class, just an object that acts in a
particular manner---in this case, you could probably consider it a
feature of the language.)

--
Ryan Pavlik <rpav@mephle.com>

"Damn ye and ye black ops mind games!" - 8BT

Dan Doel

9/13/2003 8:23:00 PM

0

Ryan Pavlik wrote:

>Yes, but it _was_ asserted that it was a language attribute of ruby,
>when you can practice it in other languages, which have no specific
>provisions, any mention of "duck typing", or common practice thereof.
>
>(Although, in JavaScript, and most prototype-based languages, you
>usually practice ''duck-typing'' because that''s the way things are.
>Pure prototype-OOP has no class, just an object that acts in a
>particular manner---in this case, you could probably consider it a
>feature of the language.)
>
>

Duck typing may not be a "feature" of Ruby, but it''s definitely supported by
Ruby. It''s also very well supported by Python, Perl, JavaScript, and
I''m sure
many other languages. The difference with Ruby is that Dave Thomas hangs
out here more and he''s the one who said it originally. :)

Ruby does have some provisions that make it more supportive of duck typing,
though. For example, as I understand it, in Smalltalk (which I''m still
learning),
you define all your methods when you''re building the program, and then all
that is fixed. You can''t, for example, make an object of class Object
and then
write custom methods for that one object. So objects and types are more
dynamic in Ruby than in, say, Smalltalk, for example.

This, of course isn''t exclusive to Ruby. As I recall, JavaScript allows you
to add methods to arbitrary classes or objects. But, as I said, Dave Thomas
hangs out here, which is why Ruby people talk about duck typing and
JavaScript people don''t. :)

Cheers.

- Dan