imcc/docs/syntax.pod has the following:

        =item 'char constant'

        Are delimited by B<'>. They are taken to be C<ascii> encoded. No escape
        sequences are processed.

But in fact B<'> behaves like B<"> without escapes or encoding/charset
prefixes:

        [EMAIL PROTECTED]> cat foo.pir
        .sub _main @MAIN
                S1 = 'xyzzy\n'
                print S1
                print ascii:"\n"
        .end
        [EMAIL PROTECTED]> parrot foo.pir
        xyzzy\n
        [EMAIL PROTECTED]> 

A syntax for specifying multiple characters without escapes seems like a
useful thing, a la Perl5, but being unable to specify an encoding or
charset seems less useful, even for a single character.  In fact, I was
expecting a single character to be represented as an integer internally,
or at least to be easily converted to one, so I was surprised that this
didn't print "120\n":

        [EMAIL PROTECTED]> cat bar.pir
        .sub _main @MAIN
                I1 = 'x'
                print I1
                print "\n"
        .end
        [EMAIL PROTECTED]> parrot bar.pir
        0
        [EMAIL PROTECTED]> 

That would seem to be the one reasonable use for character constants,
but 'x' behaves no differently from "x" in this example.

   So what should 'x' mean in PIR?  I would suggest:

   1.  B<'> in PIR is like B<'> in Perl5, i.e. accept the status quo,
but add encoding/charset prefix syntax, and fix the doc; and

   2.  Support character constants via either string syntax by defining

        I1 = 'x'

mean the equivalent of

        S1 = 'x'
        I1 = ord S1

to match my naive assumption.  Does that sound reasonable?

                                        -- Bob Rogers
                                           http://rgrjr.dyndns.org/

Reply via email to