shouting versus dotting
Michel Fortin
michel.fortin at michelf.com
Mon Oct 6 03:56:43 PDT 2008
On 2008-10-05 22:23:16 -0400, Michel Fortin <michel.fortin at michelf.com> said:
> Well, not so sure about that: I'm pretty sure it's needed for
> disambiguation too. Let's say you have:
>
> void foo(int x)();
> void foo(T)(T x);
>
> foo(5);
>
> Is foo(5) a the same as foo!(5), or does it call foo!(int).foo(5) ?
> Under the current rules, it's the second (you can write foo!(5) to call
> the first). If you allow templates to be instanciated without the "!",
> then I guess both will match and you'll have ambiguity.
>
> If you could avoid having sets of parameters, one for the function and
> one for the template, then you could get rid of the "!" in a snap...
Or... we could just disallow having both at the same time, just like
you can't have two functions with the same arguments. A call to foo(5)
would be ambigous in the above situation, plain and simple. Is this
reasonable?
We could still disambiguate using:
foo!(5);
and:
foo(int)(5);
In this context, the ! becomes the "force this to be template
arguments" operator, or the "do not deduce template arguments, I'll
provide them" operator.
Or we could just forget ! completely and leave the first one impossible
to disambiguate.
Which makes me think that it's sad we can't write the second as:
foo(int, 5);
I'd be much nicer to the eye.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list