9

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.

Yu Hao
  • 115,525
  • 42
  • 225
  • 281
tjb
  • 10,986
  • 8
  • 64
  • 89
  • 1
    weird question... well PHP allows it, in an obscure way ` $foobar = "bar foo"; ${$foobar} = "foo bar"; var_dump(get_defined_vars(${$foobar}));` – Hannes Feb 28 '11 at 11:27
  • Windows `set` command considers spaces before `=` in the variable name. So `set var =` will create a variable called `%var %` but `set var=` will create a variable called `%var%` – phuclv Jan 08 '16 at 08:24

2 Answers2

6

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.

kojiro
  • 71,091
  • 17
  • 131
  • 188
  • Thanks kojiro, I guess this an SQL is as close as any language comes, you get the point because you were first. – tjb Mar 01 '11 at 19:14
2

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

Robb
  • 3,690
  • 1
  • 36
  • 37