legal identifier check

Saaa empty at needmail.com
Sun May 31 07:12:12 PDT 2009


> Saaa wrote:
>> Is there a function to check whether some string is a legal identifier?
>>
>>
>
> Sure.
>
> static if(is(typeof({ /* code to be checked for validity goes here */ }))) 
> ...

That is a compile time check, right?
I meant a runtime check.

How does that piece of code work anyways :D
static if = compile time if
is = comparison between two non value things?
typeof = returns the type

I know use this (in the ddata thread above):

foreach(char c; identifier)
{
 if( !inPattern( c, `_a-zA-Z0-9`) )
 {
  return false;
 }
} 




More information about the Digitalmars-d-learn mailing list