March 12, 2009
BCS wrote:
> Reply to Andrei,
> 
>> Hello,
>>
>> I'm looking for a catchy phrase denoting this D idiom:
>>
>> template Blah(Stuff)
>> {
>> alias ... Blah;
>> }
>> i.e., defining inside a template a symbol of the same name as the
>> template itself. Then you can use Blah!(X, Y) to mean Blah!(X,
>> Y).Blah.
>>
>> What would be a catchy, descriptive, and memorable phrase for this?
>>
>> Thanks,
>>
>> Andrei
>>
> 
> Template ALIASING -> taliasing or tail-asing
> 
> 

Templing?
March 12, 2009
Don wrote:
> Andrei Alexandrescu wrote:
>> Hello,
>>
>>
>> I'm looking for a catchy phrase denoting this D idiom:
>>
>> template Blah(Stuff)
>> {
>>    alias ... Blah;
>> }
>>
>> i.e., defining inside a template a symbol of the same name as the template itself. Then you can use Blah!(X, Y) to mean Blah!(X, Y).Blah.
>>
>> What would be a catchy, descriptive, and memorable phrase for this?
>>
>>
>> Thanks,
>>
>> Andrei
> 
> Selfish template?

Transparent template?
March 12, 2009
name promotion
March 12, 2009
"Andrei Alexandrescu" <SeeWebsiteForEmail@erdani.org> wrote in message news:gpb2vd$18uf$1@digitalmars.com...
> Hello,
>
>
> I'm looking for a catchy phrase denoting this D idiom:
>
> template Blah(Stuff)
> {
>    alias ... Blah;
> }
>

Unitemplate?


March 12, 2009
On Thu, Mar 12, 2009 at 9:33 AM, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:
> Hello,
>
>
> I'm looking for a catchy phrase denoting this D idiom:
>
> template Blah(Stuff)
> {
>   alias ... Blah;
> }
>
> i.e., defining inside a template a symbol of the same name as the template
> itself. Then you can use Blah!(X, Y) to mean Blah!(X, Y).Blah.
>
> What would be a catchy, descriptive, and memorable phrase for this?

...Unnecessary?

You know i have to be contrary :P but I have never found a use for multiple declarations inside a template _except_ when it's used as a mixin.  Most of the time, I declare exactly one symbol inside the template, and it's always the same name as the template.  Having to specify the name of the template over and over inside it is a blatant violation of DRY, easy to mess up (typos, changing the template name etc.) and is hard to diagnose when you do it wrong, since the compiler just has no idea what you're trying to do and you end up with all sorts of confusing errors about voids having no value.

Allowing multiple declarations inside templates looks good in the spec, but honestly, I only ever use it for mixins.  My mixin templates are also never used as anything other than mixin templates, creating this sort of split between templates and mixins, even though they're represented by the same language structure.  Mixins are really more like a limited form of semihygenic AST macro, one which can only expand to declarations and not arbitrary code structures.

If templates were limited to a single declaration - and mixins were either changed to a different "type" or replaced outright by macros - I'd be perfectly happy, and there'd be no need for Implicit Template Name Forwarding (do you see what I just did there ;) ).
March 12, 2009
On Thu, 12 Mar 2009 23:11:49 +0300, Jarrett Billingsley <jarrett.billingsley@gmail.com> wrote:

