Is this D or is it Javascript?

Rob T alanb at ucora.com
Fri Jul 5 16:58:29 PDT 2013


On Friday, 5 July 2013 at 23:04:28 UTC, Adam D. Ruppe wrote:
> 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)
>

Yes that would be much better.

What I always wanted to see, was full signature overloading 
rather than only the partial signature overloading we currently 
have.

eg

int get();
char get();

int a = get(); // calls int foo()
char b = get(); // calls char foo()

Technically there's no reason why this won't work. The cases 
where there's ambiguity are virtually identical to what we 
already experience with partial signature overloading. I have no 
idea why this has not been seen as useful in most other 
languages, it seems like a natural extension of the overloading 
concept. I think only Haskel does something like it.

--rt


More information about the Digitalmars-d-announce mailing list