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).
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 :)
发布评论
评论(9)
许多日式表情符号 - O_o、v_v 等 - 在大多数语言中都是完全合法的标识符名称子字符串。
Many Japanese-style emoticons - O_o, v_v and the like - are perfectly legal substrings of identifier names in most languages.
例如,在方案中,您可以灵活地在名称中包含
:
、-
、/
... 等符号,For example in Scheme you have the flexibility to include symbols like
:
,-
,/
... in the names,C# 支持任何 Unicode 字母作为标识符,因此如果您在 Unicode 表中找到一些适合表情符号的符号,则可以使用它们。 CLR 本身允许在标识符名称中包含更多字符,例如编译器生成的名称中使用的典型反引号,因此在 MSIL 中定义非常奇怪的名称,然后在 C# 中使用反射加载类,可能会变得非常疯狂,因为它不支持这些字符...
我想到了方法名称
oO
。它本身就是一个表情符号(小眼睛和大眼睛),但是当在引用上调用时,它会扩展为一个思想气泡:.oO(Hello)
。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)
.稍微偏离主题:前几天我正在处理文件名,并意识到我的代码中出现了各种各样的面孔:
当然,还有从右到左的表情符号,您几乎总是在 C++ 代码行的末尾看到:
为什么C++看起来如此悲伤?
Slightly off-topic: I was processing filenames the other day and realised that all sorts of faces had appeared in my code:
And of course there are the right-to-left emoticons you almost always get at the end of lines of C++ code:
Why does C++ look so sad?
在 C++ 中,如果您命名一个类/结构
_
(这是一个糟糕的决定,但我们开始吧),您可以像这样从中派生:考虑一下,一个类
o
> 可能同样好:嗯。我似乎只想到悲伤的。 那个弗洛伊德家伙今天在这儿吗?我确实有个问题要问他......
In C++, if you name a class/struct
_
(a poor decision, but here we go), you can derive from it like this:Thinking about this, a class
o
might be just as good: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...
Perl 使用
::
作为包名称分隔符,这意味着当我谈论XML::Parser
(包含“:P”)时,IM 客户端可能会决定插入笑脸) 或Data::Dumper
(包含“:D”)。不建议在包名称中使用::
以外的标点符号,因此大多数“扩展”笑脸都不在图片中,但如果我想变得非常愚蠢,我可以引用名为$ 的变量{ ':-)' }
-- 但始终必须使用${'...'}
语法引用它,因为它不是可识别的标识符名称:)Perl uses
::
as a package name separator, which means that an IM client might decide to insert a smiley when I talk aboutXML::Parser
(contains ":P") orData::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 :)2014 年的此时此刻,苹果昨天刚刚发布了 Swift。我为此做了一个简短的例子。它编译并运行得很好。 :D
At this moment in 2014, Apple have just released Swift yesterday. And I made a short example for this. It compiles and runs perfectly fine. :D
我相信我见过使用
=>
访问对象属性的语言(例如person=>father
)它实际上不是名称的一部分,但它可以是一个表情符号。
I believe I've seen languages that use
=>
to access object attributes (something likeperson=>father
)It's not actually part of the name, but it could be an emoticon.
严格来说不是类名,但 PHP 中时不时会出现一些类名,例如连接时单引号中的下划线:
正如其他人指出的那样,您甚至不需要其中一些特殊符号:
更复杂的事情:
Not strictly class names, but there are a few that pop up in PHP from time to time, like an underscore in single quote when concatenating:
And as someone else pointed out, you don't even really need special symbols for some of them:
Something more convoluted: