Steve Yegge's rant on The Next Big Language
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Thu Feb 15 03:08:06 PST 2007
Thomas Kuehne wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Jarrett Billingsley schrieb am 2007-02-13:
>> "BCS" <BCS at pathlink.com> wrote in message
>> news:eqq7nq$2tut$1 at digitalmars.com...
>>
>>> Half?, more like one or two hard misses and a few more close calls.
>> Well let's see:
>
> [snip]
>
>> 15. Static typing and duck typing
>>
>> Yes. (Unless some duck typing expert wants to correct me, I _think_ D has
>> it)
>
> Shouldn't the code below be legal if D supported duck typing?
> #
> # class Cat{
> # void grow(){}
> # }
> #
> # class Tree{
> # void grow(){}
> # }
> #
> # void main(){
> # Tree t = new Cat();
> # t.grow();
> # }
>
> Thomas
>
>
> -----BEGIN PGP SIGNATURE-----
>
> iD8DBQFF0eWfLK5blCcjpWoRAhUwAJ9DflOJIIo4wN0FiqBqWl39Y6/cogCfS7Al
> QXsO2nfgt3JzdzkD0nurXPc=
> =oAuz
> -----END PGP SIGNATURE-----
Yup, D doesn't actually support duck typing. Not on the object system
method call at least, since in metaprogramming (compile-time) it has
something that can be considered duck typing: Using the is-expression to
test for features:
template func(T) (T foo) {
static if(is(foo.grow())) {
foo.grow();
} else
...
}
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d-announce
mailing list