C# style suggests using CamelCase in identifiers to delimit words. Lisp tradition suggests using-dashes-instead.

Has there ever existed a programming language where using spaces in identifiers was not only allowed, but a commonly used idiom when employing multi-word identifiers?

It's possible to have identifiers with spaces in some Scheme implementations, but it's not a widely seen practice. Here's an example:

Petite Chez Scheme Version 8.4
Copyright (c) 1985-2011 Cadence Research Systems

> (define |hey there| 100)
> (define |x y z| 200)
> (list |hey there| |x y z|)
(100 200)
  • If you have namespaces, that is a form of compound identifier. E.g. C++: bobs_utilities :: string_functions :: scramble. This is a name, and we can include arbitrary whitespace if we want because it is syntax, an not a simple token. Names with multiple components want to be abstract syntax; shoehorning namespace info into a single identifier is basically a "name mangling" hack for representing structure inside text where you are lacking the mechanism to represent the structure.
    – Kaz
    Commented Apr 24, 2012 at 18:25
  • Pretty common in JS, whose primary author was a Scheme guy. Commented Jun 14, 2013 at 23:58
  • 1
    @ErikReppen As far as I know, spaces are not valid as part of javascript identifiers...
    – Izkata
    Commented Jun 15, 2013 at 4:58
  • Not for vars no. For property names we can use any string in brackets. e.g. alert({'some Prop':'bob'}['some Prop']); but if those string property names fail the identifier/label test you can't use them with dot notation. Commented Jun 15, 2013 at 6:08
  • In Ruby you can: define_singleton_method "sjdlkfjsljk#$SDEF SDFSDF@# @#$!!~" do; puts 42; end; and then you can: send "sjdlkfjsljk#$SDEF SDFSDF@# @#$!!~" but it is not common. Commented Apr 4, 2014 at 8:15

22 Answers 22


FORTRAN compilers ignored spaces so:

   result = value * factor  
   r e s u l t = val ue * fac tor

were identical as far as the compiler was concerned.

Some SQL dialects allow embedded spaces in column names but they need to be surrounded by backquotes or some other delimiter before they can be used.

  • 7
    +1, this is new to me. I always wondered why I only got a B in Fortran but now I know :)
    – NoChance
    Commented Apr 24, 2012 at 5:44
  • 39
    Sun's FORTRAN manual used to include this sentence: "Consistently separating words by spaces became a general custom about the tenth century A.D., and lasted until about 1957, when FORTRAN abandoned the practice."
    – Blrfl
    Commented Jun 14, 2013 at 21:52

Visual Basic (and VBScript) also allow whitespace in identifiers if you surround the identifier with square brackets.

Dim [Hello World]
[Hello World] = 123

However, doing so is quite rare.


Does SQL count?

