This may seem like a dumb question, but still I don't know the answer.
Why do programming languages not allow spaces in the names ( for instance method names )?
I understand it is to facilitate ( allow ) the parsing, and at some point it would be impossible to parse anything if spaces were allowed.
Nowadays we are so use to it that the norm is not to see spaces.
For instance:
object.saveData( data );
object.save_data( data )
object.SaveData( data );
[object saveData:data];
etc.
Could be written as:
object.save data( data ) // looks ugly, but that's the "nature" way.
If it is only for parsing, I guess the identifier could be between .
and (
of course, procedural languages wouldn't be able to use it because there is no '.' but OO do..
I wonder if parsing is the only reason, and if it is, how important it is ( I assume that it will be and it will be impossible to do it otherwise, unless all the programming language designers just... forget the option )
EDIT
I'm ok with identifiers in general ( as the fortran example ) is bad idea. Narrowing to OO languages and specifically to methods, I don't see ( I don't mean there is not ) a reason why it should be that way. After all the .
and the first (
may be used.
And forget the saveData
method , consider this one:
key.ToString().StartsWith("TextBox")
as:
key.to string().starts with("textbox");
I understand it is to facilitate ( allow ) the parsing, and at some point it would be impossible to parse anything if spaces were allowed. Nowadays we are so use to it that the norm is not to see spaces.
Identifiers contain characters from any of: alpha, digit, underscore, and dollar sign. You can't use spaces or tabs or symbols like #, @, !, and so forth in an identifier.
No other characters are permitted in the variable name. Specifically, spaces are not permitted in the variable names, as the variable name must be a single word.
The identifiers in C++ can have identifiers with any length of characters. These characters can be alphanumeric i.e can contain letters, digits and underscores and whitespaces and special characters such as @,#,! etc are not allowed.
Be cause i twoul d makepa rsing suc hcode reallydif ficult.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With