> On Thu, Mar 12, 2009 at 9:33 AM, Andrei Alexandrescu
> <SeeWebsiteForEmail@erdani.org> wrote:
>> Hello,
>>
>>
>> I'm looking for a catchy phrase denoting this D idiom:
>>
>> template Blah(Stuff)
>> {
>>   alias ... Blah;
>> }
>>
>> i.e., defining inside a template a symbol of the same name as the template
>> itself. Then you can use Blah!(X, Y) to mean Blah!(X, Y).Blah.
>>
>> What would be a catchy, descriptive, and memorable phrase for this?
>
> ...Unnecessary?
>
> You know i have to be contrary :P but I have never found a use for
> multiple declarations inside a template _except_ when it's used as a
> mixin.  Most of the time, I declare exactly one symbol inside the
> template, and it's always the same name as the template.  Having to
> specify the name of the template over and over inside it is a blatant
> violation of DRY, easy to mess up (typos, changing the template name
> etc.) and is hard to diagnose when you do it wrong, since the compiler
> just has no idea what you're trying to do and you end up with all
> sorts of confusing errors about voids having no value.
>
> Allowing multiple declarations inside templates looks good in the
> spec, but honestly, I only ever use it for mixins.  My mixin templates
> are also never used as anything other than mixin templates, creating
> this sort of split between templates and mixins, even though they're
> represented by the same language structure.  Mixins are really more
> like a limited form of semihygenic AST macro, one which can only
> expand to declarations and not arbitrary code structures.
>
> If templates were limited to a single declaration - and mixins were
> either changed to a different "type" or replaced outright by macros -
> I'd be perfectly happy, and there'd be no need for Implicit Template
> Name Forwarding (do you see what I just did there ;) ).

Completely agree. That's why I proposed to separate templates and template mixins one from another:
http://www.digitalmars.com/d/archives/digitalmars/D/internal_local_template_memebers_78677.html#N78698
March 12, 2009
On Thu, 12 Mar 2009 16:11:49 -0400, Jarrett Billingsley wrote:

> On Thu, Mar 12, 2009 at 9:33 AM, Andrei Alexandrescu
> <SeeWebsiteForEmail@erdani.org> wrote:
>> Hello,
>>
>>
>> I'm looking for a catchy phrase denoting this D idiom:
>>
>> template Blah(Stuff)
>> {
>>   alias ... Blah;
>> }
>>
>> i.e., defining inside a template a symbol of the same name as the template
>> itself. Then you can use Blah!(X, Y) to mean Blah!(X, Y).Blah.
>>
>> What would be a catchy, descriptive, and memorable phrase for this?
>
> ...Unnecessary?
>
> You know i have to be contrary :P but I have never found a use for
> multiple declarations inside a template _except_ when it's used as a
> mixin.  Most of the time, I declare exactly one symbol inside the
> template, and it's always the same name as the template.  Having to
> specify the name of the template over and over inside it is a blatant
> violation of DRY, easy to mess up (typos, changing the template name
> etc.) and is hard to diagnose when you do it wrong, since the compiler
> just has no idea what you're trying to do and you end up with all
> sorts of confusing errors about voids having no value.

How do you do this without the Template Identity syntax?
(I'm going to start calling it this to promote the term I thought was best ;)

tempalte Blah(T)
{
   static if(is(T : int))
      alias T Blah;
   else
      alias T* Blah;
}

-Steve
March 12, 2009
Jarrett Billingsley wrote:
> On Thu, Mar 12, 2009 at 9:33 AM, Andrei Alexandrescu
> <SeeWebsiteForEmail@erdani.org> wrote:
>> Hello,
>>
>>
>> I'm looking for a catchy phrase denoting this D idiom:
>>
>> template Blah(Stuff)
>> {
>>   alias ... Blah;
>> }
>>
>> i.e., defining inside a template a symbol of the same name as the template
>> itself. Then you can use Blah!(X, Y) to mean Blah!(X, Y).Blah.
>>
>> What would be a catchy, descriptive, and memorable phrase for this?
> 
> ...Unnecessary?
> 
> You know i have to be contrary :P but I have never found a use for
> multiple declarations inside a template _except_ when it's used as a
> mixin.  Most of the time, I declare exactly one symbol inside the
> template, and it's always the same name as the template.  Having to
> specify the name of the template over and over inside it is a blatant
> violation of DRY, easy to mess up (typos, changing the template name
> etc.) and is hard to diagnose when you do it wrong, since the compiler
> just has no idea what you're trying to do and you end up with all
> sorts of confusing errors about voids having no value.
> 
> Allowing multiple declarations inside templates looks good in the
> spec, but honestly, I only ever use it for mixins.  My mixin templates
> are also never used as anything other than mixin templates, creating
> this sort of split between templates and mixins, even though they're
> represented by the same language structure.  Mixins are really more
> like a limited form of semihygenic AST macro, one which can only
> expand to declarations and not arbitrary code structures.
> 
> If templates were limited to a single declaration - and mixins were
> either changed to a different "type" or replaced outright by macros -
> I'd be perfectly happy, and there'd be no need for Implicit Template
> Name Forwarding (do you see what I just did there ;) ).

