D to Javascript converter (a hacked up dmd)
Piotr Szturmaj
bncrbme at jadamspam.pl
Tue Feb 28 20:02:59 PST 2012
Adam D. Ruppe wrote:
> On Wednesday, 29 February 2012 at 03:24:17 UTC, Piotr Szturmaj wrote:
>> What about passing values within object?
>
> Yeah, that's one of the first things I thought of, but
> what about a more complex thing:
>
> d = a(c) + 4;
>
> where will the c=wrapper.value go?
>
> It can't go at the end of the function call
> now. Also, if the function call is in the
> middle of something, we'd have to assign the
> wrapper somewhere too. Suppose:
>
> d = (c = 2, a(c));
>
>
> I think anything that isn't inline for the
> argument will be too easy to break.
Here's another try with objects:
function Wrapper(value) {
this.value = value;
}
Wrapper.prototype.valueOf = function() { return this.value; }
Wrapper.prototype.toString = function() { return this.value.toString(); }
function a(b) { b.value = 10 + b; }
var c = new Wrapper(5);
a(c);
alert(c); // shows 15
but this implies that all value variables must be initialized with new
Wrapper(x).
More information about the Digitalmars-d-announce
mailing list