Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any language that allows spaces in its variable names [closed]

Is there (or was there ever) any non-trivial language that allows spaces in its variable names?

I am aware of the language Whitespace, but I'm interested in a language that was actually used for something besides demonstration.

I ask this out of pure curiosity.

like image 413
tjb Avatar asked Feb 28 '11 11:02

tjb


People also ask

Is space allowed in variable name?

Specifically, spaces are not permitted in the variable names, as the variable name must be a single word. The variable name may not start with a digit or underscore, and may not end with an underscore. Double underscores are not permitted in the variable names. Hence the correct answer is White space characters.

Can C++ variables have spaces?

Variable names are case sensitive. No spaces or special characters are allowed. You cannot use a C++ keyword (a reserved word) as a variable name.

Are spaces allowed in variable names in Python?

You cannot use spaces in identifiers in Python. Spaces aren't legal in variable names. Use an underscore _ if you must.

Can variable names in Java have spaces?

Java has about 50 reserved words or keywords that you are not allowed to use as variable names such as public , class , static , void , int … Because a Java variable name can't have spaces, a style called camelCase is usually used for variable names with more than one word.


2 Answers

In a way, yes. Several languages's variable names are really just keys to a higher-level object. Both Coldfusion and Javascript come to mind. In Javascript, you can write foo=bar, but what you've really said is:

window['foo'] = bar;

You could just as easily write

window['i haz a name'] = bar;

The various scopes in Coldfusion can also be treated as either a (dict|hash|associative array) or a name.

Of course, once you've created a name with whitespace, it's harder to access without using the hash lookup syntax.

like image 181
kojiro Avatar answered Sep 27 '22 15:09

kojiro


TSQL will allow you to use whitespace in table and column names aslong as you have it between square braces [ ]

Theres a fantastic article on just what sql will let you get away with here http://www.sqlservercentral.com/blogs/philfactor/archive/2009/08/14/evil-code.aspx

like image 36
Robb Avatar answered Sep 27 '22 17:09

Robb