[fpc-other] [fpc-pascal] WebAssembly Target
Mattias Gaertner
nc-gaertnma at netcologne.de
Thu Mar 16 15:54:49 CET 2017
On Thu, 16 Mar 2017 15:29:05 +0100 (CET)
"Karoly Balogh (Charlie/SGR)" <charlie at scenergy.dfmk.hu> wrote:
>[...]
> > JS uses Double, which can express integers correctly from
> > -$10000000000000 to $fffffffffffff.
> > That should be enough for most browser programs, don't you think?
>
> No, to be honest, I don't think so. I already tracked down bugs in native
> client side software caused by this, because of stupid NodeJS backends.
May I ask, what you used to translate your int64 code to NodeJS?
> Because someone thought it will be "good enough". It wasn't. Not to
> mention the cases I got "NaN" string as value in an integer field, but
> that's just JS in general for fun.
I agree, that the NaN, Infinity and div by zero specials of JS are for a
Pascal programmer hard to befriend.
> Although NodeJS wasn't running in the browser, admittedly. But I think the
> more complex apps you bring to the web, on top of JS, the more such issues
> will appear,
True.
> and the harder it will be to track it down.
Why?
> Bottom line: It's not good enough if you want to guarantee the same
> results as on other platforms, for all integer arithmetics with all
> standard types, including 64bit ones. Which is a must for any self
> respecting multiplatform compiler, IMO. (There are ways to do it
> nevertheless even w/o WebAssembly, but with a clear performance hit.)
You can calculate wrong with int64 as well. That's why FPC has the nice
range checking feature. Same can be done for other integer types,
including the JS int53bit.
Mattias
More information about the fpc-other
mailing list