Is this D or is it Javascript?
Adam D. Ruppe
destructionator at gmail.com
Fri Jul 5 16:04:27 PDT 2013
On Friday, 5 July 2013 at 22:51:57 UTC, Rob T wrote:
> I suppose i could to this
> c = var.get!(typeof(c));
Yeah, I did two things: int c = var.get!int; and
int c;
var v;
v.putInto(c);
> [do] you think multiple alias this will solve the problem?
Maybe, but that would still be limited to a list of types. What
would be ideal is if alias this or opImplicitCast existed, or
implicit constructors like C++ has for function calls.... and
could be a template:
T get(T)() { ...}
alias get this;
int a = v; // rewrites to v.get!(int)
That won't work in all cases, there will be some where the type
requested is uncertain or ambiguous, but I'd say just go ahead
and error out there or pass the original var, if possible,
because this should cover most assignments.
But overall, I don't think the get!int is too bad. It is kinda
nice to know where you are transitioning back into static typed
world anyway.
BTW I'll push another commit to jsvar.d and script.d over the
weekend. I got return/break/continue working now (in the cases
I've tried at least, simple ones).
More information about the Digitalmars-d-announce
mailing list