String literal arguments

Yao G. nospamyaoltzin at gmail.com
Wed Apr 7 00:39:29 PDT 2010


On Wed, 07 Apr 2010 03:05:34 -0400, Simen kjaeraas  
<simen.kjaras at gmail.com> wrote:

> Yao G. <nospamyaoltzin at gmail.com> wrote:
>
>> Hello.
>
> Greetings.
>
>> foo( "Hello World", first, second );
>> ---
>>
>> You can notice that the first argument is a string literal. What I want  
>> to know is: If a function argument is declared as a string literal, it  
>> can be accessed at compile time? And if the answer is yes, how can I do  
>> it?.
>
> Afraid not. What you posted later is the only way to do this. This has
> been discussed several times in the past, and some suggestions have
> popped up, including static function parameters:
>
> void foo( static string s ) {
>    // s is a compile time constant
> }
>
> This has however not been implemented.
>

bearophile and Simen:

Thanks for your answers. Yes, I thought that this was not going to be  
possible. But again, is not a big deal for me. I'll continue to use the  
string-as-template version. I just wanted to explore the possibility,  
because I wanted this function to be consistent with my other code.

Cheers!


More information about the Digitalmars-d-learn mailing list