catchy phrase for this idiom?

BCS ao at pathlink.com
Thu Mar 12 14:56:48 PDT 2009


Reply to Denis,

> On Thu, 12 Mar 2009 23:56:55 +0300, BCS <ao at 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
> }
> }

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.





More information about the Digitalmars-d mailing list