Re: Is it possible to escape a reserved keyword in Import/module?
On Wednesday, 19 June 2019 at 21:21:53 UTC, XavierAP wrote: On Wednesday, 19 June 2019 at 18:56:57 UTC, BoQsc wrote: I would like to make sure that my modules do not interfere with d lang. Is there any way to escape reserved words? The only reason C# allows this is for interop or code generation for other languages that use the same keyword. For example "class" is an HTML attribute. There is no excuse to do this for any other reason -- and C# gurus would also agree. I would like to make sure that my modules do not interfere Then don't name them as keywords :) I used twice a similar system (&) that exists in ObjFPC. The context was a RTTI inspector and allowed to have enum members displayed without using a prefix or a translation table. Just to say, it's rarely useful but nice to have. I would have preferred # so much more that the "body" -> "do" change, which was a bad decision because focused on a detail. You mentioned "class"...
Re: Is it possible to escape a reserved keyword in Import/module?
On Wednesday, 19 June 2019 at 18:56:57 UTC, BoQsc wrote: I would like to make sure that my modules do not interfere with d lang. Is there any way to escape reserved words? The only reason C# allows this is for interop or code generation for other languages that use the same keyword. For example "class" is an HTML attribute. There is no excuse to do this for any other reason -- and C# gurus would also agree. I would like to make sure that my modules do not interfere Then don't name them as keywords :)
Re: Is it possible to escape a reserved keyword in Import/module?
On Wednesday, 19 June 2019 at 19:07:30 UTC, Jonathan M Davis wrote: On Wednesday, June 19, 2019 12:56:57 PM MDT BoQsc via Digitalmars-d-learn wrote: I would like to make sure that my modules do not interfere with d lang. Is there any way to escape reserved words? https://dlang.org/spec/lex.html#keywords > import alias; C:\Users\Juozas\Desktop\om.d(2): Error: identifier expected following import C:\Users\Juozas\Desktop\om.d(2): Error: ; expected > module abstract; C:\Users\Juozas\Desktop\commands\alias.d(1): Error: identifier expected following module You can never use keywords as identifiers in D (or any language in the C family that I've ever heard of). C# can use them when they are prefixed with a little "@" before [1]. At some point the idea was brought for D [2]. [1] https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/index [2] https://github.com/dlang/DIPs/pull/52/files
Re: Is it possible to escape a reserved keyword in Import/module?
On Wednesday, June 19, 2019 12:56:57 PM MDT BoQsc via Digitalmars-d-learn wrote: > I would like to make sure that my modules do not interfere with d > lang. Is there any way to escape reserved words? > https://dlang.org/spec/lex.html#keywords > > > import alias; > > C:\Users\Juozas\Desktop\om.d(2): Error: identifier expected > following import > C:\Users\Juozas\Desktop\om.d(2): Error: ; expected > > > module abstract; > > C:\Users\Juozas\Desktop\commands\alias.d(1): Error: identifier > expected following module You can never use keywords as identifiers in D (or any language in the C family that I've ever heard of). So, you can't ever declare symbols with names like alias or abstract. The way that the official D style guide tackles the problem is to say that any case where a keyword would be needed should append _ to the keyword to make it a legal identifier. https://dlang.org/dstyle.html#naming_keywords So, that's the way that it's handled in the standard library or any other code which follows the D style guide. e.g. The enum std.traits.FunctionAttribute has members such as pure_, nothrow_, and const_, since it can't use the actual keywords. - Jonathan M Davis
Is it possible to escape a reserved keyword in Import/module?
I would like to make sure that my modules do not interfere with d lang. Is there any way to escape reserved words? https://dlang.org/spec/lex.html#keywords import alias; C:\Users\Juozas\Desktop\om.d(2): Error: identifier expected following import C:\Users\Juozas\Desktop\om.d(2): Error: ; expected module abstract; C:\Users\Juozas\Desktop\commands\alias.d(1): Error: identifier expected following module