

Valid JavaScript variable names - mathias
http://mathiasbynens.be/notes/javascript-identifiers

======
bwarp
Whilst this is a good novelty, please please please don't do this - ever!

As my father said "just because you can put your penis in a goat, doesn't mean
you should".

~~~
4ad
I agree that non ASCII identifiers are to be avoided, but they may be some
exceptions, I have written code like this (in Go):

    
    
        type Polar struct {
            R, θ float
        }

~~~
Zarathust
First thing I think with that is : How the fuck can I make that symbol?

I'll load up google, then find unicode charts and locate this. So writing your
variable name will take about 15 to 30 minutes. Thanks a lot

~~~
TazeTSchnitzel
On Linux (and there's some similar utility for windows), there's a key
sequence to enter arbitrary Unicode code points.

~~~
pnathan
It's not per se entering the silly thing, it's figuring out which code it is.

------
rhplus
_An Identifier is an IdentifierName that is not a ReservedWord._

In .NET CLR languages, you can use Unicode for identifiers like in JS, but an
interesting side-effect of the 'common' aspect of the CLR is that you can use
reserved keywords too. This is because reserved words in one language are not
necessarily reserved words in another language.

Someone could write the following valid definition in VB.NET:

    
    
       Public Property ushort() AS Integer
    

And because it's a reserved keyword in C# you'd have to reference it using the
'@' escape:

    
    
       foo.@ushort = 123;
    

(There are probably far more confusing examples than this)

------
meow
For any one curious, 'ಠ' is pronounced as 'Ta' (Kannada language) :)

~~~
malandrew
Without copying and pasting, how do I type this letter on OS X?

~~~
mathias
I’ve created a custom OS X keyboard layout that allows me to just press `⌥` +
`O` to get `ಠ_ಠ`. Here it is:
[https://github.com/mathiasbynens/custom.keylayout/tree/maste...](https://github.com/mathiasbynens/custom.keylayout/tree/master/qwerty)

~~~
astrodust
Better not have any friends named Bjಠ_ಠrn.

------
kragen
The most legitimate use for this is for top-level namespaces, which need to be
short or they'll junk up your code like crazy. jQuery already took $, and
Underscore took _. Maybe 木, ϗ, _⃗, 个, î, 人, Ǝ (not ∃, that's illegal!), ℵ, 二,
ℜ, 龍, ℕ, 八, Δ, 大, ʃ, ː, 卐, or as mentioned below, λ? ˀ is probably too
obnoxious though.

For no particularly good reason, ☺ and ☠ are illegal. I think the Plan9
strategy of considering non-ASCII characters as identifier characters by
default is probably a better one than changing the language grammar every time
the Unicode standard revs.

(As mentioned in another comment, <http://canonical.org/~kragen/setting-up-
keyboard.html> <https://github.com/kragen/xcompose>. The Chinese I copied and
pasted from <http://www.mdbg.net/chindict/chindict.php?page=radicals> though.)

------
adavies42
> Browsers support identifiers that unescape to a reserved word, so long as at
> least one character is escaped using a Unicode escape sequence.

i smell new xss exploits....

------
jacobr
So who creates the λ functional JavaScript library?

~~~
ajuc
I'll start:

    
    
        function λ(code) {
          return eval(
        	"function () {"+
        	"   var $=arguments;" +
        	"   return " + code + ";"
        	"}"
          );
        }
    
        var sum = map([1,2,3,4], λ("$[0] + $[1]"));
        
    
    

I'm not really serious, but I'd like eval-less version of this, very, very
much.

    
    
        function(x,y) { return x*y; }
    

is so verbose.

------
enko
It's a valid ruby method name!

    
    
      def ಠ_ಠ
        puts 'i like turtles'
      end

~~~
d0ugal
It's valid in Python 3 too.

------
Zarathust
The tutorial about "How to write unmaintanable code" would love this. They
already have some hints about putting accents on "int i" and other subtileties
like that

<http://thc.org/root/phun/unmaintain.html>

------
rogerbinns
For those who like SQLite, it allows you to create tables and columns with
zero length names (you have to quote) and it does indeed work correctly when
you use them. This is valid:

CREATE TABLE ""("" "");

A zero length table name with one column with a zero length name having a type
of a zero length name.

------
rll
Works fine in PHP as well:

    
    
      php > $ಠ_ಠ = 1;
      php > echo $ಠ_ಠ;
      1
    
      php > $π = pi();
      php > echo $π;
      3.1415926535897931159979634685442
    
      php > function ಠ_ಠ() { echo 1; }
      php > ಠ_ಠ();
      1

------
noblethrasher
Works in C# as well...

------
moe
Yup, it does indeed work. <http://jsfiddle.net/bJAed/>

------
r4vik
why shouldn't it be?

------
bobowzki
Because it's awesome!

