What emoji can you put in class names in your language?

I just discussed with a developer about naming classes in C #. My last catchy line was "Don't put emoticons in our class names."

I can't think of how you could place emoticons in C # class names, but I haven't thought too much about it. Is it possible?

Does any programming language allow? What would be the best / worst language to accomplish this?

Update: The schema answer answers my question. It was a quick idea after a quick discussion, so I'm going to accept in a short time and then get on with my life. Thanks for answers.

+2


source to share


9 replies


For example, in the diagram you can include characters such as :

, -

, /

... names,



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

(:-D 9)
output: 10

      

+7


source


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



+10


source


C # supports any Unicode letter for identifiers, so if you find suitable emoji in Unicode tables, you can use them. The CLR itself allows a lot more characters in identifier names, such as the typical backtracking used in compiler generated names, so you might get really crazy setting really weird names in MSIL and then loading the classes with reflection in C # because it doesn't support these characters ...

Let's recall the name of the method oO

. It is very smiley (small and big eyes), but when you call it expands links to thought bubble: .oO(Hello)

.

+6


source


Slightly off-topic: I was handling filenames the other day and realized all sorts of faces appeared in my code:

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

      

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

mesh->Delete();

      

Why does C ++ look so sad?

+4


source


In C ++, if you named class / struct _

(bad decision, but here we go), you can get this out of it:

struct emoticon_to_the_right_of_this :_{
};

      

Thinking about it, the class o

might be just as good:

struct another_emoticon_to_the_right_of_this :o{
};

      

Hm. I think I'm just making up sad ones. Is this Freud guy here today? I have a question to ask him ...

+3


source


Perl uses ::

package names as a separator, which means the IM client might decide to insert a smiley when I say XML::Parser

(contains ": P") or Data::Dumper

(contains ": D"). Punctuation other than ::

is not recommended in package names, so most of the "extended" smileys are not visible, but if I wanted to be really stupid I could refer to a named variable ${ ':-)' }

- but it would always have to be referenced using the syntax ${'...'}

, since it is not a recognizable identifier name :)

+2


source


Currently in 2014, Apple just released Swift yesterday. And I made a short example for this. It compiles and works fine.: D

Swift

+2


source


I believe I have seen languages ​​that use =>

to access the attributes of an object (something like person=>father

)

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

0


source


Not strictly class names, but there are a few that appear in PHP from time to time, such as the single-quoted underscore when concatenating:

$foo = $bar.'_'.$baz;

      

And as someone else pointed out, you don't even need special characters for some of them:

class o_0 {}
class v_v {}
class T_T {}

      

Something more confusing:

function d() { echo 'Thumbs up!!'; }

d('_');

      

0


source







All Articles