Skip to main content
added 119 characters in body
Source Link
Eugene
  • 117
  • 3

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'llIt 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 that's no different from using class_it must add a little bit complexity to the lexer.

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'll save the lexer some trivial trouble, but the programmer finally gets to use the words float, class, template ... etc.

Contrarily, C# allows @class as variable name, but that's no different from using class_.

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.

The question is now about pros and cons.
Source Link
Eugene
  • 117
  • 3

What are some programming languages in which 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'll save the lexer some trivial trouble, but the programmer finally gets to use the words float, class, template ... etc.

Or the countrary - user defined names must be prefixed with a special character.

Are there (popular) languages that do either?


Would you please leave a comment on why you downvoted? Thanks!

The idea may be dumb, but it'll actually help me (and possibly others) if you illustrate how bad it is. This is but an honest question for a list of languages. All popular languages that I have had any experience with have the same lexical rules for keywords and identifiersContrarily, suchC# allows @class as C, C++, Python, Lua, Verilog, D, Rustvariable name, Go ... and so on. None separates its keywordsbut that's no different from regular names. I know I'm probably on the dumb sideusing class_.

What are some programming languages in which 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'll save the lexer some trivial trouble, but the programmer finally gets to use the words float, class, template ... etc.

Or the countrary - user defined names must be prefixed with a special character.

Are there (popular) languages that do either?


Would you please leave a comment on why you downvoted? Thanks!

The idea may be dumb, but it'll actually help me (and possibly others) if you illustrate how bad it is. This is but an honest question for a list of languages. All popular languages that I have had any experience with have the same lexical rules for keywords and identifiers, such as C, C++, Python, Lua, Verilog, D, Rust, Go ... and so on. None separates its keywords from regular names. I know I'm probably on the dumb side.

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'll save the lexer some trivial trouble, but the programmer finally gets to use the words float, class, template ... etc.

Contrarily, C# allows @class as variable name, but that's no different from using class_.

[Edit removed during grace period]
Added to review
Source Link
Eugene
  • 117
  • 3
Post Closed as "Not suitable for this site" by gnat, Jörg W Mittag, Philip Kendall
added 507 characters in body
Source Link
Eugene
  • 117
  • 3
Loading
Source Link
Eugene
  • 117
  • 3
Loading