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
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
Parrot 0.4.11 released
On behalf of the Parrot team, I'm proud to announce Parrot 0.4.11 "Tax Bird." Parrot (http://parrotcode.org/) is a virtual machine aimed at running all dynamic languages. Parrot 0.4.11 can be obtained via CPAN (soon), or follow the download instructions at http://parrotcode.org/source.html. For those who would like to develop on Parrot, or help develop Parrot itself, we recommend using Subversion or SVK on the source code repository to get the latest and best Parrot code. Parrot 0.4.11 News: - Compilers: + IMCC: added documentation for C-based Parrot Calling Conventions, refactorings and bug fixes + PGE: new perl6regex front end reflecting recent S05 syntax changes + PIRC: new prototype PIR parser - Languages: + Updated Lua, PHP ("Plumhead"), BASIC, pynie + Lua implements environment - Design: + PDD15 "Objects" - details added, and draft approved - Documentation: + Added guidelines for PMC documentation - Implementation: + PDD15 implementation is largely complete, including role-based composition, introspection, and C3 method resolution order + new Exporter PMC for importing globals between namespaces + new string utilities for radix conversion + PCCINVOKE and Parrot_PCCINVOKE allow calling using the full Parrot Calling Conventions from PMCs and C code respectively - Build: + Refactorings and improvements in test coverage for 'Configure.pl' - Misc: + many bugfixes, enhancements, and code cleanup + added example subversion config file + extended support for gcc, icc, and other compilers + extended support for Solaris and other platforms Thanks to all our contributors for making this possible, and our sponsors for supporting this project. Enjoy! -- Matt Diephouse
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
> "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 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
[svn:perl6-synopsis] r14377 - doc/trunk/design/syn
Author: larry Date: Tue Apr 17 11:26:03 2007 New Revision: 14377 Modified: doc/trunk/design/syn/S04.pod Log: Neglected to mention that unless also allows binding of its false parameter Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podTue Apr 17 11:26:03 2007 @@ -208,7 +208,8 @@ within the closure you already know whether it evaluated to true or false.) Binding within an C automatically binds the value tested by the previous C or C, which, while known to be -false, might nevertheless be an I value of false. +false, might nevertheless be an I value of false. (By similar +reasoning, an C allows binding of a false parameter.) Conditional statement modifiers work as in Perl 5. So do the implicit conditionals implied by short-circuit operators. Note though that
[svn:perl6-synopsis] r14376 - doc/trunk/design/syn
Author: larry Date: Tue Apr 17 11:22:38 2007 New Revision: 14376 Modified: doc/trunk/design/syn/S04.pod doc/trunk/design/syn/S05.pod Log: Note that unless no longer allows an else Clarification of binding semantics of if, elsif, and else Clarification of C<..>. requested by moritz++ Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podTue Apr 17 11:22:38 2007 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 28 Mar 2007 + Last Modified: 17 Apr 2007 Number: 4 - Version: 56 + Version: 57 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -175,8 +175,8 @@ =head1 Conditional statements -The C and C statements work almost exactly as they do in -Perl 5, except that you may omit the parentheses on the conditional: +The C and C statements work much as they do in +Perl 5. However, you may omit the parentheses on the conditional: if $foo == 123 { ... @@ -192,6 +192,24 @@ branch, the return value is C in item context and C<()> in list context. +The C statement does not allow an C or C in Perl 6. + +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 } + +Note that the value being evaluated for truth and subsequently bound is +not necessarily a value of type Bool. (All normal types in Perl may +be evaluated for truth. In fact, this construct would be relatively +useless if you could bind only boolean values as parameters, since +within the closure you already know whether it evaluated to true +or false.) Binding within an C automatically binds the value +tested by the previous C or C, which, while known to be +false, might nevertheless be an I value of false. + Conditional statement modifiers work as in Perl 5. So do the implicit conditionals implied by short-circuit operators. Note though that the first expression within parens or brackets is parsed as a statement, Modified: doc/trunk/design/syn/S05.pod == --- doc/trunk/design/syn/S05.pod(original) +++ doc/trunk/design/syn/S05.podTue Apr 17 11:22:38 2007 @@ -14,9 +14,9 @@ Maintainer: Patrick Michaud <[EMAIL PROTECTED]> and Larry Wall <[EMAIL PROTECTED]> Date: 24 Jun 2002 - Last Modified: 31 Mar 2007 + Last Modified: 17 Apr 2007 Number: 5 - Version: 56 + Version: 57 This document summarizes Apocalypse 5, which is about the new regex syntax. We now try to call them I rather than "regular @@ -1137,7 +1137,7 @@ =item * A leading C<[> or C<+> indicates an enumerated character class. Ranges -in enumerated character classes are indicated with C<..>. +in enumerated character classes are indicated with "C<..>" rather than "C<->". / <[a..z_]>* / / <+[a..z_]>* /