4 ms·
Many languages have had this feature for a long time. Ruby, ~~Rust,~~ Kotlin, etc... It hasn't been an issue at all. I like that most languages seem to have re
by nulld3v 1y ago
Many languages have had this feature for a long time. Ruby, ~~Rust,~~ Kotlin, etc... It hasn't been an issue at all.
I like that most languages seem to have reached consensus on backticks or other similarily awkward characters for this feature. Typing these identifiers is like hitting a speed bump, which seems to be enough to make devs avoid them except for very specific use-cases.
- 0rzech 1y agoRust does not have this feature. Function names can't have spaces, for example. Underscores are used instead. Maybe there are some macros for arbitrary ASCII strings - I don't know - but it's not a language feature.
- nulld3v 1y agoWow, you are correct! A Rust "raw identifiers" can be a reserved keyword. But other than that, all other normal identifier naming rules still apply... And apparently I never figured this out even after 3 years of Rust lol, thanks!
- nulld3v 1y agoWhoops, I had an edit that apparantly did not submit. My comment is very wrong now, the only language in that list that supports "raw identifiers" in the same sense as Swift is Kotlin. Although I still stress that it has never been an issue in Kotlin.
- jibal 1y agoZig uses @"arbitrary name" It's an important feature for FFI, as well as passing operator functions around. (It seems bizarre to me that you can't do `+` in Swift, but I don't know Swift so maybe there's another way to name such functions.) Also, the Zig library now uses @"..." for variables with the same name as keywords, rather than using ad hoc naming conventions in those cases.
- raydev 1y ago> languages have had this feature for a long time. Ruby Yes, that is precisely why I don't like Ruby, it's actually impossible for tools to reason about many things that would make finding bugs before shipping feasible. Big companies like Shopify have to impose a lot of restrictions on it to make it work at scale, which is silly. Just use a different language! Now Swift may not be in this situation because it's added yet more characters to wrap this nonsense so it is possible to reason about, but it's still just unnecessary, and I will be adding a lint rule against it at work. I don't expect a lot of pushback if any.
- 90s_dev 1y agoNow that you mention it, JavaScript has this inherent problem too: > foo["hello world!"]() I'm halfway glad I've never needed to write C++ professionally, but it seems to me like all my TypeScript would probably transliterate to very clean C++31.
- wiseowise 1y agoThe issue is that it’s not a problem in the first place.