[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Nil and false in Lua design
- From: Sean Conner <sean@...>
- Date: Mon, 14 Oct 2013 15:16:06 -0400
It was thus said that the Great steve donovan once stated:
> On Mon, Oct 14, 2013 at 1:25 PM, Carsten Fuchs <carsten.fuchs@cafu.de> wrote:
> > I'm certainly not feverish about this, but for consistency's sake, I think
> > it would be nice to have either -- or none. ;-)
>
> Up to some point, consistency is overvalued.
"A foolish consistency is the hogoblin of little minds."
-- Ralph Waldo Emmerson
> No point in breaking all
> those programs because implicit tostring was offending my delicate
> tastes - because tastes differ. I'm with Dirk when he suggests an
> explicit tobool, then everyone can see what's happening and (NB) not
> paying for something they don't need. This is a famous C++ principle,
> but then it hides so much implicit complexity (in theory, 'fire =
> true' could launch a rocket *) that one has to be extra awake.
I deal with some pretty complex protocols [1] at work. These protocols
tend to have lots (and lots) of optional parts. I don't like it, but I
can't change that. So, my code tends to have:
if info.use_extension_a then
...
end
if info.use_option_2 then
...
end
If nil becomes non-boolean, then I would either have to change a lot of
code to:
info.use_extension_a = false
info.use_option_2 = false
-- and a billion other options I don't care about
or
if info.use_extention_a ~= nil and info.use_extension_a then
...
end
if info.use_option_2 ~= nil and info.use_option_2 then
...
end
In other words---it becomes a royal pain in the butt. And for what? A
bit of purity? [2]
> (*) Silly example, but when dealing with others' code you learn to
> hate cleverness. It remains true, of course, that 'rocket.fire =
> true' could do the same in Lua.
True enough. I have code where you can do:
proc.limits.hard.cpu = 300
to limit the CPU usage of a program to 5 minutes [4]; underneath, it's a
call to setrlimit().
-spc
[1] SS7, which is used in telephony.
[2] Even Haskell had to ditch 100% mathematical purity just so we could
get useful programs [3]
[3] Monads solely exist to make Haskell useful.
[4] That's 300 seconds of CPU usage, not 300 seconds of wall clock time.
There is a difference.
- References:
- Re: Nil and false in Lua design, Coda Highland
- Re: Nil and false in Lua design, Luiz Henrique de Figueiredo
- Re: Nil and false in Lua design, Thomas Jericke
- Re: Nil and false in Lua design, steve donovan
- Re: Nil and false in Lua design, Dirk Laurie
- Re: Nil and false in Lua design, Carsten Fuchs
- Re: Nil and false in Lua design, Thomas Jericke
- Re: Nil and false in Lua design, steve donovan
- Re: Nil and false in Lua design, Carsten Fuchs
- Re: Nil and false in Lua design, steve donovan