This is actually something that has confused me before, too! It turns
out the LOLCODE language specification
(http://lolcode.com/specs/1.2#loops) says that any induction variables
declared for a loop ("VAR" in your sample code) are temporary and
local to the loop. This means that if you use "UPPIN YR VAR" or
"NERFIN YR VAR" in a loop declaration, it's as if a *new* variable VAR
is declared and initialized to 0 before the first iteration of the
loop and can only be used within the loop.
I agree that this it was a pretty weird design decision on the part of
the LOLCODE language creators! In their defense, loops are still
technically under construction so maybe they would have one day
addressed this issue... who knows?
TL;DR: lci is doing the right thing, even if the right thing is not
really that intuitive ;).
- Justin
> By the way, is the development stopped? :/ I really like lolcode, and
> this is the best interpreter I've found so far...
As far as I know, the people who originally created LOLCODE are not very active anymore (in part because the LOLCODE forums were shut down awhile back due to spam :( ). I'm still actively developing lci when I find time :) (last commit was a couple of weeks ago and there are some experimental new language features in the "future" branch :) and there has been some discussion in the lci-devel mailing list regarding language additions to implement in lci (such as arrays, classes, and other things). If there is some interest in further language development, I may set up another mailing list, lci-language, to try and work toward and solid LOLCODE 1.3 specification. Or maybe just set up a new forum?
> Also, are functions supported? I just can't get them to work.
They should be, although like loops, their declaration semantics aren't very well defined. This format I know for sure works:
HAI 1.2
CAN HAS STDIO?
HOW DUZ I ADD YR AA AN YR BB
FOUND YR SUM OF AA AN BB
IF U SAY SO
I HAS A X ITZ ADD 4 1
VISIBLE X
KTHXBYE
It generates the correct result, "5". If I put the declaration before the HAI I get an error and if I put the declaration after, I get the segfault (which probably shouldn't be happening, thanks for pointing that out!!!).
The rule of thumb is, for lci, if you put all of your code in the HAI...KTHXBYE block, you should generally be fine.
- Justin
Yeah, I've been pretty lazy about adding VERSIONS, COPYING, and other things like configure. I have a ToDo for lci to GNU-ify the repository, but for now, I'm just displaying the GPLv3 license in the headers.
- Justin