Duck typing and safety.

Simen kjaeraas simen.kjaras at gmail.com
Sat Aug 14 02:37:47 PDT 2010


Steven Schveighoffer <schveiguy at yahoo.com> wrote:

> 1. a function may have the same name and usage, but have a completely  
> different meaning.  Human languages are funny that way.  This means,  
> your function could accept a type as a parameter and use it in a very  
> wrong way.  Most of the time, this is a non issue, because you use duck  
> typing with clear function names (hard to imagine another meaning for  
> quack for instance).

struct Charlatan {
     bool quack( ) {
         return true;
     }
}

-- 
Simen


More information about the Digitalmars-d-learn mailing list