Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Null considered beneficial

Name: Anonymous 2015-08-03 4:56

The nil or null value was discovered, seemingly independently, when creating Lisp (perhaps IPL too), PL/I, Simula, Algol W, and BCPL (where it was just integer 0).
An all-bits-zero value was already in use by assembly programmers for marking the end of a linked list or tree.
It arises naturally when implementing pointers and linked lists.
Null is a list terminator, an uninitialized value, a dummy object, a null or revoked capability.
Null makes garbage collectors and secure memory allocators possible.

Without pointers, there would still be a null analogue.
Fortran programmers used to use array indices as pointers and a 0 index as null.
Process calculi often have a null process which can be compared by identity.

Null is one of the most noble and powerful discoveries of programming.
Although it is very simple, a full understanding of its power cannot be detailed in such a short post.

Name: Anonymous 2015-09-21 10:12

>>11
It is also as cheap as traditional pointers, because the compiler can implement it with a sentinel value if it so pleases.
It's worth noting Rust uses exactly that optimization. Option<pointer> is stored without a tag, NULL for None and pointers are recorded verbatim so the storage is pointer-sized as in C.

This optimization won't work on many kinds of enums but it will work for user defined types that qualify, such as Options (defined in std, but you might define your own if you go std-less), data-less enums, enumerations (C-style) and #[repr(C)] enums (C ABI.)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List