[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ideas
- From: Tom N Harris <telliamed@...>
- Date: Mon, 16 Apr 2012 19:17:03 -0400
On 04/16/2012 06:37 PM, Vox Timothy wrote:
- New Keywords: And, Or, Not ("Existential and," "Existential or," and
"Existential not"; like and, or, not but whose only false value is nil
(instead of nil and false))
local function _and(n, foo, ...)
if n < 2 then return foo end
if foo == nil then return nil end
return _and(n-1, ...)
end
function And(...)
return _and(select('#', ...), ...)
end
If I understand what you're asking for correctly.
- New Keyword: funct (like function, but with automatic return; would
require an explicit nil if void)
- if, while, etc. could also automatically return (be expressions
instead of statements; in case of loop, last iteration)
Explicit is better than implicit. Is it that painful to type 'return'
every once in a while?
And these two functions are not the same:
f1 = function() return nil end
f2 = function() return end
select('#', f1()) == 1
select('#', f2()) == 0
A funct would not be able to express f2.
--
- tom
telliamed@whoopdedo.org