I propose using LFG as a function declaration scoped closure declaration.
LFG SOMEFUNCTION HAI I HAS A NUMBER1 IZ 0 KTHX I HAS A NUMBER1 IZ SOMEFUNCTION!!
This is a function () → int, in this case. It always returns 0.
As a corollary, LF1M would be a function with one argument.
LF1M SOMEFUNCTION NEED HLR HAI HLR UP!!5 KTHX I HAS A NUMBER1 IZ SOMEFUNCTION!!4
This is a function int → int. It adds five and returns it. So in this case NUMBER1 is 9.
NEED is a keyword to bind the variables passed in to the scope.
The function method itself can act as a typed value. So:
I HAS A FIBONACCI IZ LF2M NUM1 HAI
IZ NUM1 SMALLER THAN 1 O RLY?
YA RLY
0
MEBBE NUM1 SMALLER THAN 2
1
NO WAI HAI
I HAS A NUM2 IS NUM1
I HAS A NUM3 IS NUM1
DOWN NUM2!!1
DOWN NUM3!!2
ADDS FIBONACCI NUM2 FIBONACCI NUM3
KTHX
KTHX
Several implications from this code. !! is an optional delimiter between arguments, and the return value of a function is always just the last executed value.
— Perhaps an implied return isn't so useful. At least, we'd want to be able to force a return, or explicitly state it. Sometimes we don't want to return anything at all. Could use GIEF as return. Or DNW/DO NOT WANT.
- Al