Nice. The problem however is that very, very often I need to store intermediate results, otherwise the code becomes quickly unreadable or spread across too many different non-reusable templates. What I now do is e.g. create a short template Blah(X, Y, Z) that aliases itself to BlahImpl!(X, Y, Z).Result. Hardly elegant.

I suggested Walter to allow templates using the eponymous trick to be able to define private symbols.


Andrei
March 12, 2009
On Thu, 12 Mar 2009 23:20:07 +0300, Steven Schveighoffer <schveiguy@yahoo.com> wrote:

> On Thu, 12 Mar 2009 16:11:49 -0400, Jarrett Billingsley wrote:
>
>> On Thu, Mar 12, 2009 at 9:33 AM, Andrei Alexandrescu
>> <SeeWebsiteForEmail@erdani.org> wrote:
>>> Hello,
>>>
>>>
>>> I'm looking for a catchy phrase denoting this D idiom:
>>>
>>> template Blah(Stuff)
>>> {
>>>   alias ... Blah;
>>> }
>>>
>>> i.e., defining inside a template a symbol of the same name as the template
>>> itself. Then you can use Blah!(X, Y) to mean Blah!(X, Y).Blah.
>>>
>>> What would be a catchy, descriptive, and memorable phrase for this?
>>
>> ...Unnecessary?
>>
>> You know i have to be contrary :P but I have never found a use for
>> multiple declarations inside a template _except_ when it's used as a
>> mixin.  Most of the time, I declare exactly one symbol inside the
>> template, and it's always the same name as the template.  Having to
>> specify the name of the template over and over inside it is a blatant
>> violation of DRY, easy to mess up (typos, changing the template name
>> etc.) and is hard to diagnose when you do it wrong, since the compiler
>> just has no idea what you're trying to do and you end up with all
>> sorts of confusing errors about voids having no value.
>
> How do you do this without the Template Identity syntax?
> (I'm going to start calling it this to promote the term I thought was best ;)
>
> tempalte Blah(T)
> {
>     static if(is(T : int))
>        alias T Blah;
>     else
>        alias T* Blah;
> }
>
> -Steve

A new 'tempalte' keyword?

Back on topic, I don't see anything wrong with this code. It defines exactly one alias.

I also think that it should define exactly one /public/ alias:

template Blah(T)
{
   private alias Foo!(T).A Tmp1;
   private alias Bar!(Tmp1!(T)).B Tmp2;

   static if (Tmp2.C!(T)) {
       private alias Tmp2.ResultA Tmp3;
   } else {
       private alias Tmp2.ResultB Tmp3;
   }

   /*public*/ alias Tmp3!(Tmp2!(Tmp1!())).C Blah;
}

This syntax makes little sense for template mixins, and that's one more reason why I proposed separating them (see my other post nearby).

March 12, 2009
On Thu, Mar 12, 2009 at 4:20 PM, Steven Schveighoffer <schveiguy@yahoo.com> wrote:
>
> How do you do this without the Template Identity syntax?
> (I'm going to start calling it this to promote the term I thought was best
> ;)

I'm not suggesting it be removed.  I'm suggesting that if you were only able to put one symbol in the template, it would be completely unnecessary.  Templates would always resolve to the single symbol that they declare.