* bogus codegen with static opAssign() usage *

kris foo at bar.com
Mon Feb 19 09:44:07 PST 2007


Walter Bright wrote:
>     a = b;
> 
> is replaced with:
> 
>     a.opAssign(b);
> 
> not:
> 
>     a = a.opAssign(b);
> 
> The return value of opAssign comes in to play with:
> 
>     c = a = b;
> 
> which is rewritten as:
> 
>     c = a.opAssign(b);


Doh! Doh! Doh!

My bad; I saw this elsewhere and just assumed it would operate correctly.

The syntax, however, is very clean. Importantly, it supports the 
unification or /centralization/ of all those 'new' invocations. I'd go 
so far as to say such a syntax could represent a bridge between OO and 
scripting:

----
String s = "mystring";
----

----
File f = "/foo/bar.d";
----

----
Regex r = "^(.*)$";
----

There's a fairly wide range of simple applicability for this kinda' 
thing. Would be great if static opAssign() could support this, or some 
other operator were enabled?

How about it?


More information about the Digitalmars-d-bugs mailing list