views:

437

answers:

7

I've just had a "discussion" with a developer about naming classes in C#. My final throw away line was, "Let's not put any emoticons in our class names."

I can't think of a way you could put emoticons in C# class names, but I haven't thought too hard about it. Is this possible?

Does any programming language allow it? What would be the best/worst language to be able to perform this in?

Update: The Scheme answer bests answers my question. It was a quick idea after a quick discussion so I'm going to accept after a short amount of time and then move on with my life. Thanks for the responses.

+6  A: 

For example in Scheme you have the flexibility to include symbols like :, -, / ... in the names,

(define (:-D x)
  (+ x 1))
...

(:-D 9)
output: 10
Nick D
+1: Best answer to the question so far
Chris Gill
+2  A: 

In C++, if you name a class/struct _ (a poor decision, but here we go), you can derive from it like this:

struct emoticon_to_the_right_of_this :_{
};

Thinking about this, a class o might be just as good:

struct another_emoticon_to_the_right_of_this :o{
};

Hm. I seem to only come up with sad ones. Is that Freud guy around here today? I do have a question to ask him...

sbi
+1: Best emotional emoticons so far
Chris Gill
+8  A: 

Many Japanese-style emoticons - O_o, v_v and the like - are perfectly legal substrings of identifier names in most languages.

moonshadow
+1: Best internationalisation so far
Chris Gill
+6  A: 

C# supports any Unicode letter for identifiers, so if you find some suitable for emoticons in the Unicode tables, you can use them. The CLR itself allows far more characters in identifier names, like the typical backtick used in compiler-generated names, so you could get really crazy by defining really strange names in MSIL, and then loading the classes with reflection in C# because it does not support those characters...

The method name oO comes to mind. It's an emoticon in itself (small and large eye), but when called on a reference, it expands to a thought bubble: .oO(Hello).

OregonGhost
+1: Best C# example. Would have been accepted if Unicode values for emoticons included - had a quick look myself but couldn't find them
Chris Gill
didn't think of specific UniCode values. But I guess you'll find some e.g. in the CJK tables. The UniCode emoticons on Wikipedia, unfortunately, mostly include parentheses, so you'll need to be even more creative to get them (like a specific method with a matching parameter (; )
OregonGhost
i like the bubble thought
knittl
I just found these: ٩๏̯͡๏)۶ and ツ . View in a large font. I don't know though if you can use them as identifiers in C# or CLR code ;)
OregonGhost
+4  A: 

Slightly off-topic: I was processing filenames the other day and realised that all sorts of faces had appeared in my code:

string number(fn.begin()+fn.rfind('_')+1,fn.begin()+fn.rfind('.'));

And of course there are the right-to-left emoticons you almost always get at the end of lines of C++ code:

mesh->Delete();

Why does C++ look so sad?

tim_hutton
+1 for why C++ looks so sad.
OregonGhost
Ah, so it's not me, but C++! (_What's that Freud guy tugging at my sleeve?_)
sbi
+2  A: 

Perl uses :: as a package name separator, which means that an IM client might decide to insert a smiley when I talk about XML::Parser (contains ":P") or Data::Dumper (contains ":D"). Punctuation other than :: isn't recommended in package names, so most "extended" smileys are out of the picture, but if I wanted to be very silly I could reference a variable named ${ ':-)' } -- but it would always have to be referenced using the ${'...'} syntax since it's not a recognizable identifier name :)

hobbs
A: 

I believe I've seen languages that use => to access object attributes (something like person=>father)

It's not actually part of the name, but it could be an emoticon.

Wallacoloo