RFC 199 (v2) Short-circuiting C, C, and C with C

2000-09-07 Thread Perl6 RFC Librarian
(or "Allowing built-in functions to use loop blocks") Reply-To: [EMAIL PROTECTED] This and other RFCs are available on the web at http://dev.perl.org/rfc/ =head1 TITLE Short-circuiting C, C, and C with C (or "Allowing built-in functions to use loop blocks") =head1 VERSION Maintainer: Garr

RFC 79 (v3) The Predefined POD Streams are C, C, and C

2000-09-07 Thread Perl6 RFC Librarian
This and other RFCs are available on the web at http://dev.perl.org/rfc/ =head1 TITLE The Predefined POD Streams are C, C, and C =head1 VERSION Maintainer: John Porter <[EMAIL PROTECTED]> Mailing List: [EMAIL PROTECTED] Date: 9 Aug 2000 Last Modified: 7 Sep 2000 Number: 79 Versio

Re: RFC 195 (v1) Retire chop().

2000-09-07 Thread Damian Conway
> Shoot chop. and chomp. Unless you add unchop and unchomp. C *has* an inverse. Surely you know about the unary postfix C<.$/> operator? Of course, you have to be careful. There's a known bug that the C<.$/> doesn't properly "unchomp" if you've ever used the C<$/&=``> operator. ;-) Damian

Re: RFC 195 (v1) Retire chop().

2000-09-07 Thread David H. Adler
On Fri, Sep 08, 2000 at 02:50:37AM +, Ed Mills wrote: > Shoot chop. and chomp. Unless you add unchop and unchomp. Parity issue. Like > a language with YES and no NO. > > Just kill then both. Although I'm rather fond of symmetry, it's not inherently good. Rather boring if overused. I admit

Re: RFC 195 (v1) Retire chop().

2000-09-07 Thread Tom Christiansen
>Shoot chop. and chomp. Unless you add unchop and unchomp. Parity issue. Like >a language with YES and no NO. By that criterion, you have zillions of other things to kill. >Just kill then both. I don't think this will win us friends. --tom

Re: RFC 195 (v1) Retire chop().

2000-09-07 Thread Ed Mills
Shoot chop. and chomp. Unless you add unchop and unchomp. Parity issue. Like a language with YES and no NO. Just kill then both. >From: Bryan C. Warnock <[EMAIL PROTECTED]> >Reply-To: [EMAIL PROTECTED] >To: Michael G Schwern <[EMAIL PROTECTED]>, [EMAIL PROTECTED] >Subject: Re: RFC 195 (v1) Ret

Re: $a in @b

2000-09-07 Thread skud
Does this discussion pertain to a particular RFC? If so, could the RFC number please be quoted in the subject? If it's not already RFC'd, who will volunteer to do it? K. -- Kirrily Robert -- <[EMAIL PROTECTED]> -- http://netizen.com.au/ Open Source development, consulting and solutions Level

Re: RFC 195 (v1) Retire chop().

2000-09-07 Thread Bryan C . Warnock
On Thu, 07 Sep 2000, Michael G Schwern wrote: > Awww, does this mean we won't be seeing chip() and chimp() in Perl 6? Someone, (and I've lost who, exactly) was interested in taking those off my hands for a String::Utils module. I believe it was quite clear, however, that my root-and-measure-deri

Re: $a in @b

2000-09-07 Thread Steve Fink
Damian Conway wrote: > >> Both are pretty much the same. Combining them, I'd say that exceptions >> should remain exceptional. > > I'd say short-circuiting a vector operation was exceptional enough. :-) I'd say it's exceptional sometimes, and very ordinary other times, and I'd prefer to

Re: $a in @b

2000-09-07 Thread Damian Conway
> Both are pretty much the same. Combining them, I'd say that exceptions > should remain exceptional. I'd say short-circuiting a vector operation was exceptional enough. :-) > Counterproposal: grep, map, etc. define two implicit magic labels > 'ACCEPT' and 'REJECT' that behave in th

Re: $a in @b

2000-09-07 Thread Tom Christiansen
>Counterproposal: grep, map, etc. define two implicit magic labels >'ACCEPT' and 'REJECT' that behave in the expected way, so you use >($first_small) = grep { ($_ < 2) and last ACCEPT } @list. Reminds me of "next LINE" in perl -p or perl -n. --tom

Re: $a in @b

2000-09-07 Thread Steve Fink
Damian Conway wrote: > >> > I would propose that the C operation should short-circuit if the >> > block throws an exception, with the value of the expection determining >> > whether the final invocation of the block should accept the element it >> > was filtering: >> >> Ot

Re: RFC 195 (v1) Retire chop().

2000-09-07 Thread Damian Conway
> > 'Pends on whether you modulate them. > > KCHP 1570 on your AM dial! Aw, not *another* one of those easy-listening Californian motor cop stations! Damian

Re: RFC 195 (v1) Retire chop().

