Aliasing of template results

Manu turkeyman at gmail.com
Wed Jan 25 05:31:13 PST 2012


On 22 January 2012 20:36, Alex Rønne Petersen <xtzgzorex at gmail.com> wrote:

> On 22-01-2012 19:33, Andrej Mitrovic wrote:
>
>> A while ago there was a suggestion by Andrei to incorporate this sort of
>> syntax:
>>
>> template ElementType(T : T[])
>> {
>>
>>    alias ElementType = T;
>> }
>>
>> struct Foo(T)
>> {
>>     alias Type = T;
>> }
>>
>> I think people agreed it was a nice syntax, but I don't know if anyone
>> tried to implement it.
>>
>
> It still feels wrong. Why am I overwriting an existing symbol?


Was it me that raised this on IRC? I've also been discussing it on IRC the
last few days, and it is very confusing.
I can write code that works now, but I still for the life of me
find coherent logic for the syntax in my head, and whether I'm aliasing
something, or producing a constant using enum... one way I'm producing a
type, the other way I'm producing a value. The same syntax can produce this
disconnected result; feels very unnatural to me. Types and values feel like
totally different things in my mind, perhaps this is my error?

I think the problem for me is that I can't see clearly exactly what a
template actually does, it feels like there's some magic involved, mainly
in the result syntax, that makes it work somehow...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120125/8dc71361/attachment.html>


More information about the Digitalmars-d mailing list