Hacker News new | past | comments | ask | show | jobs | submit login

The regex sublanguages and engines in Ruby and Python are knockoffs of the equivalents in earlier Perls.

But this thread really ought to be focused on Perl 6.

In Perl 6 one can write:

  print "match" if something ~~ /<thing>/
It looks superficially similar. But it's a scalable parsing feature, not a mere regex. That line of code will work when `something` is ten thousand lines of complex Perl 6 code and `thing` is the top rule in a grammar for parsing Perl 6 code.

Perl 6 is not Perl 5.




I was showing Ruby code to show how its regex handling is much like Perl 5 - Perl 5 would use a sigil on 'something'. Ruby is less like Perl 6 regex-wise due to the smart match (among many other things).


> Ruby is less like Perl 6 regex-wise due to the smart match (among many other things).

In both Perl 5 and Perl 6, smart match (`~~`) with a regex on the right hand side is just an alternate spelling (Perl 5) or correct spelling (Perl 6) for `=~`. It's a tiny, trivial difference.

But a Perl 6 "regex" can be an arbitrary full blown parser or compiler. And it assumes character=grapheme. In these two regards, as in several others, Perl 6 is quite unlike Perl 5 and other langs that adopted Perl 5 regexes and/or that adopted Unicode codepoints (or worse) rather than graphemes as their fundamental "character" unit.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: