# operator under C implementation in D1

Daniel Keep daniel.keep.lists at gmail.com
Thu Mar 12 18:33:05 PDT 2009



Sam Hu wrote:
> I know a little that in C there is a # operator which under a macro can return any type's value in character format.Just wanna know whether there is an equivelent implementation in D1.Say,in C using a/m macro can easily output enum's character value other than integer.It would be grateful if anybody would like to paste a few lines of code to demostrate such implementation.
> 
> Regards,
> Sam

D doesn't have text substitution macros, so it doesn't have a # operator.

The closest you can get is .stringof, which has strange and mysterious
ways.  For example, int.stringof, (1+2).stringof, etc.

That, or just quote out the thing you want to turn into a string.

  -- Daniel


More information about the Digitalmars-d-learn mailing list