Re: RFC 84 (v1) Replace => (stringifying comma) with =>
At 05:59 PM 8/10/00 -0700, Glenn Linderman wrote: >Perl6 RFC Librarian wrote: > > > The => operator would cease to be a > > first-argument-stringifying comma operator > >I find nothing in the documentation that suggests that => is anything >other than a >plain comma operator, yet you call it a "first-argument-stringifying comma >operator". In fact, the documentation explicitly claims "=>" is a synonym >of "," >(see perldata). > >So I'm curious where you get this from, and what you mean by it, and >whether it is >relevant to this RFC. Camel, 2e, page 50 : "The => operator is just a synonym for a comma, but it's more visually distinctive, and it also quotes any bare identifiers to the left of it..." --- Mark Cogan[EMAIL PROTECTED] +1-520-881-8101 ArtToday www.arttoday.com
Re: RFC 104 (v1) Backtracking
At 05:47 PM 8/15/00 -0600, Nathan Torkington wrote: >Jeremy Howard writes: > > @result = @a || @b; > > > > Which applies '||' component-wise to elements of @a and @b, placing the > > result in @result. > >*Ptui* That's not how *I* want || to behave on lists/arrays. > >I want > @result = @a || @b; >to be like: > (@result = @a) or (@result = @b); > >That's what all my students keep expecting it to mean. Seconded. It seems obvious that @a should be the whole array @a, not an iteration over its elements. If I want to iterate over @a, I should have to do so explicitly, with a for() or map(). --- Mark Cogan[EMAIL PROTECTED] +1-520-881-8101 ArtToday www.arttoday.com
Re: RFC 104 (v1) Backtracking
At 12:39 PM 8/16/00 +1000, Jeremy Howard wrote: >Mark Cogan wrote: > > At 05:47 PM 8/15/00 -0600, Nathan Torkington wrote: > > >Jeremy Howard writes: > > > > @result = @a || @b; > > > > > > > > Which applies '||' component-wise to elements of @a and @b, placing >the > > > > result in @result. > > > > > >*Ptui* That's not how *I* want || to behave on lists/arrays. > > > > > >I want > > > @result = @a || @b; > > >to be like: > > > (@result = @a) or (@result = @b); > > > > > >That's what all my students keep expecting it to mean. > > > > Seconded. > > > > It seems obvious that @a should be the whole array @a, not an iteration > > over its elements. If I want to iterate over @a, I should have to do so > > explicitly, with a for() or map(). > >It seems obvious that @a should be the whole array @a, not the size of the >array. If I want to check the size of @a, I should have to do so explicitly, >with scalar or $#. > >This is non-obvious if you think that || is a flow control statement, so >think about * for a moment: > > @c = @b * @a; But, to me at least, arrays aren't something you multiply. Multiplication applies to numbers (scalars), and returns a scalar, so when you see @c = @b * @a it should be clear that something funny is going on. And, really, what is wrong with: @c = map {$a[$_] * $b[$_]} (0..$#a); ? (or, for that matter: push @c, $a[$_] * $b[$_] for (0..$#a); ) in both cases it's clear that you're iterating over the elemnts in the array. >It's pretty clear what working on 'the whole array' means here, I think. I disagree. In particular, think of it from the point of view of someone who hasn't studied computer science. What should: @a = defined @a; return? >Treating || as a special case is asking for trouble. If you want a flow >control statement, use one: > > @result = @b unless @result = @a; || may be a suboptimal example, but I think the idea that a @-variable without an iteration function refers to the array as a whole, and not its elements is an intuitive one, and having array iteration magically happen when you're not looking is dangerous. --- Mark Cogan[EMAIL PROTECTED] +1-520-881-8101 ArtToday www.arttoday.com
Re: RFC 104 (v1) Backtracking
At 11:11 PM 8/15/00 -0400, Chaim Frenkel wrote: >You are missing the beauty of vector/matrix operations. No, I'm not; I'm opining that the vast majority of Perl users don't need to do vector/matrix ops, and that they don't belong in the core. >The math folks >really would like to be able to describe the operation wanted and have >perl do the optimization. Then maybe they should use a dedicate math extension to Perl, like PDL. >Would adding another character be helpful > > @result = @a x|| @b? > > @result = @a ||| @b? > >or perhaps a modifier? > > @result = @a || @b forall; > >(Blech, that just doesn read right.) Perhaps we just need a two-list map, which aliases $a and $b like sort(): @result = map {$a || $b} @a,@b; ------- Mark Cogan[EMAIL PROTECTED] +1-520-881-8101 ArtToday www.arttoday.com
Re: RFC 104 (v1) Backtracking
At 11:43 PM 8/15/00 -0400, Chaim Frenkel wrote: > >>>>> "MC" == Mark Cogan <[EMAIL PROTECTED]> writes: > >MC> What should: >MC> @a = defined @a; >MC> return? > >Counter example:@a = \($a, $b, $c); I guess I'm missing the point; how is this different from @a = [$a,$b,$c]; which works to be the same as push @a, [$a,$b,$c]; ? [] >MC> || may be a suboptimal example, but I think the idea that a @-variable >MC> without an iteration function refers to the array as a whole, and not its >MC> elements is an intuitive one, and having array iteration magically happen >MC> when you're not looking is dangerous. > >Not unless you are coming from a math background or are an old basic >programmer, and would like to have matrix operations built in. But we're trying to decide what is best for perl as a whole, not just what is good for math people who use perl. I don't think that the requirement that a relatively small portion of the user base put : use magical_array_iteration; at the top of their code is too outre. (and, for that matter, it might be nice to have an environment variable that implicitly sets -M command line options in the same way that PER5LIB sets -I. That way, math types can just set their perls to preload all the modules they want.) --- Mark Cogan[EMAIL PROTECTED] +1-520-881-8101 ArtToday www.arttoday.com
Re: RFC 104 (v1) Backtracking
At 11:05 PM 8/15/00 -0500, Jonathan Scott Duff wrote: >On Tue, Aug 15, 2000 at 08:59:25PM -0700, Mark Cogan wrote: > > At 11:43 PM 8/15/00 -0400, Chaim Frenkel wrote: > > >Counter example:@a = \($a, $b, $c); > > > > I guess I'm missing the point; how is this different from > > > > @a = [$a,$b,$c]; > >Well, I've lost the point of this thread, but > > @a = \($a, $b, $c); > >is equivalent to > > @a = (\$a, \$b, \$c); > >rather than what you wrote. Ah, so it is. I'd argue that that's broken and should be handled with map or for. --- Mark Cogan[EMAIL PROTECTED] +1-520-881-8101 ArtToday www.arttoday.com
Re: RFC 143 (v1) Case ignoring eq and cmp operators
At 02:09 PM 8/24/00 -0400, John Porter wrote: >Markus Peter wrote: > > > > Another possibility would be to use cmpi and eqi > >Actually, all we need is cmpi, since eqi is just !cmpi. >(And eq is !cmp.) Nope. Read the manual. --- Mark Cogan[EMAIL PROTECTED] +1-520-881-8101 ArtToday www.arttoday.com