[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

Mark Wilson

9/13/2003 8:08:00 PM

My 2 cents:

Duck typing is an answer to the questions, where are the type
declarations? What happens when I declare a variable without declaring
its type? How can I define, or call, a method without having to
explicitly specify the types the method accepts? Why is this so alien
to me with my background in (insert other language here)? etc., etc.

These are all good questions. The duck typing answer is saying -- stop
thinking in terms of types in advance (of run time). Just send a
message to an object to perform a method. If you want to think about
type, try thinking about class instead.

Class -- attributes, possible representations and methods (operations)
of values that can be created.

Duck typing isn't the only answer and it's not complete and it's not a
formal paradigm. But it does inspire a lot of thought.

But if type matters for what you're doing, by all means, think about it
-- in fact, you must think about it. It's just that there are huge
areas of development where, in a dynamic typing environment, explicit
concern with type is not necessary.

Regards,

Mark