lua-users home
lua-l archive

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

On Fri, Jan 9, 2015 at 3:43 PM, Enrique Arizón Benito
<> wrote:
> Actually the opposite applies. C language handle *REAL* memory directly.

opposite of what?  (just one example of why top-posting is pointless)

(I know why *(0) means instant kill, and also about MCUs (and big
CPUs!) where that doesn't apply. I cut my teeth on 8bit computers when
they were state-of-the-art)

my main issue is not that "you can't do this to Lua, Lua is perfect as
is!", but that those "NULL is a bug!" rants are only a very personal
point of view, often they just reduce to "i hate error checking"

I think a much better approach is the one taken by Go: embrace the
zero.  it's not a language feature, just that it's idiomatic that
every variable starts by being 0-filled, and you're supposed to accept
a zero-value as a valid 'initial' value.  The "Effective Go" document
states that "The zero-value-is-useful property works transitively",
meaning that object initializers can be trivial if all its elements
are just Zero.

there's still error checking, but usually the error comes on a
separate return value, and the error checking code is very regular, so
while not so nice as code that works correctly without checking, is
much more readable than some C code where 2 lines of every 3 are 'just
in case something nasty happens'.