4 ms·
Php supports kebab-case variables: ${"variable-name"}=123; Isnt it beautiful?
by orangepanda 4y ago
Php supports kebab-case variables:
${"variable-name"}=123;
Isnt it beautiful?
- oconnor663 4y agoHow many languages support kebab case with any Unicode dash that isn't the ASCII one? :)
- adastra22 4y agoProbably any language that supports Unicode identifiers.
- jfoutz 4y agoAt the moment, the only one I know for sure is Agda. I suspect java would work as well, not sure about golang unicode var naming.
- zimpenfish 4y agoplay.golang wouldn't let me use figure (‒, U+2012), endash (–, U+2013) or emdash (—, U+2014) in a variable name directly. But then the spec[1] says that only code points characterised as "Letter", an underscore, or characterised as "Number, decimal digit" are valid. [1] https://go.dev/ref/spec#Identifiers https://go.dev/ref/spec#Identifiers
- leipert 4y agoCoptic Small Letter Dialect-P Ni should work, looks like a hyphen. Go Playground: https://go.dev/play/p/kxgOcEWsznz https://go.dev/play/p/kxgOcEWsznz https://www.compart.com/en/unicode/U+2CBB https://www.compart.com/en/unicode/U+2CBB
- zimpenfish 4y agoOh, neat catch!
- Smaug123 4y agoF# allows arbitrary names within double-backtick identifiers. The following is a valid declaration, where I've used a hyphen, en-dash, and em-dash: let ``foo-bar–baz—quux`` = 3
- dunham 4y agoAgda does, but it also supports a plain ascii hyphen in identifiers. It allows operator characters inside identifiers and requires spaces around operators otherwise (as proposed in the article). So you can use x-y as an identifier: x-y : ℤ → ℤ → ℤ x-y x y = x - y The Agda community also heavily uses unicode characters. I've even seen a unicode colon used for a custom syntax because the ascii colon was unavailable.
- still_grokking 4y ago> The Agda community also heavily uses unicode characters. Wise move. Finally a language from the 21 century. Still sticking to ASCII is madness. Especially as most people on this planet don't use ASCII as their native char set.
- adrianmonk 4y agoPerl, too. (Probably not a coincidence.) You can also put a newline in a variable name if you really want. Or a 0 byte. Here's a demo. I've used the debugger because its "X" command can print the true name of the variable: $ perl -d -e 1 Loading DB routines from perl5db.pl version 1.60 Editor support available. Enter h or 'h h' for help, or 'man perldebug' for more help. main::(-e:1): 1 DB<1> ${"variable-name"} = 123; DB<2> ${"variable\nname"} = 456; DB<3> ${"variable\0name"} = 789; DB<4> X ~variable $variable^@name = 789 $variable^Jname = 456 $variable-name = 123
- contravariant 4y agoSo does python I suppose locals()["kebab-case"]=123
- Nzen 4y agoI agree that kebab variables aren't to my taste either, but I am partial to the notion of kebab-case keywords that I encountered in a JEP draft [0]. It suggests expanding the keyword vocabulary with a form that is otherwise invalid syntax, similar to how java treats module-info.java and package-info.java as valid files, but rejects any other hyphenated java class filename. [0] https://openjdk.org/jeps/8223002 https://openjdk.org/jeps/8223002
- valenterry 4y agoPretty ugly. Scala does it like this: var `variable-name` = 123 `variable-name` = 456 Looks much cleaner to me.