Possible bug on loops

35 views
Skip to first unread message

Gerardo Marset

unread,
Apr 4, 2011, 11:01:38 PM4/4/11
to lci-general
Running this:
#!/usr/bin/env lci
HAI 1.2
CAN HAS STDIO?
I HAS A VAR ITZ 10
IM IN YR PANTZ NERFIN YR VAR TIL BOTH SAEM VAR AN 1
VISIBLE VAR
IM OUTTA YR PANTZ
KTHXBYE
Prints:
0
-1
-2
-3
etc, etc, etc.
Very wierd.
If you put a VISIBLE VAR before the loop, it prints 10 and everything,
tough.

Justin Meza

unread,
Apr 4, 2011, 11:17:36 PM4/4/11
to lci-g...@googlegroups.com
Hey Gerardo,

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

Gerardo Marset

unread,
Apr 5, 2011, 4:28:53 PM4/5/11
to lci-general
Oh, I see :P my bad, then.
By the way, is the development stopped? :/ I really like lolcode, and
this is the best interpreter I've found so far...

Also, are functions supported? I just can't get them to work.
This (and pretty much any code that I've come up with that tries to
run a function):

#!/usr/bin/env lci
CAN HAS STDIO?

HAI 1.2
I HAS A X ITZ POWER 4 1
VISIBLE X
KTHXBYE

HOW DUZ I ADD YR AA AN YR BB
FOUND YR SUM AA AN BB
IF U SAY SO

results in a segmentation fault.

Thanks!

Justin Meza

unread,
Apr 5, 2011, 4:46:46 PM4/5/11
to lci-g...@googlegroups.com
Hey Gerardo,

> 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

Gerardo Marset

unread,
Apr 5, 2011, 5:56:55 PM4/5/11
to lci-general
> 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?
What a shame that the forums had to be shut down just because of spam :
(.
Well, I hope lci can keep progressing!

> > 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!!!).
Oh. I guess it's my bad for assuming the functions should be declared
outside the HAI block. I think the language specification doesn't say
anything on that matter, tough.
And you're welcome :).

On another matter, shouldn't you include a COPYING file along with the
source?

Thanks again!

Justin Meza

unread,
Apr 5, 2011, 8:21:19 PM4/5/11
to lci-g...@googlegroups.com
> On another matter, shouldn't you include a COPYING file along with the
> source?

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

Reply all
Reply to author
Forward
0 new messages