Tips from the compiler
Don
nospam at nospam.com
Tue Oct 19 17:20:41 PDT 2010
Rainer Deyke wrote:
> On 10/19/2010 05:44, Don wrote:
>> Rainer Deyke wrote:
>>> Simple. If the template is in a library file, it's library code,
>>> regardless of where it was instantiated.
>> The separation isn't clean. User code instantiates library code which
>> instantiates user code. Look at std.algorithm, for example.
>> Mixins and template alias parameters blur things even further.
>
> There are exactly four possible situations:
> - Template in library code instantiated by library code.
> - Template in library code instantiated by user code.
> - Template in user code instantiated by library code.
> - Template in user code instantiated by user code.
>
> These cases can be nested arbitrarily deep, but that doesn't add
> additional cases. If we categorically ignore where a template is
> instantiated, the four cases reduce to just two:
> - Template in library code.
> - Template in user code.
Don't forget that delegate literals can be passed as template alias
parameters; so can expressions. Problems get even more extreme when
mixins are involved.
Example: Suppose we have warnings for possible numeric overflow. Then
consider:
sort!"a*5<b"(x);
We should have a warning that 'a*5' may cause a numeric overflow. How
can that be done?
More information about the Digitalmars-d
mailing list