Fully dynamic d by opDotExp overloading
davidl
davidl at nospam.org
Fri Apr 17 08:20:53 PDT 2009
在 Fri, 17 Apr 2009 22:24:04 +0800,Steven Schveighoffer
<schveiguy at yahoo.com> 写道:
> On Fri, 17 Apr 2009 09:44:09 -0400, Leandro Lucarella <llucax at gmail.com>
> wrote:
>
>> I don't fully understand the example though. In writefln((v.qq = 5).i),
>> how is that B.i is assigned to 5 if the opDotExp("qq", 5) don't
>> propagate
>> the 5 to the new B()?
>
> I think it translates to
>
> opDotExp("qq") = 5
>
> Without knowing the signature of qq, how is the compiler supposed to
> infer that it is a property? In fact, I think this might be a
> limitation of this syntax, you can't define dynamic properties.
>
> I for one, can't really see a huge benefit, but then again, I don't
> normally work with dynamic-type langauges. It looks to me like a huge
> hole that the compiler will ignore bugs that would have been caught if
> the methods were strongly typed:
>
Actually this can help ddl project to work more nicely. Consider you can
call plugin code directly without static bindings. And I believe delphi
COM variant use some similar trick. It allows you call COM object without
static bindings. Sometimes it's troublesome to get the static bindings,
and you only need one piece of little function(you won't need the whole
interface).
--
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list