Fwd: [Re: [FWP] Comic goodness]

2000-09-15 Thread Michael G Schwern

I thought you people might need a little break.  The first one is
particularly... yeah.


- Forwarded message from Jim Monty [EMAIL PROTECTED] -
From: Jim Monty [EMAIL PROTECTED]
Subject: Re: [FWP] Comic goodness
To: [EMAIL PROTECTED]
Date: Fri, 15 Sep 2000 09:53:48 -0700 (MST)

 See, regular expression matter to stick people as well as humans.
 http://www.explodingdog.com/june11/backref.html

Cf. http://www.userfriendly.org/cartoons/archives/99feb/uf000342.gif

-- 
Jim Monty
[EMAIL PROTECTED]
Tempe, Arizona USA

 Want to unsubscribe from Fun With Perl?  Well, if you insist...
 Send email to [EMAIL PROTECTED] with message _body_
   unsubscribe

- End forwarded message -

-- 

Michael G Schwern  http://www.pobox.com/~schwern/  [EMAIL PROTECTED]
Just Another Stupid Consultant  Perl6 Kwalitee Ashuranse
Plus I remember being impressed with Ada because you could write an
infinite loop without a faked up condition.  The idea being that in Ada
the typical infinite loop would be normally be terminated by detonation.
-- Larry Wall in [EMAIL PROTECTED]



Re: RFC 166 (v2) Alternative lists and quoting of things

2000-09-15 Thread Mark-Jason Dominus


 (?Q$foo) Quotes the contents of the scalar $foo - equivalent to
 (??{ quotemeta $foo }).

How is this different from

\Q$foo\E

? 



RFC 166 (v2) Alternative lists and quoting of things

2000-09-15 Thread Perl6 RFC Librarian

This and other RFCs are available on the web at
  http://dev.perl.org/rfc/

=head1  TITLE

Alternative lists and quoting of things

=head1 VERSION

  Maintainer: Richard Proctor [EMAIL PROTECTED]
  Date: 27 Aug 2000
  Last Modified: 15 Sep 2000
  Mailing List: [EMAIL PROTECTED]
  Number: 166
  Version: 2
  Status: Developing

=head1 ABSTRACT

Expand Alternate Lists from Arrays and Quote the contents of things 
inside regexes.

=head1 DESCRIPTION

These are a couple of constructs to make it easy to build up regexes
from other things.

=head2 Alternative Lists from arrays

The basic idea is to expand an array as a list of alternatives.  There
are two possible syntaxs (?@foo) and just plain @foo.  @foo might just have
existing uses (just), therefore I prefer the (?@foo) syntax.

(?@foo) is just syntactic sugar for (?:(??{ join('|',@foo) })) A bracketed
list of alternatives.

=head2 Quoting the contents of things

If a regex uses $foo or @bar there are problems if the content of
the variables contain special characters.  What is needed is a way
of \Quoting the content of scalars $foo or arrays (?@foo).

Suggested syntax:

(?Q$foo) Quotes the contents of the scalar $foo - equivalent to
(??{ quotemeta $foo }).

(?Q@foo) Quotes each item in a list (as above) this is equivalent to
(?:(??{ join ('|', map quotemeta, @foo)})).

In this syntax the Q is used as it represents a more inteligent \Quot\E.

=head2 Comments

Hugo:
 (?@foo) and (?Q@foo) are both things I've wanted before now. I'm
 not sure if this is the right syntax, particularly if RFC 112 is
 adopted: it would be confusing to have (?@foo) to have so
 different a meaning from (?$foo=...), and even more so if the
 latter is ever extended to allow (?@foo=...).
 I see no reason that implementation should cause any problems
 since this is purely a regexp-compile time issue.

Me: I cant see any reasonable meaning to (?@foo=...) this seams an appropriate
syntax, but I am open for others to be suggested.

=head1 CHANGES

RFC 166, v1 was entitled "Additions to regexes".

V1 of this RFC had three ideas, one has been dropped, the other is now part
of RFC 198.

V2 Expands the list expansion and quoting with quoting of scalars and 
Implemention issues.


=head1 MIGRATION

As (?@foo) and (?Q...) these are additions with out any compatibility issues.

The option of just @foo for list exansion, might represent a small problem if
people already use the construct.

=head1 IMPLENTATION

Both of these are changes are regex compile time issues.

Generating lists from arrays almost works by localising $" as '|' for the 
regex and just using @foo.

MJD has demonstrated implementing (?@foo) as (?\@foo) by means of an overload
of regexes, this slight change was necessary because of the expansion of
@foo - see below.

Both of these changes are currently affected by the expansion of variables in
the regex before the regex compiler gets to work on the regex.  This problem also
affects several other RFCs.  The expansion of variables in regexes needs
for these (and other RFCs) to be driven from within the regex compiler so
that the regex can expand as and where appropriate.  Changing this should not
affect any existing behaviour.

=head1 REFERENCES

RFC 198: Boolean Regexes