create table "Registered Members" (
    "Full Name" varchar(100),
    "Mailing Address" varchar(100),
  • 3
    It's certainly possible, but I wouldn't call it idiomatic. Commented Apr 24, 2012 at 7:05
  • 3
    If you need masking, it doesn't seem to be encouraged. Commented Apr 24, 2012 at 11:53

Inform 7 is a system for developing interactive fiction using natural language–like syntax, in which multi-word identifiers are commonplace:

Mr Jones wears a top hat. The crate contains a croquet mallet. 

The restriction, of course, is that an identifier can’t contain a keyword when this would be ambiguous.

In a similar vein, identifiers with underscores in Agda can be used mixfix, the simplest example of which is probably the if_then_else_ operator:

if_then_else_ : {A : Set} -> Bool -> A -> A -> A
if true  then x else y = x
if false then x else y = y

I don't know if you consider MediaWiki wikitext a language, but names with spaces are definitely idiomatic:

This example lacks text.
{{Expand section}}

Where "expand section" is the name of a template (http://en.wikipedia.org/wiki/Template:Expand_section)

I guess it meets the criteria - a language where identifiers routinely contain spaces. It's never (I think?) ambiguous because identifiers are always surrounded by lots of punctuation to separate them from raw wiki text.

  • 2
    While wikitext certainly is a formal language, I wouldn't call it a programming language (it doesn't even have loops).
    – svick
    Commented Apr 24, 2012 at 22:57
  • @svick: Neither do Haskell, Smalltalk, Scheme, Clojure, Erlang, Lambda Calculus, Turing Machines, Io, Ioke, Seph, … Commented Apr 25, 2012 at 11:45
  • @JörgWMittag, but they have recursion, which is just a different way of expressing loops. Wikitext doesn't even have that.
    – svick
    Commented Apr 25, 2012 at 12:08
  • @svick Depending on which extensions you installed, you get some control structures in mediawiki markup. In particular you get ifs and recursion. Syntax and performance are pretty bad though. Templates behave pretty much like functions, and their names count as identifiers in my book. Commented Apr 25, 2012 at 12:38
  • 1
    Interesting, from [[Wikipedia:Transclusion]]: "There is no real looping functionality built into the Mediawiki software as of this time...but there are some tricks for mimicking them. For instance, repeatedly calling a template that repeatedly calls a different template can mimic a double loop. Templates can also be coerced into calling themselves (normally prohibited by the Mediawiki software past a single instance, to prevent infinite loops), by the artful use of redirects (see m:Template:Loop1 (backlinks, edit)) See also m:Help:Recursive conversion of wikitext." Commented Apr 26, 2012 at 0:46

In Algol 68 you could have space in identifiers (I don't remember if they were significant or not). But keywords were marked by stropping. Using names with space in them was idiomatic (at least around me).

VHDL allows escaped identifiers with significant spaces in them: \foo bar\. This allows also to use keywords as identifier \and\, any character \n<42>\ and case sensitivity in identifiers (\Foo\ and \foo\ are different while Foo and foo are equivalent, and different from either \Foo\ and \foo\!). Verilog also has espaced identifiers with most of these characteristics (normal identifiers are case sensitive and escaping them unnecessarily doesn't make another identifier), but doesn't allow spaces in them. The need from escaped identifiers in VHDL and Verilog come from the fact they are often produced automatically from other sources (such as schematic) where identifiers customarily don't have the same restriction as in programming language; AFAIK, they aren't idiomatically used in other circumstances.

  • I seem to remember (looking back to the 1980s here!) that CORAL did something similar - you could (and did) have white space in variable names, but keywords then had quotes around them (like 'DEFINE' and, a personal favourite, 'COMMENT'. We used to use the macro processor to replace these with un-quoted versions).
    – AAT
    Commented Apr 24, 2012 at 21:12

Well Whitespace is all about... whitespace:

Most modern programming languages do not consider white space characters (spaces, tabs and newlines) syntax, ignoring them, as if they weren't there. We consider this to be a gross injustice to these perfectly friendly members of the character set. Should they be ignored, just because they are invisible? Whitespace is a language that seeks to redress the balance. Any non whitespace characters are ignored; only spaces, tabs and newlines are considered syntax.

Unfortunately Markdown doesn't support its syntax and I can't show you some code, but Wikipedia has a human friendly code sample.

  • @sepp2k Whitespace has labels.
    – yannis
    Commented Apr 24, 2012 at 5:33
  • Oh, you're right. Nevermind then.
    – sepp2k
    Commented Apr 24, 2012 at 5:36
  • "Most modern programming languages do not consider white space characters". Python does :)
    – jadkik94
    Commented Apr 27, 2012 at 16:18
  • @jadkik94 Python does use whitespace, but for indentation not as identifiers.
    – yannis
    Commented Apr 27, 2012 at 20:08
  • @YannisRizos Oh, yes. And it's also true that most languages don't use whitespace at all (identifiers or not)
    – jadkik94
    Commented Apr 27, 2012 at 21:01

Scala allows arbitrary identifiers using backticks. The usual use for this is to invoke Thread.`yield` because yield is a reserved word in Scala. This could be (ab)used to have spaces in names, although that would be far from idiomatic Scala code:

val `the answer` = 42
println(`the answer`)

Heck, you can even have tabs in identifiers:

scala> val `the\tanswer` = 42
the     answer: Int = 42

I suppose this could conceivably be idiomatic for the literate programming folk. Maybe.

  • Scala allows characters like + in method names. So for obj.a+=1, it would parse it as if a+= were a method. The inventor Martin Odersky in his textbook assumes that programmers usually include spaces, so that parser ambiguities are practically not too problematic. Commented Apr 25, 2012 at 11:20
  • 1
    @aitchnyu: Actually, in mixed identifiers, the alphanumeric part and the operator part need to be separated by an underscore. obj.a+=1 is equivalent to obj.a += 1 which is equivalent to obj.a.+=(1). You would need to have obj.a_+=1 if you want it to work the way you describe. (Actually, that will give a parse error, you need to either call obj.a_+=(1) or obj a_+= 1.) Commented Apr 25, 2012 at 11:56
  • That's no tab… it's a space station. And by space station, I mean a tab escape sequence. Commented Aug 15, 2014 at 14:52

You might consider this to be the case in Cucumber/Gherkin, where function names are effectively sentences with the arguments embedded inside them.

As an extension, I would expect this to be more common in tiny DSLs, where the language is supposed to be friendly to non developers. For example, many rules engines provide an abilty to define rules with an english-like description, where spaces can be used in identifiers.


F# allows white space in identifier names, but they must be surrounded with double backticks. See the answer to this question: https://stackoverflow.com/questions/6639688/using-keywords-as-identifiers-in-f.


FWIW, Tcl allows spaces (and just about every other character) in identifiers, though it's not common to take advantage of this feature. The main reason it's not used very often is just that you have to use proper quoting. For example, the following sets a variable named "my name" to "bob", then prints it

set "my name" "bob"
puts "hello, ${my name}"

OTOH, it's very useful when building variables dynamically since, when creating such variables, one doesn't have to worry about illegal characters


If you consider an automated testing DSL a language, the robot framework allows spaces in keyword names, and it's very idiomatic. In the following example "Say hello" is a keyword name, "Example test case" is a test case name, and "${first name}" is a variable:

*** Keywords ***
| Say hello | [Arguments] | ${first name}
| | log | Hello, ${first name}

*** Test Cases ***
| Example test case
| | Say hello | world

There are few I know of. I am working on one, and the lithe programming language. Inform does, but it's not exactly a general purpose programming language.


The 4D language allows white space in method names and variables. It is generally frowned upon within the community, but all built-in methods and variables use them when applicable (SET MENU ITEM PARAMETER, for example)


Powershell allows spaces in variable names:

PS C:\> ${the var} = 100

PS C:\> ${the var}

I saw mention of similar for VB but in JS this is used a lot actually. Any property of an object in JavaScript can be accessed and set in string form with square brackets or simply as strings in object literals. Property names that don't follow JS's variable naming rules are inaccessible via . notation but they are handy. For instance, you might want to map URLs to behavior or reference a group of people by name when you're certain they're all unique. It's often very convenient and easy to read:

var peoplesFavoriteThings = {
    "Bob Jones":"kittens",
    "Jane Doe":"chainsaws"

for(var name in peoplesFavoriteThings){
    console.log(name + ' likes ' + peoplesFavoriteThings[name] + '.\n');

This also makes it easy to restructure JSON for ease of use without losing the instant-object factor when dropped into JS.

  • Funny that this is the only mention of JavaScript. Yes, methods and properties can contain strings: foo['my method']() and foo['my property'] Commented Mar 3, 2017 at 5:50

Smalltalk features keyword methods such as a:b:c: which involve whitespace when invoked. E.g.: a: 100 b: 200 c: 300. This is a standard idiom in the language.


Power Query uses a lot of automatically generated code. I'd guess more than half of generated identifiers use white space:

    Source = Sql.Database(".", "Test"),
    dbo_pvt = Source{[Schema="dbo",Item="pvt"]}[Data],
    #"Filtered Rows" = Table.SelectRows(dbo_pvt, each [VendorID] <= 4),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Emp1", "Emp2"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"Emp3", "Emp4"}, {{"Count", each List.Sum([Emp5]), type number}})
    #"Grouped Rows"

As you can see, like in many languages there's extra syntax to disambiguate what the identifier is.

But in places where it's unambiguous, no extra syntax is needed:

    spaceRecord = [with space = 42, recursive record = @spaceRecord],
    drilldown = spaceRecord[recursive record][recursive record][recursive record][with space]
    drilldown   // 42

If you you count it as a real language, JMP scripting language ( http://www.jmp.com/support/downloads/pdf/jmp_scripting_guide.pdf ). It allows identifiers to have whitespace (to make them more "readable") and more or less encourages such.


The o42a programming language I am currently developing supports a multi-word names. The language has no keywords at all and the names are usually separated with some symbol. In the rare case the two names follow each other, the underscore is used to separate them.


Authorware, whose scripting language was based on non-object-oriented Pascal, allowed spaces in variable names, though over time people discovered the problems with using them and moved away from it http://books.google.com/books?id=bHC88YignAkC&pg=PA428&lpg=PA428 .


Edit: This answer was shown to be not correct, see the comments.

If I understand your question correctly, a compiler can't allow space(s) in identifier name because it could cause duplicate names (unless a delimiter is used). For example:

int my=0; bool my count=false; int count=0; if (my Count)...

the term 'my count' is confusing it could either refer to the variable called 'my count' or maybe the developer forgot to write a relation operator such as > between my and count.

COBOL allowed division names and section names to be separated by space but those are not identifiers and variables as in your question.

  • 5
    Well, it's not the compiler, it's the language definition. Most languages can't allow whitespace in identifiers because they would create ambiguity. Commented Apr 24, 2012 at 5:15
  • 3
    Your reasoning seems kind of iffy to me. In your example the only alternative to my Count being a variable name would be the programmer having made a typo. That's not ambiguity. Ambiguity would be if there was another valid way to parse the expression. By the same reasoning you could say that allowing a(b+c) is ambiguous because maybe the programmer forgot a > and really meant a > (b + c).
    – sepp2k
    Commented Apr 24, 2012 at 5:32
  • 1
    @EmmadKareem I don't know, but in the vast majority of languages a(b+c) is syntactically valid and calls the function a with the argument b+c.
    – sepp2k
    Commented Apr 24, 2012 at 5:43
  • 1
    But (in a language that allows spaces in variable names) there is also no ambiguity in if (my count). You're not saying there is a different, valid way to parse that statement (which would mean it's ambiguous). You're saying if you add the character <, you end up with a different, valid parse. And I'm saying if you add the character < to a(b+c) you also end up with a different, valid parse.
    – sepp2k
    Commented Apr 24, 2012 at 5:55
  • 1
    @SteveBennett Right. Any language that allowed spaces in variable names would either have to disallow them in type names or use a different syntax for type declarations (like say var name of the variable : type of the variable) - or not have type declarations at all.
    – sepp2k
    Commented Apr 24, 2012 at 5:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.