log☇︎
218700+ entries in 0.134s
asciilifeform: first time i see the d00d mention shitlangs. but the overflow thing affects shitlangs just as much as sanelangs.
mircea_popescu: rust is pretty much the anti-language ; as someone explained "the red hat decided to present it as the thing and hope for all the idiots to contribute freely to make it the thing for this reason".
mircea_popescu: i couldn't care less what rust dork has to say on any topic.
asciilifeform: looks like ARM might be the culprit.
asciilifeform: but when you open the hood you discover that there are all kinds of idiocies that 'people live with' because 'what else can you do'
asciilifeform: the one thing it is, is ~familiar~.
mircea_popescu: maybe. i'd have to see the scheme.
mircea_popescu: you understand, all this, cpu freq, bus aperture, words etc exist because simple and cheap solution to the clock problem
asciilifeform: rather than arbitrary constant N-wide bus.
asciilifeform: mircea_popescu: the correct parallelization scheme is N single-bit ALUs working in concert.
mircea_popescu: if you can't do that, they have a point.
mircea_popescu: the only way to make them wrong would be to make your cpu work without clock and bus cycles.
asciilifeform: because folx who want to break logical structure to get 'percept cycle massage' oughta be beaten with sticks.
mircea_popescu: and someone somewhere is going to want to talk of it directly rather than haskelly, and so they will use the concept of... machine words.
asciilifeform: not single, but < the actual logical width, almost certainly.
mircea_popescu: are you also going to have serial bus ?
asciilifeform: where, yes, you can add 0xFFF......FFF and 1 in constant time, but the cost is that now some numbers are 'special'
asciilifeform: this goes back to the 'dma' thread. large machine registers are an ad-hoc and clumsy form of parallelism.
asciilifeform: but forget, for this thread, trinary adders, you can just as readily have same arithmetron with binary regs
asciilifeform: mircea_popescu: no pointer contemplated, just knuth's trinary arithmetic scheme, familiar from kindergarten.
asciilifeform: (you can elegantly implement with 2 ordinary binary registers, and use 4th state to store propagating-eggogs, aka NaNs)
mircea_popescu: what's a trit
asciilifeform: throw out the dumb speshulcases.
asciilifeform: mircea_popescu: if i make a chip, all regs are 1 trit wide.
mircea_popescu: myeah. but if i ever make a chip myself, there's not going to be fucking carry speshul bit.
asciilifeform: actually that second thing only half-happened, you only get a second machineword out of mul on any known chip
mircea_popescu: ie, origin ally the philosophical minds prevailed, and a special wire was added (the carry). but then ww2 ended and saner minds prevailed ; thus double sized results on the same bus and the world went back to the peace and prosperity of everything in band.
mircea_popescu: incidentally this whole thing with mul add etc is a fine working example for the in band / out of band discussion.
mircea_popescu: well yes, but as long as the job is "check for machine word fixed type", the carry will save you.
asciilifeform goes to the b00kz room to fetch 'ada 2012 rationale', to learn whether he is complete moron, or wat.
asciilifeform: mircea_popescu: there's another op defined for ring of integers, that is SHL
mircea_popescu: asciilifeform there's also fleshlights. i don't program on those.
asciilifeform: but iirc the reason why we do not have this behaviour by default is that there are boxes that don't give you the upper bits of an overflowing mul. or set the carry.
asciilifeform: mircea_popescu has mega-point --- you CAN make range-checked (at least for upper bound of range not exceeding the native fixint size by more than factor of 2) behaviour on x86
mircea_popescu: yes but here is used conceptually, as the "top half of the result", be it 1 bit or 1 machine word.
asciilifeform: mircea_popescu: 'carry' on most chips refers to a physically separate 1bit register. but sure
mircea_popescu: ok. what's this to do with ada i dunno, but anyway, there it is.
asciilifeform: the top of the result, rather. but yes. on x64 you could!!! have the Right Thing bignumtron.
mircea_popescu: top half being, obviously, THE FUCKING CARRY.
mircea_popescu: ok, so the carry being set, you blew it.
asciilifeform: nope. x86 (and correspondingly x64) mul gives you ~two~ buswidth-sized results, the bottom and top half of the result.
mircea_popescu: so it just returns the same as 0x000000000 + 0x000000000 ?
asciilifeform: that doesn't set the carry on x86...
mircea_popescu: so you do 0x100000000 * 0x100000000 and get the carry set and you blew it.
asciilifeform: now take mul .
asciilifeform: aha, for add / sub it is trivial
mircea_popescu: so if the carry flag is set you blew it.
asciilifeform: for addition, this is actually simple on most chips, there is a 'carry' flag
asciilifeform: to make bounds checking happen, on whatever particular cpu, gotta emit not only the add instruction but a few others also
mircea_popescu: i didn't realise the above high level math was stand-in for asm.
asciilifeform: the cpu NEVER DOES THIS omfg
mircea_popescu: you get memory access violation for trying to write at offset-1 in memory.
asciilifeform: in this case aha.
asciilifeform: in this example. and it gotta signal the overflow.
asciilifeform: y is of the constrained type contemplated.
mircea_popescu: it's not clear how you represent the y ; but whatever, half questions ftw.
mircea_popescu: the test MAY NOT BE > 0 (or -1 ?) and < 0x10000000000000000. if the compiler does that the compiler is very, very stupid.
mircea_popescu: that is the test. all of it is representable.
mircea_popescu: the range is 0 to 0xfffffffffffffff. the test is >= 0 and <= 0xfffffffffffffff.
mircea_popescu: the range is 0 to 0xfffffffffffffff. the test is >=
asciilifeform: right! but in order for the machine to KNOW that it cannot, the ranges have to be representable.
mircea_popescu: if the compile rules do "add one and <" the compiler is wrong ; it should not add one ad <=.
asciilifeform: the thing will not, like idiot cpp does, emit some 'but he REALLY WANTED THIS...'
asciilifeform: mircea_popescu: if you write down a statement that is logically impossible to transform into compiled code, per the ground rules, it is a compiletime eggog.
mircea_popescu: indeed 0x10000000000000000 is not what the program stated ; and indeed the problem is that (if) the compiler adds one to what the program statyed ; it shouldn't do that.
asciilifeform: 'you asked me to make 2 equal 4, go fuck yerself'
mircea_popescu: i thought bounds checking was introduced by the compiler not by the program.
asciilifeform: comparing to 0xffffffffffffffff is not what the program stated, in the example. and since the compiler is sane, it does not substitute a semantically variant statement to what programmer wrote, under any circumstances.
mircea_popescu: are you saying the problem ISN'T after all that "the compiler can't find 0x10000000000000000" as you originalyl stated, but that it can't be arsed to compare to 0xffffffffffffffff instead ?
asciilifeform: guaranteed. try it yourself.
mircea_popescu: which fundamental reasons entirely consist of "alf the bee dog with his magical black and white spots vision managed to read the expliciting of the < vs <= difference SIX TIMES and ignore it every time"
asciilifeform: you're stuck with 1 bit smaller quantities than the full bus width.
asciilifeform: that you can't do this for full machine-width integer. for fundamental reason, turns out.
mircea_popescu: so then what are you on about ?
asciilifeform: it isn't a compile-time static thing
asciilifeform: in same language, program throws ~runtime~ exception if you EVER try to assign the 11, no matter how it was arrived at
asciilifeform: mircea_popescu: 'programmer said 11 -- we beat him with a stick' is trivial. of concern is arithmetic overflow/underflow.
mircea_popescu: because if the programmer said the number 10, the compiler is NOT at liberty to invent magic number 11.
asciilifeform: let's revisit the particular of how you can even end up with an X that no longer sits down in 64 bits, using an op on an A and a B which ~do~
mircea_popescu: and therefore question for type Foo is range 0 .. 10 must always be, is foo <= 10 ; not is foo < 11
asciilifeform: how do you compare to a bound that needs moar bits to represent than the number you are comparing ?
mircea_popescu: i'm not interested in picking anything. bound checking is to be done by comparing TO THE BOUND not to some other random value picked by the compiler.
mircea_popescu: DO NOT implement bounds checking as "smaller than bound +1". DO implement bounds checking as "smaller or equal than bound".
mircea_popescu: so then why do you ?
mircea_popescu: i think i'm done with this convo.
mircea_popescu: why the fucksticks did you pick the first.
mircea_popescu: dude, stop picking the irrelevant. pick the meat of what i say.
asciilifeform: problem is that you cannot represent MAXINT+1 as a constant !!
asciilifeform: by comparison to a constant.
mircea_popescu: < as opposed to <= ?
asciilifeform: it implements it in the only way that is guaranteed to be invariant, and run in constant spacetime, on all iron.
mircea_popescu: so basically, what my mind has strained from this convo, is that ada implements bound checking badly ; in that it (wrongly) assumes that it can always source a larget item to compare to, like < size+1.
asciilifeform: and other beautiful things.
asciilifeform: y'know, the one where the boeing 787 engine melted.
asciilifeform: it is NOT the same as 'modular arithmetic', modular arithmetic is the behaviour of the native iron that we are going AWAY from here.
asciilifeform: same as if you try to add 1 to a foo where type Foo is range 0 .. 10; and Q: Foo; and Q was already 10.
mircea_popescu: the thing is called modular exponentiation you know :D
mircea_popescu: cut the value to size
asciilifeform: mircea_popescu: what the fuck will a mod do ??
asciilifeform: mircea_popescu: in all fairness this was only a surprise to asciilifeform because he is a n00b; the b00k warns explicitly, in black on white letters.