Same, I thought this is gotta be a problem for someone who uses notepad as their main editor.
...for which my default fix would be to delete and reenter it in hopes of fixing ehatever hiccup the syntax validator is having
That means that detection was added explicitly because this prank was done enough that it was worth it to add.
The reason is in fact not only because of this exact symbol, but because people tried to change programβs behavior in a malicious way by replacing legitimate code with same looking symbols.
Something similar happened to me a while back. I was copying some code from a Mac to a remote Linux host. For some reason the Mac was using a thing called an βen dashβ β
which is slightly longer than a regular hyphen -
and was really fucking frustrating to figure out.
I don't know why I'm here commenting about this, but I love type, so:
Hyphen (-): the short one, used for hyphenated words. fire-eaters. Close-up.
en-dash (β): slightly longer, traditionally the length of a lowercase"n" in the typeface. Used between for things like a timeframe. 10β11:30, AugustβOctober
em-dash (β): the longest of the three, and the length of a lowercase "m". Used as a punctuation mark to denote a side comment or to abruptly cut off a sentence. "It's a great punctuation markβin fact I overuse itβbut it's still useful." "Hey where are you going with that giantβ"
I didn't bother to double check the definitions, so there might be more specific rules, but these are my rules of thumb.
Dictionary source for possible particulars: https://www.merriam-webster.com/grammar/em-dash-en-dash-how-to-use
Some mac apps have some quirks, the default note app was probably not meant for pasting code in, but when you do it changes the quotes and makes them all fancy. Drives me up the wall and there's nobody to blame but me.
Letβs dig him up and put him on trial. If itβs good enough for the pope, itβs good enough for him.
I was looking for this. Some text from webpages end up pasting that way too, even on non-mac systems, and it is utterly infuriating. Nothing I hate more than having to paste something into notepad++ so I can fix all the stupid quotes from some online tutorial that is giving you things to paste into a command prompt.
I knew a guy who used the Unicode character for a space in his password. He figured if anyone ever saw his password they'd think it was a space and still not be able to use it. It's silly, but it was a fun thing to learn about him.
Most of the time. Sometimes it can lead to code that is ambiguous and ASI picks the wrong way to interpret it.
Technically I don't think any Greek layout uses a different Unicode codepoint for the question mark. In fact, the ordinary semicolon symbol is used, so what the meme describes would probably not happen IRL.
Does all this make it any less funnier? No. It's still brilliant.
In Unicode, it is separately encoded as U+037E ΝΎ GREEK QUESTION MARK, but the similarity is so great that the code point is normalised to U+003B ; SEMICOLON, making the marks identical in practice.
Source: https://en.wikipedia.org/wiki/Question_mark
I'm still curious whether it would be accepted by the code interpreters / compilers of various languages. I'm not bold enough to assume they all normalise properly.
Programmers who care about best practices. Here are a couple of scenarios where not using a semicolon will bite you in the ass.
~95% of the JS code you see on the Web has semicolons. Apparently, a lot of programmers think it's worth that extra keystroke to avoid these types of bugs. I agree with them. The difficulty with programming isn't "Arrgh, there are too many keystrokes, my hands are tired!" It's "Arrgh, HTF did this bug get in here?!?"
They made it a named function, but this is literally how you format anonymous functions in js, a key feature that usually gets called with stuff like an onclick
or onload
call in the html domain.
In that sentence, we use "programmer" singular, because "every" is singular, though referring to many
All real programmers
Every real programmer
Each real programmer
No real programmer
It's pretty arbitrary
I use prettier which by default adds semicolons. Coming from predominately doing backend stuff (mostly in Java) I donβt really mind, especially when the formatter adds them for me