views:

72

answers:

5

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 your 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.

A: 

No, not really. Keywords in a language tend to be short and general - two things that rarely make for good variable names.

Adam Wright
+1  A: 

type and object. I don't like when my programming languages steal those :(

Kai
Why? What would the `type` or `object` variables be for? Those are horrendously undescriptive names that probably _should_ be builtins.
Chris Lutz
struct Item { ItemType Type; Item(ItemType type) {Type = type;}}
zildjohn01
@Chris I use them as localized variables that don't have a scope of more than a few lines. I hope you aren't using long variable names for everything.
Kai
This is the kind of answer I'm looking for.
zildjohn01
A: 

In those cases, I think of "in" and "out" as adjectives, and usually make something more descriptive, such as "inStream" and "outStream".

Monte
A: 

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.

Justin Kramer
+1  A: 

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.

ephemient