lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Apr 30, 2013 at 10:01:24AM -0300, Roberto Ierusalimschy wrote:
> > It can't be more portable than the language it's implemented in.
> 
> Of course, that depends on your meaning of portability. C has way too
> many non-portable features, so programs written in C usually are
> non-portable. You can write very portable programs in C, but you must be
> *very* careful. If we follow the standard, a lot of things we take
> for granted in C are undefined and should not be used in portable programs
> (e.g., any use of pointer subtraction and ptrdiff_t).

Technically if you're not following the standard you're not writing in C ;)

I know lots of stuff is unspecified or implementation-defined, but if you're
following the standard then you're also checking to see if such behavior is
acceptably portable, or otherwise selecting your algorithm so it works
portably.

It's not like Lua solves all these issues, either. Floating point behavior
is just as dependant on implementation-defined behavior as similar C code
would be. I just ran into it last week when exploring why infinity was
changing between INT_MIN and INT_MAX depending on whether it was converted
at compile-time or runtime.