Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

punie.g observation

1 Aufruf
Direkt zur ersten ungelesenen Nachricht

Chris Dolan

ungelesen,
17.01.2006, 16:50:5617.01.06
an perl6-i...@perl.org
Allison et al.,

I was looking at languages/punie/lib/punie.g in the current SVN head
and got confused. I see:
rule gprint { (print) \s* <PunieGrammar::expr> }
and
rule expr { <PunieGrammar::gprint> | <PunieGrammar::cexpr> }

Doesn't that imply that "print print print print 1;" is a valid Punie
program? Is that intentional? It seems to me that the gprint rule
should instead contain "cexpr":
rule gprint { (print) \s* <PunieGrammar::cexpr> }

Sorry if these are dumb questions. I've been following Parrot for a
while, but I'm new to the code...

Chris
--
Chris Dolan, Software Developer, http://www.chrisdolan.net/
Public key: http://www.chrisdolan.net/public.key
vCard: http://www.chrisdolan.net/ChrisDolan.vcf

Andrew Rodland

ungelesen,
17.01.2006, 18:01:1017.01.06
an perl6-i...@perl.org
On Tuesday 17 January 2006 16:50, Chris Dolan wrote:
> Allison et al.,
>
> I was looking at languages/punie/lib/punie.g in the current SVN head
> and got confused. I see:
> rule gprint { (print) \s* <PunieGrammar::expr> }
> and
> rule expr { <PunieGrammar::gprint> | <PunieGrammar::cexpr> }
>
> Doesn't that imply that "print print print print 1;" is a valid Punie
> program? Is that intentional? It seems to me that the gprint rule
> should instead contain "cexpr":
> rule gprint { (print) \s* <PunieGrammar::cexpr> }

"print print print print 1;" is certainly a valid Perl 5 program; it prints a
1 followed by 3 other things (which are defined to be true, and which happen
to also be the number 1). Digging on retroperl.cpan.org shows that it did
exactly the same thing on perl 1.0.0. So to answer your question, it's
probably intentional :)

Andrew

Chromatic

ungelesen,
17.01.2006, 20:41:5317.01.06
an perl6-i...@perl.org, Andrew Rodland
On Tuesday 17 January 2006 15:01, Andrew Rodland wrote:

> "print print print print 1;" is certainly a valid Perl 5 program; it
> prints a 1 followed by 3 other things (which are defined to be true, and
> which happen to also be the number 1).

Nit: print doesn't *always* return a true value. It's a system call. It can
fail.

At least, that's how Punie should eventually handle it, if it doesn't yet.

-- c

Allison Randal

ungelesen,
17.01.2006, 21:24:5417.01.06
an Internals List
On Jan 17, 2006, at 18:01, Andrew Rodland wrote:
>>
>> Doesn't that imply that "print print print print 1;" is a valid Punie
>> program? Is that intentional? It seems to me that the gprint rule
>> should instead contain "cexpr":
>> rule gprint { (print) \s* <PunieGrammar::cexpr> }
>
> "print print print print 1;" is certainly a valid Perl 5 program;
> it prints a
> 1 followed by 3 other things (which are defined to be true, and
> which happen
> to also be the number 1). Digging on retroperl.cpan.org shows that
> it did
> exactly the same thing on perl 1.0.0. So to answer your question, it's
> probably intentional :)

Yup, that part of the punie grammar is pretty direct translation of
the original perl.y.

Allison

0 neue Nachrichten