do BLOCK as inline sub? (was Re: "do BLOCK while COND" and "EXPR while COND")
[email protected] (Uri Guttman) Thu, 31 Aug 2000 16:12:13 -0400
| Newsgroups | perl.perl6.language.flow |
|---|---|
| Message-ID | <[email protected].> |
>>>>> "TC" == Tom Christiansen <[email protected]> writes: TC> It just kinda irks me here: TC> $total += 2 * do { TC> my $count = 0; TC> for $n (@nums) { $count += $n } TC> $count; TC> }; TC> I rather that were: TC> $total += 2 * do { TC> my $count = 0; TC> for $n (@nums) { $count += $n } TC> return $count; TC> }; hmm, why not consider a do block to be an inline sub with no name or arguments and it executes immediately. then it has all the semantics of return so you don't need last. it can return the last expression or use a return statement. you could support next and redo without any major hacking IMO. uri -- Uri Guttman --------- [email protected] ---------- http://www.sysarch.com SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books The Best Search Engine on the Net ---------- http://www.northernlight.com