lua-users home
lua-l archive

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


On Mon, Oct 07, 2019 at 10:24:14PM -0700, Russell Haley wrote:
> On Mon, Oct 7, 2019 at 3:12 PM Egor Skriptunoff <egor.skriptunoff@gmail.com>
> wrote:
> 
> > On Mon, Oct 7, 2019 at 10:48 PM Petri Häkkinen wrote:
> >
> >>
> >> > So, the motivation for the change is to move our minds from the
> >> > concept that errors return (nil,msg) to the concept that errors return
> >> > (falsy,msg). Maybe one day in the distant future we might change
> >> > that falsy to false instead of nil.
> >>
> >> I’m sorry but I fail to see any improvement here. How does false signal
> >> an error any better than nil?
> >>
> >>
> > Probably, Roberto wants to guarantee that an array
> > *{any_standard_function()}*  will be a sequence.
> > Hence such array will become traversable with ipairs.
> > This might reduce nilophoby in Lua :-)
> >
> > Okay, that makes some sense to me, but `fail` is not a keyword and I can
> assign a value to `fail`. Is fail just a concept?
> 
> Should I start explicitly returning false instead of just letting values be
> nil? Returning nil as the first return value IS weird but it's a pattern I
> have grown fond of.
> 

Is it wierd or just reflective of a difficult problem domain? As an
undergraduate (late 1990s) I took a programming class in the statistics
department. I forget my professor's name but he worked for one of the
government agencies in Washington, D.C. tracking labor and other economic
data, including processing and analysis of questionaires. After class for a
couple of evenings he *attempted* to explain to me a research paper he had
written some years prior regarding how to encode missing, null, empty, 0,
incomplete, erroneous, etc answers. It was all completely over my head; I
didn't even understand the existing, well-accepted types let alone his
extensions of them that he was so excited about.

What I do know is that the number of such types he was trying to explain
were more numerous than any set I've since been able to find in the computer
science literature. Which explains his excitement. IIRC, he was a scholar in
the data science field, so presumably his ideas went straight to the heart
of some important theories in applied math and statistics.

My impression is that false and nil are woefully inadequate to express the
various nuances demanded of such types. OTOH, exactly what you want or
should express can be very difficult to identify. So whether Lua only has 1,
2, or 4 such types[1], I don't think there's any getting away from the
sentiment that the set of available types is either incomplete or
superfluous, depending on the context.

[1] My vague recollection is that he was arguing for either 3 or 4 unique
xtypes, or 1 more than whatever the established, minimal set.