2000-09-07 Thread Michael G Schwern
On Thu, Sep 07, 2000 at 06:48:35PM -0600, Tom Christiansen wrote: > >Awww, does this mean we won't be seeing chip() and chimp() in Perl 6? > > 'Pends on whether you modulate them. KCHP 1570 on your AM dial! -- Michael G Schwern http://www.pobox.com/~schwern/ [EMAIL PROTECTED] Just A

Re: RFC 195 (v1) Retire chop().

2000-09-07 Thread Tom Christiansen
>On Wed, Sep 06, 2000 at 06:39:38PM -, Perl6 RFC Librarian wrote: >> =head1 TITLE >> >> Retire chop(). >Awww, does this mean we won't be seeing chip() and chimp() in Perl 6? 'Pends on whether you modulate them. --tom

Re: $a in @b

2000-09-07 Thread Damian Conway
> I don't think C should be able to eat unintentional exceptions. > Perhaps it could short-circuit if the exception is 1 or false, as > opposed to true or false? No objection here. Damian

Re: RFC 195 (v1) Retire chop().

2000-09-07 Thread Michael G Schwern
On Wed, Sep 06, 2000 at 06:39:38PM -, Perl6 RFC Librarian wrote: > =head1 TITLE > > Retire chop(). Awww, does this mean we won't be seeing chip() and chimp() in Perl 6? -- Michael G Schwern http://www.pobox.com/~schwern/ [EMAIL PROTECTED] Just Another Stupid Consultant

Re: $a in @b

2000-09-07 Thread Jarkko Hietaniemi
> Exactly the sort of chicanery grep/last is meant to avoid. So the question > becomes, how do we crowbar "last" in without altering the returned value in > C blocks. I'm for putting it after a comma. Which matches the syntax of > John Porter's proposal about internally converting the block to a

Re: $a in @b

2000-09-07 Thread Damien Neil
On Fri, Sep 08, 2000 at 09:45:54AM +1100, Damian Conway wrote: > I would propose that the C operation should short-circuit if the > block throws an exception, with the value of the expection determining > whether the final invocation of the block should accept the element it > was filtering: I do

Re: $a in @b

