PHP-style (embedded variables) print statements

Don Clugston dac at nospam.com.au
Sat Jun 2 12:08:20 PDT 2007


Sean Kelly wrote:
> Dejan Lekic wrote:
>> I pray to God I will never have to write code like:
>>
>>>      Stdout("current=")(i)(" next=")(i+1)(" const=")(k*3)(" ")(str);
>>
> 
> I think the Phobos syntax could probably be added to Tango using 
> variadic templates:
> 
>     void opCall( Args... )( Args args )
>     {
>         foreach( arg; args )
>             this.print( arg );
>     }
> 
> Something like that. 

Unfortunately, that adds template bloat, since every combination of types gets 
its own instantation...

  But I personally don't find the "whisper" syntax
> to be particularly annoying.

I don't like it myself, but aside from macros/mixins it's the only typesafe 
option not requiring RTTI or template bloat.
With macros, we should be able to do much the same thing with writefln syntax.
(ie, convert it to a sequence of whisper calls).



More information about the Digitalmars-d mailing list