Re: Change ($one, $two)= behavior for optimization? (was Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar))

2000-09-04 Thread Peter Scott
At 11:48 AM 9/3/00 +1100, Damian Conway wrote: Ever consider then having ($a, $b, $c) = FH; or @a[4,1,5] = FH; only read three lines? I think this is a superb idea, and look forward to someone's RFC'ing it. I like it too. Anyone working on the RFC? I

Re: Change ($one, $two)= behavior for optimization? (was Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar))

2000-09-04 Thread Peter Scott
At 10:52 AM 9/4/00 -0600, Nathan Torkington wrote: Peter Scott writes: ($a, $b, $c) = FH; or @a[4,1,5] = FH; only read three lines? I think this is a superb idea, and look forward to someone's RFC'ing it. Should be part of the want() context. It is. I

Re: Change ($one, $two)= behavior for optimization? (was Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar))

2000-09-04 Thread Nathan Wiger
Tom Christiansen wrote: Ever consider then having ($a, $b, $c) = FH; or @a[4,1,5] = FH; only read three lines? I mean, how many if any builtins would it make sense to make aware of this, and do something "different"? Personally, I think this would be really cool; stuff like

Re: Change ($one, $two)= behavior for optimization? (was Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar))

2000-09-04 Thread Jeremy Howard
Nathan Wiger wrote: Tom Christiansen wrote: Ever consider then having ($a, $b, $c) = FH; or @a[4,1,5] = FH; only read three lines? I mean, how many if any builtins would it make sense to make aware of this, and do something "different"? Personally, I think this would

Re: Change ($one, $two)= behavior for optimization? (was Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar))

2000-09-04 Thread Nathan Wiger
Jeremy Howard wrote: The problem with making these builtins respect the number of return values context in want() is that, as Nate mentions, the expressions may have side-effects that are desired for the whole list. An alternative approach is to make these builtins respect lazy(), as

Re: Change ($one, $two)= behavior for optimization? (was Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar))

2000-09-04 Thread Damian Conway
Should be part of the want() context. It is. I interpreted Damian's remark to mean that it would be good if readline() took advantage of it, and that should be RFC'ed. That's indeed precisely what I meant. In fact, all list-returning built-ins ought to be optimized this way.

Re: Change ($one, $two)= behavior for optimization? (was Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar))

2000-09-02 Thread Jeremy Howard
Tom Hughes wrote: For example, in Perl you have for a long time been able to do this: ($one, $two) = grep /$pat/, @data; However, what currently happens is grep goes to completion, then discards possibly huge amounts of data just to return the first two matches. For example, if

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-09-02 Thread Randal L. Schwartz
"Tom" == Tom Christiansen [EMAIL PROTECTED] writes: Tom Wherever you think you need one of these, try to think again. Either Tom it's already in list context, in which case it's silly to put in Tom the list thing, or else there's always a better way to accomplish Tom whatever you're trying to

Re: Change ($one, $two)= behavior for optimization? (was Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar))

2000-09-02 Thread Damian Conway
Here is my suggestion: What if other functions were able to backtrace context and determine how many arguments to return just like split can? I have an RFC on that: RFC 21: Replace Cwantarray with a generic Cwant function Cwant takes a list of strings that describe

Re: Change ($one, $two)= behavior for optimization? (was Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar))

