[Parrot-users] Parrot Babysteps - a PIR tutorial for novices - works on 2.6

Brian Wisti brian.wisti at gmail.com
Thu Jul 22 15:36:57 UTC 2010


Hi kjstol,

Thanks for the feedback! I just put a quick test PIR script together,
and it looks like the limitation applies.

    # evil.pir
    .sub 'main' :main
        .local int if, goto

        if = 5
        goto = 3

        if if > goto goto L1
        say "if is not greater than goto"

      L1:
        say "what?"
    .end

The example used your sample excerpt as a starting point. Parrot
complains loudly if I hand it the file, though.

    $ parrot evil.pir

    error:imcc:syntax error, unexpected IF, expecting IDENTIFIER ('if')
            in file 'evil.pir' line 5
    error:imcc:syntax error, unexpected '=' ('=')
            in file 'evil.pir' line 7
    error:imcc:syntax error, unexpected '=', expecting IDENTIFIER or
PARROT_OP ('=')
            in file 'evil.pir' line 8
    error:imcc:syntax error, unexpected IF ('if')
            in file 'evil.pir' line 10
    error:imcc:syntax error, unexpected STRINGC, expecting '(' ('"if
is not greater than goto"')
            in file 'evil.pir' line 11
    error:imcc:syntax error, unexpected STRINGC, expecting '(' ('"what?"')
            in file 'evil.pir' line 14
    error:imcc:syntax error ... somewhere
            in file 'evil.pir' line 14

Thanks for making me check, though. I was taking some docs at their
word and hadn't actually verified the behavior myself until now.

Kind Regards,

Brian Wisti

On Thu, Jul 22, 2010 at 1:59 AM, kjstol <parrotcode at gmail.com> wrote:
> well done, keep up the good work. just browsing quickly, I noted:
>
> http://coolnamehere.com/geekery/parrot/learn/02-variables-and-types.html
>
> The only other rule to remember about variable names is that they may
> not be reserved words. Reserved words have special meaning to Parrot,
> and it will complain if you use one of them for your own nefarious
> ends. The list of reserved words is delightfully small.
>
> ISTR that this is not the case. At least, I went through great efforts
> to prevent this when working on PIRC; you *can* actually declare
> variables with those names, so they are not reserved. So, that means
> you could write:
>
> .local int if, goto
> ...
> if if > goto goto L1
> ...
> L1:
>
> Not sure to what extent that works in IMCC. In any case, somewhere in
> the mailing list there is a discussion on this, and the conclusion was
> that they are not reserved words.
>
> cheers,
> kjs


More information about the Parrot-users mailing list