Re: Quasiquoting

1 view
Skip to first unread message

Autrijus Tang

unread,
Jun 27, 2005, 7:54:37 PM6/27/05
to Brad Bowman, perl6language
On Tue, Jun 28, 2005 at 09:49:58AM +1000, Brad Bowman wrote:
> Autrijus' journal mentions quasiquoting (Perl 5).

Yes... quasiquoting in Perl 5 is currently crudely emulated
by feeding things to PPI::Tokenizer and PPI::Transform. :-)

> I was wondering how that would work. Many languages use unusual
> syntax for quasiquoting and code splicing but Perl 6 is already
> nibbling into unicode.
> Does that mean macros will be grafting and pruning the AST that
> comes back from a quote/rule?

That is my current understanding; you'll have to explicitly call
parse and compile and then eval.

> Or will there be syntatic shorthand?

There's no shorthand for the process as far as I'm aware. I'd love
to see a sane design, and implementors are welcome too. :)

Thanks,
/Autrijus/

Adam Kennedy

unread,
Jun 27, 2005, 11:19:20 PM6/27/05
to perl6-l...@perl.org
Autrijus Tang wrote:
> On Tue, Jun 28, 2005 at 09:49:58AM +1000, Brad Bowman wrote:
>
>>Autrijus' journal mentions quasiquoting (Perl 5).
>
>
> Yes... quasiquoting in Perl 5 is currently crudely emulated
> by feeding things to PPI::Tokenizer and PPI::Transform. :-)

You're doing what now? :)

Just in case this ever comes up again, let me clear something up now.
It's worth noting it once here for everyone.

PPI is not a code parser. By code parser I mean taking a string and
turning it into working code. PPI is a document parser. It parses ONLY
on syntax to form a model of a document. Any conclusions it might make
on the structure of the resulting code are secondary.

It cannot determine implicit parameters for function calls, which also
means it has difficulty or cannot determine operator precedence.

It is theoretically impossible to (document) parse Perl "fully" without
also executing it, and even then perl doesn't (document) parse Perl, it
just (code) parses Perl, or rather runs Perl.

So to summarise, PPI is of limited use when it comes to working with
bytecode or something that will be executed. It is for working with
documents, not code.

And I'm done here :)

Adam K

Autrijus Tang

unread,
Jun 28, 2005, 5:41:49 AM6/28/05
to Adam Kennedy, perl6-l...@perl.org
On Tue, Jun 28, 2005 at 01:19:20PM +1000, Adam Kennedy wrote:
> >Yes... quasiquoting in Perl 5 is currently crudely emulated
> >by feeding things to PPI::Tokenizer and PPI::Transform. :-)
>
> PPI is not a code parser. By code parser I mean taking a string and
> turning it into working code. PPI is a document parser. It parses ONLY
> on syntax to form a model of a document. Any conclusions it might make
> on the structure of the resulting code are secondary.

Right. Hence it guarantees at most well-formness, instead of semantic
correctness. Hence, "crudely emulated", because we don't have anything
better at this moment.

> So to summarise, PPI is of limited use when it comes to working with
> bytecode or something that will be executed. It is for working with
> documents, not code.

Yup. But PPI is still much better than consuming and concatenating
raw strings. :-)

Thanks,
/Autrijus/

Reply all
Reply to author
Forward
0 new messages