2000-09-07 Thread David L. Nicol
Damian Conway wrote: > A C such as: > > @array = grep BLOCK LIST > > is equivalent to: > > @tmp = (); > foreach (LIST) { push @tmp, $_ if do BLOCK } > @array = @tmp; > > That similarity would not change in any way under the proposal > (except to be made stronge

Re: $a in @b

2000-09-07 Thread David L. Nicol
John Porter wrote: > heh. for a normal sub, > > sub foo { > return( 42 ); > } > > finds OMWTDI as > > sub foo { > 42; > last; > } > > Somehow, this seems like very natural perl to me. > > -- > John Porter I'd

Re: RFC 199 (v1) Short-circuiting C and C with C

2000-09-07 Thread David L. Nicol
The "assignment from a lazy list" section of RFC 123 suggests a system for requesting the first however many items out of a map or grep by making it lazy and then assigning it to an array of that size. "last" is more flexible, if you are looking for a condition more complex than the first one,

Re: $a in @b

2000-09-07 Thread Damian Conway
> > I would propose that the C operation should short-circuit if the > > block throws an exception, with the value of the expection determining > > whether the final invocation of the block should accept the element it > > was filtering: > > Otherwise nice but until now die() ha

Re: $a in @b

2000-09-07 Thread Jarkko Hietaniemi
> I would propose that the C operation should short-circuit if the > block throws an exception, with the value of the expection determining > whether the final invocation of the block should accept the element it > was filtering: Otherwise nice but until now die() has been a serious thing, now it

Re: $a in @b

2000-09-07 Thread Damian Conway
> If one were looking for the first matching item, last would work: > >grep { /pat/ and last } @foo ># return()s the value of $_=~/pat/, which will be true Huh? I can't see how that could work unless you change the existing semantics of C and C. Let's take a step back and an

Re: RFC 181 (v1) Formats out of core / New format syntax

2000-09-07 Thread David L. Nicol
Johan Vromans wrote: > my $file_format = qf( > @<: @ > $name, $ssn > ); > > Now, $file_format would be a Format object (compare this with qr//, > that produces a Regex object). or the proposed qs// which would produce a packed structure definition

Re: $a in @b

2000-09-07 Thread John Porter
Damian Conway wrote: > > The expression C<1 and last> does *not* evaluate to true -- it does not > evaluate to *anything*. So the C is terminated by the C > without the block having ever evaluated true. So no element of LIST is > ever "passed through". So the C evaluates to zero. Right. Well, pe

Re: $a in @b

2000-09-07 Thread John Porter
Jarkko Hietaniemi wrote: > > How about using 'return', then? That could, ahem, return both true and > false values. Hmm. I think it boils down to the fact that we'd like a grep block to have characteristics of both a subroutine and a true loop block. Here's a proposal which would mostly elim

Re: we already have barewords as variables if we want them Re: the C JIT

2000-09-07 Thread David L. Nicol
John Porter wrote: > > David L. Nicol wrote: > > > > A bareword inside doublequotes is not interpreted, in Perl or C. > > No; a "bareword" in quotes (any kind) is not a bareword. > > -- > John Porter huh? -- David Nicol 816.235.1187 [EMAIL PROTECTED]

Re: $a in @b

2000-09-07 Thread Jarkko Hietaniemi
On Thu, Sep 07, 2000 at 10:05:58PM +0200, Bart Lateur wrote: > On Fri, 8 Sep 2000 05:59:02 +1100 (EST), Damian Conway wrote: > > >But it makes "short-circuit as soon as C > >lets through a specific value" ugly: > > > >my $seen; > >$has_odd_elem = grep { $seen && last; $_%2 && ++$s

Re: $a in @b

2000-09-07 Thread Bart Lateur
On Fri, 8 Sep 2000 05:59:02 +1100 (EST), Damian Conway wrote: >But it makes "short-circuit as soon as C >lets through a specific value" ugly: > >my $seen; >$has_odd_elem = grep { $seen && last; $_%2 && ++$seen } @numbers; Not just ugly. Useless. -- Bart.

Re: $a in @b

2000-09-07 Thread Damian Conway
John wrote: > > I don't know how grep works internally. I don't know if grep pushes > > elements into @a one at a time, or if it returns a finished list of > > elements which pass the conditional block. If it is the latter as I > > assume, a short-circuited grep would return a list o

RE: $a in @b

2000-09-07 Thread Damian Conway
Garrett wrote: > It almost feels like grep could have been written like this (in > another life): @a = grep (@b) { $_ > 2 or last } http://www.csse.monash.edu.au/~damian/TPC/2000/Romana/perligata.html ;-) > While I'm at it, I'm curious as to why: > > $a = 2; > @b = (1,

Re: $a in @b

2000-09-07 Thread Damian Conway
Bart wrote: > >The last operator doesn't return anything does it? It immediately > >exits the loop/block in question. This is correct. > But then, what is the value that would be returned to grep()? If you use > 0 as the last value evaluated inside the block, grep() would return an

Re: $a in @b

2000-09-07 Thread John Porter
Garrett Goebel wrote: > > Let's see if I've got this straight. To paraphrase Damian's > RFC 77 for reduce: > > If a C's block were terminated by a call to C, > grep immediately returns the last block value (i.e. C > on the first block call, $_[0] otherwise). Or maybe that's @_ > otherwise...

RE: $a in @b

2000-09-07 Thread Garrett Goebel
From: Bart Lateur [mailto:[EMAIL PROTECTED]] > > On Wed, 6 Sep 2000 16:24:41 -0500 , Garrett Goebel wrote: > >> > grep { $a > $_ and last } @b) > >> > >> So "last" should return true, or what? > > > >The last operator doesn't return anything does it? It > >immediately exits the loop/block

Re: the C JIT

2000-09-07 Thread David L. Nicol
"Myers, Dirk" wrote: > $mode = 0755 ; > $file = "Foobar" ; > > #include > #include > > chmod($mode, $file) ; > > Which chmod gets called, perl or C? What are the rules for figuring this > out? > > Dirk Following the documentation at http://www.pe

Re: $a in @b

2000-09-07 Thread Bart Lateur
On Wed, 6 Sep 2000 16:24:41 -0500 , Garrett Goebel wrote: >> > grep { $a > $_ and last } @b) >> >> So "last" should return true, or what? > >The last operator doesn't return anything does it? It immediately exits the >loop/block in question. But then, what is the value that would be retur

Re: RFC 103 (v1) Fix print "$r->func" and $pkg::$var precedence

2000-09-07 Thread Nathan Wiger
Bart Lateur wrote: > > >Currently, attempting to use objects in a string context > >yields garbage: > > > > print "r is $r->func"; # "OBJ=HASH(0xef958)->func" > > print "r is ", $r->func; # works, but clumsy > > Does this expand to regexes? > > /$foo->blah/ > > To be conseque

Re: RFC 103 (v1) Fix print "$r->func" and $pkg::$var precedence

2000-09-07 Thread Bart Lateur
On 14 Aug 2000 23:29:38 -, Perl6 RFC Librarian wrote: >Currently, attempting to use objects in a string context >yields garbage: > > print "r is $r->func"; # "OBJ=HASH(0xef958)->func" > print "r is ", $r->func; # works, but clumsy I've not seen any comments on this RFC yet. But thi

RE: $a in @b

2000-09-07 Thread Garrett Goebel
From: Damian Conway [mailto:[EMAIL PROTECTED]] > > From: Garrett Goebel > > @passed = grep { 2 > $_ and last } (1, 2, 3, 2, 1); > > > > would leave > > @passed = (1, 2) > > I believe the above would leave: > > @passed = (); > > since on the first call to the block 2 > 1 is true, so th

sort syntax

2000-09-07 Thread H . Merijn Brand
Having no time to write and/or maintain RFC's, I'll toss this up in the air and see what happens. Abigail has posted sorting benchmarks for 5.6.0 to 5.7.0 on clp.misc, and I've extended that being curious to performance loss for anonymous blocks and named subroutines sub Xcmp { $a cmp $b