Skip to main content
5 of 5
added 119 characters in body
Eugene
  • 117
  • 3

Is it a good idea to let keywords have different lexical rules from names of types, variables, functions, etc?

For example, keywords have a special prefix. Objective-C has @interface, @implementation, but that's for compatibility with C. It inherits all the C keywords of course, with no @. How about a language in which all keywords are prefixed with a special character? It will only save the lexer some trivial trouble, but the programmer finally gets to use the words float, class, template ... etc.

Contrarily, C# allows @class as a variable name, and via reflection the name can be retrieved as "class" instead of "@class". It's good compromise, but it must add a little bit complexity to the lexer.

Eugene
  • 117
  • 3