9 ms·
YAML had a worse example, once. For the ease of entering time units YAML 1.1 parsed any set of two digits, separated by colons, as a number in sexagesimal (bas
by azernik 6y ago
YAML had a worse example, once.
For the ease of entering time units YAML 1.1 parsed any set of two digits, separated by colons, as a number in sexagesimal (base 60). So 1:11:00 would parse to the integer 4260, as in 1 hour and 11 minutes equals 4260 seconds.
Now try plugging MAC addresses into that parser.
The most annoying part is that the MAC addresses would only be mis-parsed if there were no hex digits in the string. Like the bug in this post, it could only be reproduced with specific values.
Generally, if you're doing implicit typing, you need to keep the number of cases as low as possible, and preferably error out in case of ambiguity.
- m463 6y agoslightly related, on my microwave 99 > 100, even 61 > 100
- bonzini 6y agoWhy does your microwave compare numbers?
- mckirk 6y agoHow else would you prove it's turing complete and can run Doom?
- pdpi 6y agoNot the OP, but I have the same problem. For some reason that escapes me, pressing the “10 sec” button 7 times produces 00 70 instead of 01 10. If you then press the “1 min” button you get 01 70
- nerdponx 6y agoMost microwaves (in the USA) do this, at least in my experience. They treat the ":" like a sum of two sexagesimal numbers, rather than a sexagesimal digit separator.
- sokoloff 6y agoIt doesn’t compare them, it just counts down. If I enter 1-3-0-start, I get 90 seconds of cooking. If I enter 9-9-start, I get 99 seconds of cooking, so in that sense, 99 > 130. If I want about 90 seconds, I’ll use 88 as it’s faster to enter (fewer finger movements).
- JoeAltmaier 6y agoI've done the same thing for decades! Soul mates?
- sokoloff 6y agoYou might like this one as well. Load soap into the dishwasher after emptying rather than after loading. If the soap dispenser is closed, the dishes are dirty.
- LilBytes 6y agoBlasphemy! I do the inverse. You're wrong. /s insert code flame war here
- sneak 6y agoMy rule is that loading the dishwasher means that one loads all the available dishes, and runs it, even if it's only x% full. We use the (large) sink as an input buffer. If the dishwasher has dishes in it and it's not running, they're clean.
- rootusrootus 6y agoThis is exactly our algorithm as all. I can't really imagine flipping it the other way, since leaving dirty dishes in a dishwasher will just let them completely dry out, making it more likely they won't get fully clean when the cycle is eventually run.
- medstrom 6y ago
- roland35 6y agoI try to optimize my microwave button pushing too. I also have a +30 seconds button, so for 1:30 I can hit "1,3,0,Start" or "+30" three times and save a press!
- whytookay 6y agoOne that really surprised/confused me was that pyaml (and the yaml spec) attempts to interpret any 0-prefixed string into an octal number. There was a list of AWS Account IDs that parsed just fine until someone added one that started with a 0 and had no numbers greater than 7 in it, after which our parser started spitting out decidedly different values than we were expecting. Fixing it was easy, but figuring out what in the heck was going on took some digging.
- dragonwriter 6y ago> YAML had a worse example, once. It had it literally at the same time as it had the problem in the article (the article refers to YAML 2.O, a nonexistent spec, and to PyYAML, a real parser which supports only YAML 1.1.) Both the unquoted-YES/NO-as-boolean and sexagesimal literals were removed in YAML 1.2. (As was the 0-prefixed-number-as-octal mentioned in a sibling comment.)
- adwn 6y ago> For the ease of entering time units YAML 1.1 parsed any set of two digits, separated by colons, as a number in sexagesimal (base 60). This is a mind-boggling level of idiocy. Even leaving aside the MAC address problem, this conversion treats "11:15" (= 675) different from "11:15:00" (= 40500), even though those denote the same time, while treating "00:15:00" (15 minutes past midnight) and "15:00" (3 in the afternoon) the same.
- azernik 6y agoYou know you've fucked up when you have to remove features from the spec (which they did in YAML 1.2).
- imtringued 6y agoOn the other hand, you know that you did well, when a direct competitor would look exactly the same minus some undesired features.
- lainga 6y agoWe had a Grafana dashboard where one of the columns was a short Git hash. One day, a commit got the hash `89e2520`, which Grafana's frontend helpfully decided to display as "+infinity". Presumably it was parsing 89E+2520.
- rootusrootus 6y agoHa, that reminds me of some work I was doing just yesterday, implementing a custom dictionary for a postgres full text search index. Postgres has a number of mappings that you can specify, and it picks which one based on a guess of what the data represents. I got bit by a string token in this same format, because it got interpreted as an exponential number.
- BlueTemplar 6y agoSounds like the core issue is that an hexadecimal number was encoded as a string ?