Re: Just reading up on Pike...
On Sat, 17 August 2002, Nicholas Clark wrote: > But how on earth would you implement such a thing? :-) I imagine that type specifiers require that values assigned to the corresponding variable satisfy: value.isa(type). Using a superposition as a type means that the result of that test comes back as a superposition too. If that returned superposition is true, the assignment proceeds. Damian
Re: Just reading up on Pike...
Aaron Sherman wrote: > So, > > my all(str, int) $foo = $!; > > would be fine? I'd expect so. > I'm forgetting what has been said about $! Typically contains an object with both string and integer conversions. Whether convertability to both types is enough to satisfy a superpositional type is an interesting question. I suspect it *is*. Damian
Re: Just reading up on Pike...
In a message dated Sat, 17 Aug 2002, [EMAIL PROTECTED] writes: > [$!] Typically contains an object with both string and integer > conversions. Whether convertability to both types is enough to satisfy a > superpositional type is an interesting question. I suspect it *is*. Then I'd assume that multiple inheritance of both types would also conform? So if $! is Errno, where class Errno is str is int (or is that Errno is str, int?), that would work too? Wow. There's more than one way to do it--even static(-ish) typing. Who woulda thunk it. :-) Trey
Balanced Matches in Regexps?
Hello All, After reading over Apocalypse 5 one more time, I noticed that balanced matches (like capturing nested parenthetical comments ((like this))) had been glossed over in the rejection of RFC 145. What was not even mentioned in the rejection was the possibility of balanced expressions that would take rules as their opening and closing delimiters. This would be especially useful, for example, when capturing nested tables in an HTML document, since not all tables look the same ( vs. for instance). You may object that this would just make the regexp uglier, but what happens if we allow XML-ish rules, e.g. $html =~ / closing=>/; where the "balanced" rule gets to play with %_{opening} and %_{closing} to do its magic? I am not saying that such a "balanced" rule would be easy to implement in Perl (I personally think that the "balanced" rule is something that should be more deeply tied to the Regex Engine), but I am proposing that it can simultaneously be very useful and still look nice. Isn't that justification enough? Comments are appreciated, Peter Behroozi
RE: Balanced Matches in Regexps?
Peter Behroozi: # After reading over Apocalypse 5 one more time, I noticed that # balanced matches (like capturing nested parenthetical # comments ((like this))) had been glossed over in the # rejection of RFC 145. What was not even mentioned in the rule parenthesized { \( ( <-[()]> | ) \) } The key to balanced delimiters is recursion. A5 gives us convenient recursion; therefore, it gives us balanced delimiters. --Brent Dax <[EMAIL PROTECTED]> @roles=map {"Parrot $_"} qw(embedding regexen Configure) He who fights and runs away wasted valuable running time with the fighting.
RE: Balanced Matches in Regexps?
On Sat, 17 Aug 2002, Brent Dax wrote: : Peter Behroozi: : # After reading over Apocalypse 5 one more time, I noticed that : # balanced matches (like capturing nested parenthetical : # comments ((like this))) had been glossed over in the : # rejection of RFC 145. What was not even mentioned in the : : rule parenthesized { \( ( <-[()]> | ) \) } : : The key to balanced delimiters is recursion. A5 gives us convenient : recursion; therefore, it gives us balanced delimiters. That being said, there may well be a builtin rule that refers to the current rule without having to name it. That lets you write anonymous recursive rules, or possibly a generic rule that could have more than one name. Larry
RE: Balanced Matches in Regexps?
Larry Wall: # That being said, there may well be a builtin rule that # refers to the current rule without having to name it. That # lets you write anonymous recursive rules, or possibly a # generic rule that could have more than one name. I suspected as much, but didn't use it to avoid stepping on toes. :^) --Brent Dax <[EMAIL PROTECTED]> @roles=map {"Parrot $_"} qw(embedding regexen Configure) He who fights and runs away wasted valuable running time with the fighting.
Re: Balanced Matches in Regexps? + tr and hashes
On Sat, 2002-08-17 at 14:31, Brent Dax wrote: > Peter Behroozi: > # After reading over Apocalypse 5 one more time, I noticed that > # balanced matches (like capturing nested parenthetical > # comments ((like this))) had been glossed over in the > # rejection of RFC 145. What was not even mentioned in the > > rule parenthesized { \( ( <-[()]> | ) \) } > So that would mean to match nested tables, I would have to write rule nested_tables { [ >> . | ] } or maybe even rule balanced { @_[0] [ . | ] @_[1] }; $html =~ /, )>/; Forgiving lookahead syntax errors on my part, that isn't as bad as I had thought. Thanks for pointing that out. However, since you forced me to read through A5 again, I now have another question :). Since we can now do $string.tr %hash; what happens when the keys of %hash have overlapping ranges by accident or otherwise? Are there any other options than reporting an overlap (hard), auto-sorting the key-value pairs (medium), or not allowing hashes (easy)? Peter Behroozi
FW: CPAN Upload: B/BR/BRENTDAX/Perl6-Parameters-0.03.tar.gz
I've uploaded a new version of my Perl6::Parameters module. This is mostly just a "make it compile" version; its design is out of sync with the current Perl 6 design, a problem I'll resolve in the next version. It should be bouncing around between mirrors right now, so it may be up to a day before your favorite mirror has a copy. Share and enjoy. --Brent Dax <[EMAIL PROTECTED]> @roles=map {"Parrot $_"} qw(embedding regexen Configure) He who fights and runs away wasted valuable running time with the fighting. -Original Message- The uploaded file Perl6-Parameters-0.03.tar.gz has entered CPAN as file: $CPAN/authors/id/B/BR/BRENTDAX/Perl6-Parameters-0.03.tar.gz size: 4414 bytes md5: b73bee5737bf35ac3c0e00ebbf8cd3c8
Re: Balanced Matches in Regexps? + tr and hashes
On 17 Aug 2002, Peter Behroozi wrote: : However, since you forced me to read through A5 again, I now have : another question :). Since we can now do : : $string.tr %hash; : : what happens when the keys of %hash have overlapping ranges by accident : or otherwise? Are there any other options than reporting an overlap : (hard), auto-sorting the key-value pairs (medium), or not allowing : hashes (easy)? Doing tr efficiently generally requires precompilation, so in the case of a hash, the compiled result would be stored as a run-time property. So we can really do whatever processing we want, on the assumption that the hash will change much less frequently than it gets used. Alternatively, we could restrict hashes to single character translations. But under UTF-8 that doesn't guarantee a constant string length (as measured in bytes). But I would guess that hashes would be used for even longer sequences of characters too, so some amount of preprocessing would be desirable to determine if one key was a prefix of another. Maybe it wants to get translated to some sort of trie parser. Really just depends on how much memory we want to throw at it to make it fast. Larry
Sigils, et all
Somewhat random question here: We all know how to alias things in Perl 5. The binding operator allows aliasing in Perl 6, I understand. So, how do we alias grammer rules? Here are my guesses. Rules live in the same namespace as subroutines, so you can use the &. Or possibly (because filehandles are first class objects and formats are phhbbtt) rule1 := rule2 with no sigil. Even if rules don't work like this, I'd like to know if that works for subs. If we think of &sub $scalar @array and %hash as typed references and the sigils as disambiguating *which* reference, then perhaps we use <> as in := We can't. I related question - rule {..} can create an anonymous rule, but how do we create a ref to a named rule? -Erik Is your boss reading your email? Probably Keep your messages private by using Lycos Mail. Sign up today at http://mail.lycos.com