www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - catchy phrase for this idiom?

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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
Mar 12 2009
next sibling parent jq <jlquinn optonline.net> writes:
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?

Template forwarding? Jerry
Mar 12 2009
prev sibling next sibling parent reply Don <nospam nospam.com> writes:
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?
Mar 12 2009
parent Don <nospam nospam.com> writes:
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?
Mar 12 2009
prev sibling next sibling parent Gide Nwawudu <gide btinternet.com> writes:
On Thu, 12 Mar 2009 06:33:34 -0700, 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?


Thanks,

Andrei

Reciprocal template declaration? Gide
Mar 12 2009
prev sibling next sibling parent reply Sean Kelly <sean invisibleduck.org> writes:
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?

Template identity definition?
Mar 12 2009
next sibling parent Sean Kelly <sean invisibleduck.org> writes:
Sean Kelly 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?

Template identity definition?

Oh, and should this actually be: template Blah(Stuff) { alias ... this; } I thought that was the new syntax.
Mar 12 2009
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Thu, 12 Mar 2009 11:01:21 -0400, Sean Kelly <sean invisibleduck.org>  
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?

Template identity definition?

Sounds good. I think Template Identity sounds good too. -Steve
Mar 12 2009
prev sibling next sibling parent Bill Baxter <wbaxter gmail.com> writes:
eponymous alias?

--bb

On Fri, Mar 13, 2009 at 12:55 AM, Steven Schveighoffer
<schveiguy yahoo.com> wrote:
 On Thu, 12 Mar 2009 11:01:21 -0400, Sean Kelly <sean invisibleduck.org>
 wrote:

 Andrei Alexandrescu wrote:
 Hello,
 =A0I'm looking for a catchy phrase denoting this D idiom:
 =A0template Blah(Stuff)
 {
 =A0 alias ... Blah;
 }
 =A0i.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.
 =A0What would be a catchy, descriptive, and memorable phrase for this?

Template identity definition?

Sounds good. I think Template Identity sounds good too. -Steve

Mar 12 2009
prev sibling parent Bill Baxter <wbaxter gmail.com> writes:
eponymous alias?

--bb

On Fri, Mar 13, 2009 at 12:55 AM, Steven Schveighoffer
<schveiguy yahoo.com> wrote:
 On Thu, 12 Mar 2009 11:01:21 -0400, Sean Kelly <sean invisibleduck.org>
 wrote:

 Andrei Alexandrescu wrote:
 Hello,
 =A0I'm looking for a catchy phrase denoting this D idiom:
 =A0template Blah(Stuff)
 {
 =A0 alias ... Blah;
 }
 =A0i.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.
 =A0What would be a catchy, descriptive, and memorable phrase for this?

Template identity definition?

Sounds good. I think Template Identity sounds good too. -Steve

Mar 12 2009
prev sibling next sibling parent reply BCS <ao pathlink.com> writes:
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
Mar 12 2009
parent Ary Borenszweig <ary esperanto.org.ar> writes:
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?
Mar 12 2009
prev sibling next sibling parent Walter Bright <newshound1 digitalmars.com> writes:
name promotion
Mar 12 2009
prev sibling next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"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?
Mar 12 2009
parent "Nick Sabalausky" <a a.a> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:gpbnms$2ba1$1 digitalmars.com...
 "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?

...Unless you're talking specifically about an alias (as opposed to the general case of it being an alias or a const char[] or a function or a class, etc), in which case it should just be "alias template" to go along with "function template" and "class template".
Mar 12 2009
prev sibling next sibling parent reply Jarrett Billingsley <jarrett.billingsley gmail.com> writes:
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)
 {
 =A0 alias ... Blah;
 }

 i.e., defining inside a template a symbol of the same name as the templat=

 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 ;) ).
Mar 12 2009
next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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
Mar 12 2009
prev sibling parent Ary Borenszweig <ary esperanto.org.ar> writes:
Denis Koroskin escribió:
 On Fri, 13 Mar 2009 03:24:10 +0300, Jarrett Billingsley 
 <jarrett.billingsley gmail.com> wrote:
 
 On Thu, Mar 12, 2009 at 5:05 PM, Steven Schveighoffer
 <schveiguy yahoo.com> wrote:
 On Thu, 12 Mar 2009 16:37:06 -0400, Jarrett Billingsley
 <jarrett.billingsley gmail.com> wrote:

 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.

So without requiring the alias how do you rewrite my example? I'm not saying you are wrong, I just don't grasp what you are saying. An example would be helpful.

It would go along with the suggestion of having some kind of name for the current template. Something like: template Blah(T) { static if(is(T : int)) alias T this template; else alias T* this template; } 'this template' (which reads like English, nicely) would be lexicalized as a single token and would only be legal within templates. But this suggestion is somewhat orthogonal.

Sean has proposed (or let out a secret?) that: On Thu, 12 Mar 2009 18:02:18 +0300, Sean Kelly <sean invisibleduck.org> wrote:
 Oh, and should this actually be:

 template Blah(Stuff)
 {
      alias ... this;
 }

 I thought that was the new syntax.


But maybe "this" gets confused with "this class' instance" (just the meaning, I think there's no ambiguity in the semantic pass). What about: alias T template; ?
Mar 12 2009
prev sibling next sibling parent "Denis Koroskin" <2korden gmail.com> writes:
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
Mar 12 2009
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
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
Mar 12 2009
prev sibling next sibling parent reply "Denis Koroskin" <2korden gmail.com> writes:
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).
Mar 12 2009
next sibling parent BCS <ao pathlink.com> writes:
Reply to Denis,

 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; }
 

That covers my one major concern with the exactly one rule; local values. OTOH I have used template with many public value as a type of compile time structs. It's an absolute must for anything thing that require data structures like parsing of strings.
Mar 12 2009
prev sibling parent reply "Denis Koroskin" <2korden gmail.com> writes:
On Thu, 12 Mar 2009 23:56:55 +0300, BCS <ao pathlink.com> wrote:

 Reply to Denis,

 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; }

That covers my one major concern with the exactly one rule; local values. OTOH I have used template with many public value as a type of compile time structs. It's an absolute must for anything thing that require data structures like parsing of strings.

