String literal arguments

Simen kjaeraas simen.kjaras at gmail.com
Wed Apr 7 00:05:34 PDT 2010


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.

-- 
Simen


More information about the Digitalmars-d-learn mailing list