Re: Return with no expression

2004-08-24 Thread Jonadab the Unsightly One
Alexey Trofimenko [EMAIL PROTECTED] writes: I wanna ask, could be there in perl6 any difficulties with recognizing C:: as part of C... ?? ... :: ... and C:: as module sigil? Does it involve some DWIM? Among other things, the ?? will tip off the parser that it's looking for an expression

Re: Return with no expression

2004-08-24 Thread Brent 'Dax' Royal-Gordon
Aaron Sherman [EMAIL PROTECTED] wrote: I've always thought that particular bit of sugar was rather dangerous. I'd even prefer a longhand: $foo either 0 or split(); The overloading of 'or' there is (IMHO) far more dangerous than the overloading of '::' being discussed in this thread. --

Re: Return with no expression

2004-08-24 Thread Aaron Sherman
Luke Palmer wrote: Aaron Sherman writes: $foo??0::split() ouch! Yeah, seriously. I mean, what a subtle bug! It would take him hours to figure out went wrong! Sarcasm is an ugly thing. One thing that I just thought of that could be intersting: $foo = 'a' or 'b' My thought was that

Re: Return with no expression

2004-08-24 Thread Dave Whipp
Brent 'Dax' Royal-Gordon [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Aaron Sherman [EMAIL PROTECTED] wrote: I've always thought that particular bit of sugar was rather dangerous. I'd even prefer a longhand: $foo either 0 or split(); The overloading of 'or' there is

Re: Return with no expression

2004-08-24 Thread Aaron Sherman
On Tue, 2004-08-24 at 11:50, Dave Whipp wrote: You're assuming that Ceither in a ternary operator. It could be a binary operator, defined as {eval $RHS if $LHS; return $LHS}. For that interpretation, one might choose a different name (e.g. Cimplies). We could actually define ?? as a binary

Re: Return with no expression

2004-08-24 Thread Graham Barr
On 24 Aug 2004, at 22:14, Aaron Sherman wrote: You don't HAVE to use auto-topicalization. You CAN always write it long-hand if you find that confusing: for @words - $word { given ($chars($word) 70) - $toolong { say abbreviate($word) ?? $word;

Re: Return with no expression

2004-08-24 Thread Adam D. Lopresto
On Tue, 24 Aug 2004, Aaron Sherman wrote: On Tue, 2004-08-24 at 11:50, Dave Whipp wrote: You're assuming that Ceither in a ternary operator. It could be a binary operator, defined as {eval $RHS if $LHS; return $LHS}. For that interpretation, one might choose a different name (e.g.

Re: Return with no expression

2004-08-23 Thread Alexey Trofimenko
On Fri, 20 Aug 2004 09:21:02 +0100, Matthew Walton [EMAIL PROTECTED] wrote: On 19 Aug 2004, at 18:04, Luke Palmer wrote: [...] my $num = $param == 0 ?? 0 : rand $param; my $num = $param == 0 ?? 0 :: rand $param; surely? a little off theme.. I wanna ask, could be there in perl6 any

Re: Return with no expression

2004-08-23 Thread Matthew Walton
Alexey Trofimenko wrote: On Fri, 20 Aug 2004 09:21:02 +0100, Matthew Walton [EMAIL PROTECTED] wrote: On 19 Aug 2004, at 18:04, Luke Palmer wrote: [...] my $num = $param == 0 ?? 0 : rand $param; my $num = $param == 0 ?? 0 :: rand $param; surely? a little off theme.. I wanna ask, could be

Re: Return with no expression

2004-08-23 Thread Luke Palmer
Juerd writes: Where :: (in a module name) can be used, an operator could have been used. How is $foo??Bar::Baz::Quux parsed? $foo ?? Bar::Baz::Quux; # error, :: expected Indeed, this is illegal: Bar::Baz :: Quux.new; No whitespace allowed. I hope it's an error, although some

Re: Return with no expression

2004-08-23 Thread Aaron Sherman
Luke Palmer wrote: $foo??split()::0; Ought to be fine Imagine the shock of the first guy who rezlizes he got the logic backwards and bug-fixes it to: $foo??0::split() ouch! I've always thought that particular bit of sugar was rather dangerous. I'd even prefer a longhand: $foo either 0

Re: Return with no expression

2004-08-23 Thread Matt Creenan
I've always thought that particular bit of sugar was rather dangerous. I'd even prefer a longhand: $foo either 0 or split(); to the troublesome double-usage of C:: I think I'd prefer that as well, since it has the advantage of not having to use the evil shift key. Though i don't think it

Re: Return with no expression

2004-08-23 Thread Matt Creenan
I think I'd prefer that as well, since it has the advantage of not having to use the evil shift key. Though i don't think it stands out as much as it should. I hate to reply to my own message, but... How about $foo??split()!!0; for a touch of craziness. Or is !! not usable? Actually, just

Re: Return with no expression

2004-08-23 Thread Luke Palmer
Aaron Sherman writes: Luke Palmer wrote: $foo??split()::0; Ought to be fine Imagine the shock of the first guy who rezlizes he got the logic backwards and bug-fixes it to: $foo??0::split() ouch! Yeah, seriously. I mean, what a subtle bug! It would take him hours to

Re: Return with no expression

2004-08-21 Thread Matthew Walton
Larry Wall wrote: On Fri, Aug 20, 2004 at 09:21:02AM +0100, Matthew Walton wrote: : It would be nice if rand behaved a bit more sanely in Perl 6. I can : understand the reasoning for making rand 0 produce between 0 and 1, but : that doesn't mean I have to like it. What makes you think there was

Re: Return with no expression

2004-08-21 Thread Aaron Sherman
Matthew Walton wrote: Larry Wall wrote: I suspect there's an argument that [0,0) ought to be considered undef (which would conveniently numerify to 0 with an optional warning). In the absence of a paradox value, undef would be fine there I think :-) Too bad we don't have NaRN (Not a Random

Re: Return with no expression

2004-08-20 Thread Matthew Walton
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 19 Aug 2004, at 18:04, Luke Palmer wrote: The one in Perl 5 that stands out most was the cause for the only patch I ever sent to p5p: the rand function. rand $x will give you a uniformly distributed random number in [0, $x) for any $x EXCEPT 0. If

Re: Return with no expression

2004-08-20 Thread Larry Wall
On Fri, Aug 20, 2004 at 09:21:02AM +0100, Matthew Walton wrote: : It would be nice if rand behaved a bit more sanely in Perl 6. I can : understand the reasoning for making rand 0 produce between 0 and 1, but : that doesn't mean I have to like it. What makes you think there was any reasoning

Re: Return with no expression

2004-08-19 Thread Luke Palmer
Matt Diephouse writes: use CGI qw(:standard); my $foo = Bar-new( name = Baz, value = param('baz'), something = 'else' ); See the problem? Yikes, yeah, that seems so innocent. Cparam uses Creturn;. In this example, it's called in list context.

Re: Return with no expression

2004-08-19 Thread Juerd
Matt Diephouse skribis 2004-08-19 9:35 (-0400): But I came across this code at work this week: use CGI qw(:standard); my $foo = Bar-new( name = Baz, value = param('baz'), something = 'else' ); Ouch. You have foo-bar-baz code *at work*? :) See the

Re: Return with no expression

2004-08-19 Thread Matt Diephouse
On Thu, 19 Aug 2004 17:52:18 +0200, Juerd [EMAIL PROTECTED] wrote: Ouch. You have foo-bar-baz code *at work*? :) Unfortunately, some of the code here is much worse than that. In fact, this was anticipated and the doesn't-exist case is explicitly documented as: If the parameter does not

Re: Return with no expression

2004-08-19 Thread Luke Palmer
Matt Diephouse writes: The point that it's documented for Cparam and for Creturn doesn't remove the fact that while this DWIM the majority of the time, it can be the cause of a subtle bug. I'm sure many people don't know about the DWIM behavior. Or aren't actively aware of it. As is the case

Re: Return with no expression

2004-08-19 Thread David Wheeler
On Aug 19, 2004, at 9:41 AM, Matt Diephouse wrote: If the parameter does not exist at all, then param() will return undef in a scalar context, and the empty list in a list context. Sure enough. And I've even read a large percentage of the (unwieldy) CGI.pm docs. But I was using Cparam as

Re: Return with no expression

2004-08-19 Thread David Wheeler
On Aug 19, 2004, at 11:07 AM, Aaron Sherman wrote: First off, in Perl 6, I *think* that that C = will enforce a scalar context (it's a tuple operator, last I recall). W00t! Second, in Perl 5 it should not be hard to identify such situations for warning purposes. C = may be a synonym for C,, but