Have there been any cases where you wanted to use a word as a variable/function name, but couldn't because it was a reserved word in y开发者_运维百科our language?
The ones that crop up over and over again for me are in
and out
in C#... Those would be great names for streams, but I'm always forced to use inn
and outt
instead.
EDIT: I'm not asking about help with this problem -- I'm trying to learn from mistakes that past language designers have made. Your answers will influence a language I'm designing.
type
and object
. I don't like when my programming languages steal those :(
Some languages let you use any words you want anywhere. Clojure, for example:
(let [let "what?"] let)
=> "what?"
This could either be helpful or horrible depending on the context.
I like to use new
and delete
as function pointer fields in OO-ish C code a lot, which makes porting to C++ "fun"... ugh.
This isn't really a problem for C#, though:
int @in;
There, now you have a variable named in
.
No, not really. Keywords in a language tend to be short and general - two things that rarely make for good variable names.
In those cases, I think of "in" and "out" as adjectives, and usually make something more descriptive, such as "inStream" and "outStream".
精彩评论