Re: [svn:perl6-synopsis] r14376 - doc/trunk/design/syn
On 4/24/07, Larry Wall [EMAIL PROTECTED] wrote: On Tue, Apr 24, 2007 at 06:45:12PM -0400, Charles Bailey wrote: : On 4/17/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: : Note that unless no longer allows an else : It's probably that I'm just having another day where skull brain, but I'm : not sure I see the benefit to the language here. : : I think of unless as an alternate spelling for if not, so it seems : natural that it be possible to follow it with an else. I'll grant that : the (common) idiomatic usage of unless doesn't include an else, but that : seems more an argument not to use an else rather than to forbid it. It's : a bit like saying one can continue after a while but not an until. : : Is there a parsing advantage that I've missed, or does it disambiguate some : other construct? Yes, it's slightly easier to parse this way, and yes, it bugs me that unless/else is not English, but mostly I changed it as a not-so-gentle prod towards refactoring, based on the notion that if you have to install a guard on a storage location being false, you've probably got the scope of the storage location wrong. And even if not, there are several other ways to write it, at least one of which will be generally more readable to other people. I freely admit that it's less orthogonal and that I'm being high-handed. :) For situations such as this we have Rule One. But I think I'd still ask you to reconsider, in a low-priority thread somewhere. My sense is that the driving consideration is more a use case than an intrinsic element of language structure (to the extent that the two are separable), and would have a more natural home in a pragma like Design::BestPractice (or Lingua::Franca or Wheels::Training or Lingua::Fascist, depending on one's point of view). Maybe I'm just thinking too neutrally of unless === if not, rather than unless === if shouldn't be. Either way, it's a pretty minor point -- certainly nothing as mind-bending as a good JAPH or with the scary security implications of parens-specify-an-executable-block, so 'nuff said. -- Regards, Charles Bailey Lists: bailey _dot_ charles _at_ gmail _dot_ com Other: bailey _at_ newman _dot_ upenn _dot_ edu
Re: [svn:perl6-synopsis] r14376 - doc/trunk/design/syn
On 4/17/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Note that unless no longer allows an else It's probably that I'm just having another day where skull brain, but I'm not sure I see the benefit to the language here. I think of unless as an alternate spelling for if not, so it seems natural that it be possible to follow it with an else. I'll grant that the (common) idiomatic usage of unless doesn't include an else, but that seems more an argument not to use an else rather than to forbid it. It's a bit like saying one can continue after a while but not an until. Is there a parsing advantage that I've missed, or does it disambiguate some other construct? -- Regards, Charles Bailey Lists: bailey _dot_ charles _at_ gmail _dot_ com Other: bailey _at_ newman _dot_ upenn _dot_ edu
Re: [svn:perl6-synopsis] r14376 - doc/trunk/design/syn
On Tue, Apr 24, 2007 at 06:45:12PM -0400, Charles Bailey wrote: : On 4/17/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: : Note that unless no longer allows an else : It's probably that I'm just having another day where skull brain, but I'm : not sure I see the benefit to the language here. : : I think of unless as an alternate spelling for if not, so it seems : natural that it be possible to follow it with an else. I'll grant that : the (common) idiomatic usage of unless doesn't include an else, but that : seems more an argument not to use an else rather than to forbid it. It's : a bit like saying one can continue after a while but not an until. : : Is there a parsing advantage that I've missed, or does it disambiguate some : other construct? Yes, it's slightly easier to parse this way, and yes, it bugs me that unless/else is not English, but mostly I changed it as a not-so-gentle prod towards refactoring, based on the notion that if you have to install a guard on a storage location being false, you've probably got the scope of the storage location wrong. And even if not, there are several other ways to write it, at least one of which will be generally more readable to other people. I freely admit that it's less orthogonal and that I'm being high-handed. :) Larry
Re: [svn:perl6-synopsis] r14376 - doc/trunk/design/syn
On 4/17/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Note that unless no longer allows an else Hmm, that's interesting. I don't _think_ I'm opposed, but maybe I am. The main case that I can see this limiting me is where I like to put my error conditions at the end of my code, out of the way, like so: unless $.something { $.something = UsefulData.new; } else { die Something exists!; } I don't want to switch the order of those blocks, and switching the condition to if !$.something defeats the whole purpose of unless. Luke
Re: [svn:perl6-synopsis] r14376 - doc/trunk/design/syn
LP == Luke Palmer [EMAIL PROTECTED] writes: LP On 4/17/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Note that unless no longer allows an else LP Hmm, that's interesting. I don't _think_ I'm opposed, but maybe I am. LP The main case that I can see this limiting me is where I like to put LP my error conditions at the end of my code, out of the way, like so: LP unless $.something { LP $.something = UsefulData.new; LP } LP else { LP die Something exists!; LP } LP I don't want to switch the order of those blocks, and switching the LP condition to if !$.something defeats the whole purpose of unless. in perl5 i like to get the quick stuff like next/last/die out of the way. it saves a block, indents and else clauses. something like this in p6 (just your code edited): die Something exists! if $.something ; $.something = UsefulData.new; i don't like unnecessary blocks and indents if i can help it. unless with else is very confusing and i never used that. i try to keep my unless clauses to be very simple. anything complex and i revert to if. uri -- Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com --Perl Consulting, Stem Development, Systems Architecture, Design and Coding- Search or Offer Perl Jobs http://jobs.perl.org
Re: [svn:perl6-synopsis] r14376 - doc/trunk/design/syn
On Tue, Apr 17, 2007 at 11:22:39AM -0700, [EMAIL PROTECTED] wrote: Note that unless no longer allows an else I'm sorry to see this. This is one item from PBP that I don't really agree with. Personally, I find I am at least as likely to make mistakes about the double negative in if (!cond) ... else as I am for unless (cond) ... else . Since that tends to be a minority viewpoint, I only use unless/else for code that will not be maintained by anyone other than me; but for my own code I'd rather keep the (to me) better readability. --
Re: [svn:perl6-synopsis] r14376 - doc/trunk/design/syn
[EMAIL PROTECTED] wrote: + +The value of the conditional expression may be optionally bound to +a closure parameter: + +iftesta() - $a { say $a } +elsif testb() - $b { say $b } +else - $b { say $b } I'd prefer it if the result of a test in an if or elsif were usable in all subsequent elsif or else statements in the same if .. elsif .. else clause, so you could do something like if testa() - $a {say $a is true} elsif testb() - $b say {$a is false and $b is true} else say {Neither $a nor $b is true} Joe Gottman
Re: [svn:perl6-synopsis] r14376 - doc/trunk/design/syn
On Tue, Apr 17, 2007 at 07:34:38PM -0400, Joe Gottman wrote: : [EMAIL PROTECTED] wrote: : + : +The value of the conditional expression may be optionally bound to : +a closure parameter: : + : +iftesta() - $a { say $a } : +elsif testb() - $b { say $b } : +else - $b { say $b } : : I'd prefer it if the result of a test in an if or elsif were usable in : all subsequent elsif or else statements in the same if .. elsif .. else : clause, so you could do something like : : if testa() - $a {say $a is true} : elsif testb() - $b say {$a is false and $b is true} : else say {Neither $a nor $b is true} Sorry, that sort of P5ish chicanery with implicitly propagated scopes violates the simplified rules of scoping in P6. If you really want that, you'll have to say: if my $a = testa(){ say $a is true} elsif my $b = testb() { say $a is false and $b is true} else { say Neither $a nor $b is true} and live with the fact that $a and $b are also visible after the construct. Larry