2000-09-02 Thread Tom Christiansen
Here is my suggestion: What if other functions were able to backtrace context and determine how many arguments to return just like split can? I have an RFC on that: RFC 21: Replace Cwantarray with a generic Cwant function Cwant takes a list of strings that describe

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-09-01 Thread Bart Lateur
On Fri, 1 Sep 2000 13:25:07 +1100 (EST), Damian Conway wrote: More than anything I think the inability to write Csub list DWIMishly argues that we need it built-in. But we also need a *very* careful design of the semantics. Well, except that it isn't clear which DWIM you want. Does DWIM mean,

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-09-01 Thread John Porter
Bart Lateur wrote: $\ = "\n"; print $a = () = qw(a b c); -- 3 All those who expected that the list would be evaluated in array (not list!) context, raise your hands. this illustrates why the whole subject is, or can be, so confusing. That qw() list was NOT evaluated in

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-09-01 Thread Bart Lateur
On Fri, 01 Sep 2000 07:30:54 -0600, Tom Christiansen wrote: % man perldata List assignment in a scalar context returns the number of elements produced by the expression on the right side of the assignment: $x = (($foo,$bar) = (3,2,1)); # set $x to 3,

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-09-01 Thread Steve Fink
for reality here. That should be written more like: 1 while FH; $burp = $.; or even: for ($burp = 0; my $line = FH; $burp++) {} I'd go for my $burp = 0; $burp++ while FH; This proposal should be dropped. I read your message and agree. Not that I liked the

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-09-01 Thread Graham Barr
On Fri, Sep 01, 2000 at 11:23:16AM -0700, Steve Fink wrote: I read your message and agree. Not that I liked the idea that much even before considering the ramifications. But do you agree that even seasoned perlers have trouble anticipating how a list/array is going to be converted to a

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-09-01 Thread Nathan Wiger
Tom Christiansen wrote: First off, thanks for taking the time to present such a thorough document. Well-reasoned arguments is exactly what the Perl 6 project needs, IMO. I read this early last night, and have been postulating on it ever since. In the process of trying what feels like 100's of

Change ($one, $two)= behavior for optimization? (was Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar))

2000-09-01 Thread Nathan Wiger
Tom Christiansen wrote: % man perlfunc ... When assigning to a list, if LIMIT is omitted, Perl supplies a LIMIT one larger than the number of variables in the list, to avoid unnecessary work. As usual I picked a bad example. And I did read the perlfunc manpage, but

Re: Change ($one, $two)= behavior for optimization? (was Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar))

2000-09-01 Thread Tom Christiansen
Let me shift gears and instead ask whether anyone thinks this: $y = ($first, $second) = grep /$pat/, @data; Returning "5" has any value? If you're going to do this, it seems like you'd want the number that were really returned (since scalar grep will give you the total number found

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-08-31 Thread Bart Lateur
On Fri, 1 Sep 2000 07:27:24 +1100 (EST), Damian Conway wrote: And has anyone pointed out that Clist is just: sub list {@_} Um no. I would expect it to be sub list { @_[0..$#_] } It's too early in the morning. The subtlety here escapes me. It's the

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-08-31 Thread Peter Scott
At 11:46 PM 8/31/00 +0200, Bart Lateur wrote: On Fri, 1 Sep 2000 07:27:24 +1100 (EST), Damian Conway wrote: And has anyone pointed out that Clist is just: sub list {@_} Um no. I would expect it to be sub list { @_[0..$#_] } It's too early in the morning.

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-08-31 Thread Damian Conway
This is the kind of thing that keeps Perl instructors in business... And Perl out of businesses :-( More than anything I think the inability to write Csub list DWIMishly argues that we need it built-in. But we also need a *very* careful design of the semantics. Damian

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-08-31 Thread Tom Christiansen
This is the kind of thing that keeps Perl instructors in business... And Perl out of businesses :-( More than anything I think the inability to write Csub list DWIMishly argues that we need it built-in. But we also need a *very* careful design of the semantics. I'd like to see from this

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-08-30 Thread skud
(yes, I'm in an RFC-commenting mood today...) On Wed, Aug 30, 2000 at 02:22:31AM -, Perl6 RFC Librarian wrote: Add Clist keyword to force list context (like Cscalar) Makes sense to me. Does it connect in any way with Damian's generic want() function? K. -- Kirrily Robert -- [EMAIL

Re: RFC 175 (v1) Add Clist keyword to force list context (like Cscalar)

2000-08-30 Thread Damian Conway
On Wed, Aug 30, 2000 at 02:22:31AM -, Perl6 RFC Librarian wrote: Add Clist keyword to force list context (like Cscalar) Makes sense to me. Does it connect in any way with Damian's generic want() function? Only in that it would explicitly cause Cwant 'LIST' to return