Pugs Bug

4 views
Skip to first unread message

Stevan Little

unread,
Apr 2, 2005, 9:32:12 PM4/2/05
to perl6-c...@perl.org
Autrijus,

I was writing tests for split(<regexp>, <str>) and I stumbled upon this
bug:

pugs -e 'split(rx:perl5//, "not good")'

Will go into an infinite loop. I also tried the empty regexp in a match
on it's own, and it was not a problem.

- Steve

Andrew Savige

unread,
Apr 3, 2005, 1:34:02 AM4/3/05
to Stevan Little, perl6-c...@perl.org

Further to that, I noticed that the somewhat arcane semantics of p5 split
are not honoured by Pugs. Since S29 split is not written yet I'm not sure,
but I expect p6 split will be p5 split compatible. For example, p5 split
retains leading empty fields, but lops trailing ones:

# cat s.pl
my $x = ":a:z:";
my @x = split(":", $x);
for (@x) { print "v='$_'\n" }

# perl -w s.pl
v=''
v='a'
v='z'

# pugs s.pl
v=''
v='a'
v='z'
v=''

The sometimes seemingly arbitrary semantics of p5 split seem to have become
something of a de facto standard, with even Java and .NET following suit
(I *think*, not certain about this and too lazy to check right now).

/-\


Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

Uri Guttman

unread,
Apr 3, 2005, 1:54:58 AM4/3/05
to Andrew Savige, Stevan Little, perl6-c...@perl.org
>>>>> "AS" == Andrew Savige <ajsa...@yahoo.com.au> writes:

AS> The sometimes seemingly arbitrary semantics of p5 split seem to
AS> have become something of a de facto standard, with even Java and
AS> .NET following suit (I *think*, not certain about this and too
AS> lazy to check right now).

just remember perl derived the semantics from awk and/or sed.

uri

--
Uri Guttman ------ u...@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org

Autrijus Tang

unread,
Apr 3, 2005, 5:28:44 AM4/3/05
to Stevan Little, perl6-c...@perl.org

Fixed, but I have not implemented the full weird awk semantics.
Tests welcome. :-)

Thanks,
/Autrijus/

Larry Wall

unread,
Apr 4, 2005, 1:39:16 PM4/4/05
to perl6-c...@perl.org
On Sun, Apr 03, 2005 at 05:28:44PM +0800, Autrijus Tang wrote:

Don't work too hard on that--we'll probably find some way of making
those semantics explicit, perhaps with a separate function, perhaps
with an optional argument. (Now that builtins are just functions out
in * space, we can probably afford to throw a few more convenience
functions out there for common operations like word splitting and
whitespace trimming. (Specific proposals to p6l please.))

Larry

Reply all
Reply to author
Forward
0 new messages