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

[svn:perl6-synopsis] r9727 - doc/trunk/design/syn

0 views
Skip to first unread message

la...@cvs.perl.org

unread,
Jun 30, 2006, 6:17:55 PM6/30/06
to perl6-l...@perl.org
Author: larry
Date: Fri Jun 30 15:17:55 2006
New Revision: 9727

Modified:
doc/trunk/design/syn/S02.pod

Log:
Revised quote declarator.


Modified: doc/trunk/design/syn/S02.pod
==============================================================================
--- doc/trunk/design/syn/S02.pod (original)
+++ doc/trunk/design/syn/S02.pod Fri Jun 30 15:17:55 2006
@@ -14,7 +14,7 @@
Date: 10 Aug 2004
Last Modified: 30 Jun 2006
Number: 2
- Version: 46
+ Version: 47

This document summarizes Apocalypse 2, which covers small-scale
lexical items and typological issues. (These Synopses also contain
@@ -1344,21 +1344,50 @@
:f :function Interpolate & calls
:c :closure Interpolate {...} expressions
:b :backslash Interpolate \n, \t, etc. (implies :q at least)
+ :code Quasiquoting

-[Conjectural: Ordinarily the colon is required on adverbs, but the
-"quote" declarator allows you to combine any of the existing adverbial
-forms above without an intervening colon:
-
- quote qw; # declare a P5-esque qw//
- quote qqx; # equivalent to P5's qx//
- quote qn; # completely raw quote qn//
- quote qnc; # interpolate only closures
- quote qqxwto; # qq:x:w:to//
+Ordinarily the colon is required on adverbs, but the C<quote> declarator
+allows you to combine any of the existing adverbial forms above
+without an intervening colon:

-]
+ quote qw; # declare a P5-esque qw// meaning q:w
+ quote qn; # completely raw quote qn//
+ quote qnc; # q:n:c//, interpolate only closures
+
+If you want to abbreviate further, you may also give an explicit
+definition as either a string or quasiquote:
+
+ quote qx = 'qq:x'; # equivalent to P5's qx//
+ quote qTO = 'qq:x:w:to'; # qq:x:w:to//
+ quote circumfix:<❰ ❱> = q:code { .quoteharder }; # or some such...
+
+In particular, these forms disable the lookahead for an adverbial argument,
+so while
+
+ q:n($foo)
+
+will misinterpret C<$foo> as the C<:n> argument,
+
+ qn(stuff)
+
+has the advantage of misinterpreting it as the argument to the C<qn()>
+function instead. C<:)>
+
+But parens are special that way. Other bracketing characters are special
+only if they can be mistaken for adverbial arguments, so
+
+ qn[stuff]
+
+is fine, while
+
+ q:n[stuff]
+
+is not. Basically, just don't use parens for quote delimiters, and always
+put a space after your adverbs.

If this is all too much of a hardship, you can define your own quote
-adverbs and operators. All the uppercase adverbs are reserved for
+adverbs and operators as standard macros.
+All the uppercase adverbs are reserved for
user-defined quotes. All of Unicode above Latin-1 is reserved for
user-defined quotes.

Markus Laire

unread,
Jul 1, 2006, 8:31:52 AM7/1/06
to perl6-l...@perl.org
On 7/1/06, la...@cvs.perl.org <la...@cvs.perl.org> wrote:
> +In particular, these forms disable the lookahead for an adverbial argument,
> +so while
> +
> + q:n($foo)
> +
> +will misinterpret C<$foo> as the C<:n> argument,
> +
> + qn(stuff)
> +
> +has the advantage of misinterpreting it as the argument to the C<qn()>
> +function instead. C<:)>
> +
> +But parens are special that way. Other bracketing characters are special
> +only if they can be mistaken for adverbial arguments, so
> +
> + qn[stuff]
> +
> +is fine, while
> +
> + q:n[stuff]
> +
> +is not. Basically, just don't use parens for quote delimiters, and always
> +put a space after your adverbs.

Why q:n[stuff] is not fine? Shouldn't that pass [stuff] to adverb n?

Also, in what way are parens special?
Doesn't qn(stuff) and qn[stuff] both mean same thing?
And both q:n(stuff) and q:n[stuff] pass something to adverb n. (First
passes stuff, second passes [stuff])

--
Markus Laire

Larry Wall

unread,
Jul 1, 2006, 4:14:33 PM7/1/06
to perl6-l...@perl.org

That's what it does. But it's not fine if you expected [...] to
delimit the quoted string instead.

: Also, in what way are parens special?


: Doesn't qn(stuff) and qn[stuff] both mean same thing?

Nope, qn(stuff) is always a function call. q(foo) is always a function
call, not a quote.

: And both q:n(stuff) and q:n[stuff] pass something to adverb n. (First


: passes stuff, second passes [stuff])

That is correct. My intent with the quote declarator however is that
there be an implicit space after it, so the n on the end of qn no longer
functions as an adverb, at least in terms of looking for a subsequent
argument. I will attempt to clarify the distinction between quotes
and ordinary macros. Thanks.

Larry

0 new messages