lua-users home
lua-l archive

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


> local a,b
>
> Variables must have a value; what shall it be if not nil?
>
> I.e. it is hard to banish the need for nil, if we insist that all
> variables must have a definite value. So something like nil always
> sneaks in. And insisting on always initializing locals would be
> irritating.

Hmm, either insisting to be initalized, or error() if read without
initialization, or "false" as a new kinda dropin replacement, as
first-class-like nil. I wouldn't know which one would be the best, if
to code done the nil-less dialect.

> Something that has been floated before, of course, is that there
> should be two kinds of nil; call them nil and null (they both have
> type 'nil' and both evaluate as false); the difference is that null
> can be put into a table. I think Mark Hamburg suggested something like
> this in the last 'holes, dammit!' discussion, but it was felt that
> this was a foreign idea imported from JavaScript. (His suggestion was
> something a bit more subtle; that this null value would not
> necessarily be visible to the programmer, but exist as a
> non-nil-but-nil-like value to put into tables)

This reappears in this discussion. This depends on the subtlies, but
might a change in usage/mind sufficide, and declare:
_G.undefined = {}
And use this for these "unknown" places instead of the (mis)use of
nil. It would work in many places. except its implicit boolean value
to be true, which is un-nice.

Just when a language needs to differ between '==' and '===' then IMHO
something went wrong along the way.

Kind regards,