develooper Front page | perl.perl6.internals | Postings from January 2002

Question about "match" vtable method and regexes

Thread Next
From:
David M. Lloyd
Date:
January 11, 2002 19:05
Subject:
Question about "match" vtable method and regexes
Message ID:
Pine.LNX.4.43.0201112055500.2869-100000@homebody.freemm.org
I have a design question here.  Why did we take the approach of having a
match method on every single vtable, instead of having a vtable for
regular expressions, and have regex be an object (like Perl 5)?

From a Perl (6) perspective, it makes more sense to me:

  # This:
  $a =~ /$regex/;
  # would be the same as this:
  $regex.match($a);

This way I can have my own regex module:

  use PCRE;

  my $pcre = PCRE.new('^foo(\d+)');

  $string =~ /$pcre/;
  # same as:
  $pcre.match($string);

And have races. :-)

I can't imagine that class designers would always remember to implement
the 'match' method on every class, and I also think that there really
isn't any logical way to match a non-string against a regular expression.
My proposed regular expression vtable methods would just stringify their
PMC arguments.

Does this make any sense to anyone?

- D

<dmlloyd@tds.net>


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About