You could use a tuple or struct for that purpose: template Blah(Stuff) { struct Blah { // code that defines multiple symbols here } }
Mar 12 2009
next sibling parent BCS <ao pathlink.com> writes:
Reply to Denis,

 On Thu, 12 Mar 2009 23:56:55 +0300, BCS <ao pathlink.com> wrote:
 
 Reply to Denis,
 
 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; }

values. OTOH I have used template with many public value as a type of compile time structs. It's an absolute must for anything thing that require data structures like parsing of strings.

template Blah(Stuff) { struct Blah { // code that defines multiple symbols here } }

Under some conditions (I never figured out the details) you end up being forced to do that anyway. However in heavy code you can literally get MB of meta data generated for struct that are never actually used for anything.
Mar 12 2009
prev sibling parent reply "Denis Koroskin" <2korden gmail.com> writes:
On Fri, 13 Mar 2009 00:56:48 +0300, BCS <ao pathlink.com> wrote:

 Reply to Denis,

 On Thu, 12 Mar 2009 23:56:55 +0300, BCS <ao pathlink.com> wrote:

 Reply to Denis,

 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; }

values. OTOH I have used template with many public value as a type of compile time structs. It's an absolute must for anything thing that require data structures like parsing of strings.

template Blah(Stuff) { struct Blah { // code that defines multiple symbols here } }

Under some conditions (I never figured out the details) you end up being forced to do that anyway. However in heavy code you can literally get MB of meta data generated for struct that are never actually used for anything.

These should be stripped by linked, shoudn't they? That's a separate issue if linker doesn't do it properly.
Mar 12 2009
parent BCS <ao pathlink.com> writes:
Reply to Denis,

 On Fri, 13 Mar 2009 00:56:48 +0300, BCS <ao pathlink.com> wrote:
 
 Under some conditions (I never figured out the details) you end up
 being  forced to do that anyway. However in heavy code you can
 literally get MB  of meta data generated for struct that are never
 actually used for  anything.
 

issue if linker doesn't do it properly.

That would help some, but they cause problems both that the link level (extra IO) and the the compile time level (I have seen dmd spend *minutes* generating the meta data.
Mar 12 2009
prev sibling next sibling parent Jarrett Billingsley <jarrett.billingsley gmail.com> writes:
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.
Mar 12 2009
prev sibling next sibling parent Jarrett Billingsley <jarrett.billingsley gmail.com> writes:
On Thu, Mar 12, 2009 at 4:26 PM, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:
 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.

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

That seems like a reasonable solution. I'm assuming you'd allow templates to define at most one public symbol.
Mar 12 2009
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Thu, 12 Mar 2009 16:37:06 -0400, Jarrett Billingsley  
<jarrett.billingsley gmail.com> wrote:

 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.

So without requiring the alias how do you rewrite my example? I'm not saying you are wrong, I just don't grasp what you are saying. An example would be helpful. -Steve
Mar 12 2009
prev sibling next sibling parent reply Sergey Gromov <snake.scaly gmail.com> writes:
Thu, 12 Mar 2009 06:33:34 -0700, 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

maybe parametrized alias
Mar 12 2009
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Sergey Gromov wrote:
 Thu, 12 Mar 2009 06:33:34 -0700, 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

maybe parametrized alias

That sounds good but (I'm saying this to all others who focused on "alias") - the inner name doesn't have to be an alias. Andrei
Mar 12 2009
parent Sergey Gromov <snake.scaly gmail.com> writes:
Thu, 12 Mar 2009 18:21:04 -0700, Andrei Alexandrescu wrote:

 Sergey Gromov wrote:
 Thu, 12 Mar 2009 06:33:34 -0700, 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

maybe parametrized alias

That sounds good but (I'm saying this to all others who focused on "alias") - the inner name doesn't have to be an alias. Andrei

template shortcut?
Mar 14 2009
prev sibling next sibling parent reply Christopher Wright <dhasenan gmail.com> writes:
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

Eigentemplate.
Mar 12 2009
next sibling parent BCS <ao pathlink.com> writes:
Reply to Christopher,


 Eigentemplate.
 

Doh! :)
Mar 12 2009
prev sibling next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Christopher Wright 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

Eigentemplate.

My heart fell among my other integrated circuits. Looks like a huge winner. Thanks Christopher. Oh boy. I wasn't even dreaming about something *this* good. Andrei
Mar 12 2009
next sibling parent Walter Bright <newshound1 digitalmars.com> writes:
Bill Baxter wrote:
 But it is what the word "eponymous" is about.

I can't even pronounce "eponymous". Not too catchy :-)
Mar 12 2009
prev sibling next sibling parent Christopher Wright <dhasenan gmail.com> writes:
Bill Baxter wrote:
 Kinda not the same thing if you ask me.  Eigen-blah generally refers
 to something where you've captured the essence of something better by
 representing it using a different set of basis functions.

That's pretty specific for a German word meaning 'self'.
Mar 13 2009
prev sibling parent Robert Fraser <fraserofthenight gmail.com> writes:
Andrei Alexandrescu wrote:
 Christopher Wright 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

Eigentemplate.

My heart fell among my other integrated circuits. Looks like a huge winner. Thanks Christopher. Oh boy. I wasn't even dreaming about something *this* good. Andrei

If it's called this, I will have flashbacks to Linear Algebra every time I use it. Just reading this thread brought back my PTSD.
Mar 13 2009
prev sibling next sibling parent reply Bill Baxter <wbaxter gmail.com> writes:
On Thu, Mar 12, 2009 at 6:24 PM, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:
 Christopher Wright wrote:
 Andrei Alexandrescu wrote:
 Hello,


 I'm looking for a catchy phrase denoting this D idiom:

 template Blah(Stuff)
 {
 =A0 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

Eigentemplate.

My heart fell among my other integrated circuits. Looks like a huge winne=

 Thanks Christopher. Oh boy. I wasn't even dreaming about something *this*
 good.

Kinda not the same thing if you ask me. Eigen-blah generally refers to something where you've captured the essence of something better by representing it using a different set of basis functions. This doesn't seem to have much of anything to do with that. Its just identity or sameness of name. That's not really what eigen thingys are about. But it is what the word "eponymous" is about. --bb
Mar 12 2009
next sibling parent reply BCS <none anon.com> writes:
Hello Bill,

 Kinda not the same thing if you ask me.  Eigen-blah generally refers
 to something where you've captured the essence of something better by
 representing it using a different set of basis functions.
 
 This doesn't seem to have much of anything to do with that.  Its just
 identity or sameness of name.  That's not really what eigen thingys
 are about.
 

An Eigen value for a matrix M is a vector V sutch that M x V = V (IIRC)
Mar 12 2009
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
BCS wrote:
 Hello Bill,
 
 Kinda not the same thing if you ask me.  Eigen-blah generally refers
 to something where you've captured the essence of something better by
 representing it using a different set of basis functions.

 This doesn't seem to have much of anything to do with that.  Its just
 identity or sameness of name.  That's not really what eigen thingys
 are about.

An Eigen value for a matrix M is a vector V sutch that M x V = V (IIRC)

That's an eigenvector. An eigenvalue is a multiplier alpha such that M x V = alpha V. "Eigen" in German means "its own", proper. I previously liked "the eponymous trick" as it had a nice self-recurrence flavor, but I like "eigentemplates" better. Andrei
Mar 13 2009
prev sibling parent Bill Baxter <wbaxter gmail.com> writes:
On Fri, Mar 13, 2009 at 1:30 PM, BCS <none anon.com> wrote:
 Hello Bill,

 Kinda not the same thing if you ask me. =A0Eigen-blah generally refers
 to something where you've captured the essence of something better by
 representing it using a different set of basis functions.

 This doesn't seem to have much of anything to do with that. =A0Its just
 identity or sameness of name. =A0That's not really what eigen thingys
 are about.

An Eigen value for a matrix M is a vector V sutch that M x V =3D V (IIRC)

Close, If M v =3D \lambda v Then \lambda is an eigenvalue (a scalar), v is the eigenvector (a vector) --bb
Mar 12 2009
prev sibling next sibling parent Bill Baxter <wbaxter gmail.com> writes:
On Fri, Mar 13, 2009 at 12:07 PM, Walter Bright
<newshound1 digitalmars.com> wrote:
 Bill Baxter wrote:
 But it is what the word "eponymous" is about.

I can't even pronounce "eponymous". Not too catchy :-)

R.E.M. thought it was catchy enough to name an album that. :-) Seriously, though, I don't really care what you call it. --bb
Mar 12 2009
prev sibling parent "Simen Kjaeraas" <simen.kjaras gmail.com> writes:
Robert Fraser <fraserofthenight gmail.com> wrote:

 Andrei Alexandrescu wrote:
 Christopher Wright 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

Eigentemplate.

winner. Thanks Christopher. Oh boy. I wasn't even dreaming about something *this* good. Andrei

If it's called this, I will have flashbacks to Linear Algebra every time I use it. Just reading this thread brought back my PTSD.

And here I thought that'd be a good thing... -- Simen
Mar 13 2009
prev sibling next sibling parent Jarrett Billingsley <jarrett.billingsley gmail.com> writes:
On Thu, Mar 12, 2009 at 5:05 PM, Steven Schveighoffer
<schveiguy yahoo.com> wrote:
 On Thu, 12 Mar 2009 16:37:06 -0400, Jarrett Billingsley
 <jarrett.billingsley gmail.com> wrote:

 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. =A0I'm suggesting that if you were only able to put one symbol in the template, it would be completely unnecessary. =A0Templates would always resolve to the single symbol that they declare.

So without requiring the alias how do you rewrite my example? =A0I'm not saying you are wrong, I just don't grasp what you are saying. =A0An examp=

 would be helpful.

It would go along with the suggestion of having some kind of name for the current template. Something like: template Blah(T) { static if(is(T : int)) alias T this template; else alias T* this template; } 'this template' (which reads like English, nicely) would be lexicalized as a single token and would only be legal within templates. But this suggestion is somewhat orthogonal.
Mar 12 2009
prev sibling next sibling parent "Denis Koroskin" <2korden gmail.com> writes:
On Fri, 13 Mar 2009 03:24:10 +0300, Jarrett Billingsley
<jarrett.billingsley gmail.com> wrote:

 On Thu, Mar 12, 2009 at 5:05 PM, Steven Schveighoffer
 <schveiguy yahoo.com> wrote:
 On Thu, 12 Mar 2009 16:37:06 -0400, Jarrett Billingsley
 <jarrett.billingsley gmail.com> wrote:

 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.

So without requiring the alias how do you rewrite my example? I'm not saying you are wrong, I just don't grasp what you are saying. An example would be helpful.

It would go along with the suggestion of having some kind of name for the current template. Something like: template Blah(T) { static if(is(T : int)) alias T this template; else alias T* this template; } 'this template' (which reads like English, nicely) would be lexicalized as a single token and would only be legal within templates. But this suggestion is somewhat orthogonal.

Sean has proposed (or let out a secret?) that: On Thu, 12 Mar 2009 18:02:18 +0300, Sean Kelly <sean invisibleduck.org> wrote:
 Oh, and should this actually be:

 template Blah(Stuff)
 {
      alias ... this;
 }

 I thought that was the new syntax.

Mar 12 2009
prev sibling parent reply Kagamin <spam here.lot> writes:
Andrei Alexandrescu Wrote:

 I'm looking for a catchy phrase denoting this D idiom:
 
 template Blah(Stuff)
 {
     alias ... Blah;
 }

verbose templated declaration.
Mar 13 2009
next sibling parent "Nick Sabalausky" <a a.a> writes:
"Kagamin" <spam here.lot> wrote in message 
news:gpd8ka$1npp$1 digitalmars.com...
 Andrei Alexandrescu Wrote:

 I'm looking for a catchy phrase denoting this D idiom:

 template Blah(Stuff)
 {
     alias ... Blah;
 }

verbose templated declaration.

As far as I'm concerned, we've found a winner right here ;)
Mar 13 2009
prev sibling parent reply "Tim M" <a b.com> writes:
On Fri, 13 Mar 2009 22:49:00 +1300, Nick Sabalausky <a a.a> wrote:

 "Kagamin" <spam here.lot> wrote in message
 news:gpd8ka$1npp$1 digitalmars.com...
 Andrei Alexandrescu Wrote:

 I'm looking for a catchy phrase denoting this D idiom:

 template Blah(Stuff)
 {
     alias ... Blah;
 }

verbose templated declaration.

As far as I'm concerned, we've found a winner right here ;)

What's verbose about a template with a single declaration? Verbose adj. "Using or containing a great and usually an excessive number of words" Or is that part of the trickey?
Mar 14 2009
next sibling parent BCS <none anon.com> writes:
Hello Tim,

 What's verbose about a template with a single declaration?
 
 Verbose adj. "Using or containing a great and usually an excessive
 number  of words"
 

there is no compact form for alias but this T Foo(T)(T t) { return t; } is internally identical the the more verbose form: template Foo(T) { T Foo(T t){ return t; } }
Mar 14 2009
prev sibling parent reply "Tim M" <a b.com> writes:
On Sun, 15 Mar 2009 06:27:42 +1300, BCS <none anon.com> wrote:

 there is no compact form for alias but this

 T Foo(T)(T t) { return t; }

 is internally identical the the more verbose form:

 template Foo(T) { T Foo(T t){ return t; } }

Hi BCS. On this page: http://www.digitalmars.com/d/1.0/template.html scroll down to "Implicit Template Properties" and it says: "If a template has exactly one member in it, and the name of that member is the same as the template name, that member is assumed to be referred to in a template instantiation". I think Andrei Alexandrescu was actually looking a catchy name for this. You don't have to specify the templates only property, you use the template directly. So its a technique used to make your code less verbose.
Mar 15 2009
parent BCS <none anon.com> writes:
Hello Tim,

 On Sun, 15 Mar 2009 06:27:42 +1300, BCS <none anon.com> wrote:
 
 there is no compact form for alias but this
 
 T Foo(T)(T t) { return t; }
 
 is internally identical the the more verbose form:
 
 template Foo(T) { T Foo(T t){ return t; } }
 

scroll down to "Implicit Template Properties" and it says: "If a template has exactly one member in it, and the name of that member is the same as the template name, that member is assumed to be referred to in a template instantiation". I think Andrei Alexandrescu was actually looking a catchy name for this. You don't have to specify the templates only property, you use the template directly. So its a technique used to make your code less verbose.

Yes, I known that. I was answering the question you asked about what is verbose about the usage Andrei posted. I was pointing out that if you consider not the feature he was asking about but the form he used, then verbose is a good description. If the example is converted to a function example, as I illustrated, then this becomes even more clear as the form Andrei used is indeed more verbose than the other option. The person who suggested "verbose" as a good name is not totally off base as often, even with functions, you end up needing to switch to the more verbose form to allow static asserts or static ifs around the function.
Mar 15 2009