Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Perl5 -> Perl 6 Translations Design Document

3 views
Skip to first unread message

Sage La Torra

unread,
Jun 5, 2006, 6:22:49 PM6/5/06
to perl6-l...@perl.org
Hello all,

I'm the student picking up on the translation work lwall started. Since the
perl 5 parser is more or less complete, I've headed straight to the
translation work. I'm going to be taking on the translations a few at a
time, starting with the easiest translations and moving to the more complex.
I've got a design document detailing the first few translations I'll be
handling, and I'd greatly appreciate feedback and advice. Larry already took
a good crack at it, catching a few things I had stupidly thought were
simpler then they are, and now it's ready for general review.

The current version can be found at
http://infohost.nmt.edu/~slatorra/conversionstageone.txt

Any advice/comments/criticism on the document and even ideas on
implementation would be greatly appreciated.

Sage

Ruud H.G. van Tol

unread,
Jun 5, 2006, 6:42:13 PM6/5/06
to perl6-l...@perl.org
Sage La Torra schreef:

> http://infohost.nmt.edu/~slatorra/conversionstageone.txt
>
> Any advice/comments/criticism on the document and even ideas on
> implementation would be greatly appreciated.

I think that

split('\s+') -> split(/\s+/)

should be


split('\s+') -> .split(/\s+/)

--
Groet, Ruud

Jonathan Worthington

unread,
Jun 5, 2006, 9:06:05 PM6/5/06
to Sage La Torra, perl6-l...@perl.org
"Sage La Torra" <sag...@gmail.com> wrote:
> I've got a design document detailing the first few translations I'll be
> handling, and I'd greatly appreciate feedback and advice.
>
I may be off base here, or in the alternate pointing out a corner case
that's of little significance, but:

-Compound statements: if($foo eq "a" or $foo eq "b" or $foo eq "c") {...} ->
if $foo eq "a"|"b"|"c" {...}

Is there an issue if $foo is tied here, in that (unless the a or b condition
match) $foo will be evaluated three times; for testing against a junction is
it feasible that the compiler can say "aha, I'll only evaluate $foo once and
test it three times"? Reading $foo may have some real world visible effects
and the semantics would change. The P6 spec may nail this down, but I
haven't time to go look (and I'll surely not have time before I forgot this
thought completely...)

That's all I can pick out from the quick glance I have time for. Have fun!
:-)

Jonathan

Larry Wall

unread,
Jun 5, 2006, 9:37:29 PM6/5/06
to perl6-l...@perl.org

Yes, but I think the translator can assume that most scalar variables
aren't tied, especially if there isn't a tie anywhere else in the file.
Could have a user option to pessimize that, and it should probably be logged
as one of the places the translator guessed. But unlimited tying is
one of the problems with Perl 5 that Perl 6 is trying to control, so it's
sort of natural that the translator would run into this here and there.

Another minor difference is that "or" guarantees an ordered
short-circuit while "|" may short-circuit in any order the compiler
pleases. Again, unlikely to be a problem for the variable in the
absence of ties, but if some of the value calculations that can blow
up are guarded by "or" conditions, then you've got a problem.

We'll definitely need to provide some knobs for the user to turn to
control how much refactoring is attempted.

Larry

Sam Vilain

unread,
Jun 5, 2006, 9:41:41 PM6/5/06
to Sage La Torra, perl6-l...@perl.org
Sage La Torra wrote:

Looks like a reasonable starting point.

I assume that the "AST" will include comment nodes etc?

Sam.

Aaron Crane

unread,
Jun 6, 2006, 5:00:23 AM6/6/06
to perl6-l...@perl.org
Sage La Torra writes:
> http://infohost.nmt.edu/~slatorra/conversionstageone.txt

You say this:

-Hash in interprative context: "%hash" -> "%hash{}" (also @{[...]} ->
{...})

Hashes don't interpolate in Perl 5, so that's not an issue (unless I'm
misunderstanding what you meant). But using "{...}" instead of "@{[...]}"
is definitely a good thing.

--
Aaron Crane

Sage La Torra

unread,
Jun 6, 2006, 8:09:53 PM6/6/06
to perl6-l...@perl.org
"interpolative context" ment the perl 5 side, where the double quotes should
cause interpolation. Maybe not the best phrase to identify it, now that you
mention it.

Sage

Smylers

unread,
Jun 7, 2006, 5:48:28 AM6/7/06
to perl6-l...@perl.org
Sage La Torra writes:

> "interpolative context" ment the perl 5 side, where the double quotes
> should cause interpolation.

Yes, but not for entire hashes; the percent character isn't special in


Perl 5 double-quoted strings, as Aaron said:

> On 6/6/06, Aaron Crane <pe...@aaroncrane.co.uk> wrote:
>
> > Sage La Torra writes:
> >
> > > http://infohost.nmt.edu/~slatorra/conversionstageone.txt
> >
> > You say this:
> >
> > -Hash in interprative context: "%hash" -> "%hash{}" (also @{[...]} ->
> > {...})
> >
> > Hashes don't interpolate in Perl 5, so that's not an issue

And Sage, please (in general) don't top-post on this mailing list; it
makes it much harder for people who wish to follow up on what was said
earlier in the thread to provide context for exactly what they're
commenting on.

Smylers

Sage La Torra

unread,
Jun 7, 2006, 5:42:00 PM6/7/06
to perl6-l...@perl.org
Just an update:

I've started coding (in haskell, to be used with Pugs). I've got file input,
I've got a data structure for the AST, now I just have to make them play
nicely together. I'll start implementing translations soon, so any other
corrections would be appreciated.

Thanks to everyone who's already given me corrections, sorry for the
mistakes I made (no more top posting for me).

Sage

0 new messages