Re: Fw: perl6 operator precedence table
On Thu, 26 Sep 2002, Joe Gottman wrote: : Apocalypse 4 mentions unary '?' . Since this is used to force boolean : context, I would assume that it has the same precedence as unary '+' and : '_' which force numeric and string context respectively. By the way, has : anyone come up with a use for binary '?' yet? More likely to be a postfix operator. Maybe it even means the same thing: if ?foo() {...} if foo()? {...} I've always wondered what the ! postfix operator means. The mathematicians think they know. :-) There's this basic rule that says you can't have an operator for both binary and postfix, since it's expecting an operator in either case, rather than a term (which is how we recognize prefix operators). The one exception I can think of is that we might allow .. as a postfix operator, but only if followed by a right bracket. That would let us say @a[0..] rather than @a[0..Inf] But that's a special case. Larry
Re: Fw: perl6 operator precedence table
On Tue, Oct 08, 2002 at 06:07:09PM -0700, Larry Wall wrote: > There's this basic rule that says you can't have an operator for both binary > and postfix, since it's expecting an operator in either case, rather than a > term (which is how we recognize prefix operators). The one exception I can > think of is that we might allow .. as a postfix operator, but only if followed > by a right bracket. That would let us say > > @a[0..] > > rather than > > @a[0..Inf] > > But that's a special case. Would that mean that three other special cases of postfix .. might exist? 0..; # useful for return 0..; (0..) # pass infinite lists as parameters with less typing {0..} # not sure, but it follows on Nicholas Clark
Re: Fw: perl6 operator precedence table
On Wed, 9 Oct 2002, Nicholas Clark wrote: : On Tue, Oct 08, 2002 at 06:07:09PM -0700, Larry Wall wrote: : > There's this basic rule that says you can't have an operator for both binary : > and postfix, since it's expecting an operator in either case, rather than a : > term (which is how we recognize prefix operators). The one exception I can : > think of is that we might allow .. as a postfix operator, but only if followed : > by a right bracket. That would let us say : > : > @a[0..] : > : > rather than : > : > @a[0..Inf] : > : > But that's a special case. : : Would that mean that three other special cases of postfix .. might exist? : : 0..; # useful for return 0..; I bet the PDLers want to be able to say: @a[0..; 0..:10; 0..:100] : (0..) # pass infinite lists as parameters with less typing : {0..} # not sure, but it follows on I meant those too when I said "bracket". If only we had Unicode editors, we could just force everyone to use the infinity symbol where they mean it. It seems a shame to make a special case of the .. operator. Maybe we should ... to mean "and so on forever": @a[0...; 0...:10; 0...:100] Except then we couldn't use it to mean what Ruby means by it, which might be handier in real life. (It means to exclude the endpoint, so 0...4 is the same as 0..3. But then, that's kind of odd too.) Larry
Re: Fw: perl6 operator precedence table
In a message dated Wed, 9 Oct 2002, Larry Wall writes: > If only we had Unicode editors, we could just force everyone to use > the infinity symbol where they mean it. It seems a shame to make a > special case of the .. operator. Maybe we should ... to mean "and so > on forever": > > @a[0...; 0...:10; 0...:100] > > Except then we couldn't use it to mean what Ruby means by it, which > might be handier in real life. (It means to exclude the endpoint, > so 0...4 is the same as 0..3. But then, that's kind of odd too.) Oh, but then (0...) would mean "all numbers from zero to infinity, excluding infinity" which would have the same effect in the real world, wouldn't it? :-) Trey
Re: Fw: perl6 operator precedence table
On Wed, Oct 09, 2002 at 10:35:32AM -0700, Larry Wall wrote: > On Wed, 9 Oct 2002, Nicholas Clark wrote: > : On Tue, Oct 08, 2002 at 06:07:09PM -0700, Larry Wall wrote: > : Would that mean that three other special cases of postfix .. might exist? > : > : 0..; # useful for return 0..; > > I bet the PDLers want to be able to say: @a[0..; 0..:10; 0..:100] Logically does that mean , also gets in on the special case? I think it makes sense, as I presume one could pass a couple of infinite lists to a function that way. > : (0..) # pass infinite lists as parameters with less typing > : {0..} # not sure, but it follows on > > I meant those too when I said "bracket". Oops - sorry. I'm so used to American texts that use bracket, brace and parentheses to mean [] {} () (in that order, IIRC), so I assumed that you were strictly following that convention. > If only we had Unicode editors, we could just force everyone to use > the infinity symbol where they mean it. It seems a shame to make a > special case of the .. operator. Maybe we should ... to mean "and so > on forever": > > @a[0...; 0...:10; 0...:100] > > Except then we couldn't use it to mean what Ruby means by it, which > might be handier in real life. (It means to exclude the endpoint, > so 0...4 is the same as 0..3. But then, that's kind of odd too.) I think it would be clearer with .. Inf, and however many "special cases" make sense. Presumably ] } ) ; : , are all symbols that can't be unary prefix operators? And if ... is exclude the endpoint, there's little difference between 0 .. Inf and 0 ... Inf, so the mathematicians can write 0 ... and be happy, can't they? Nicholas Clark -- Even better than the real thing:http://nms-cgi.sourceforge.net/
Re: Fw: perl6 operator precedence table
On Wednesday, October 9, 2002, at 10:35 AM, Larry Wall wrote: > Except then we couldn't use it to mean what Ruby means by it, which > might be handier in real life. (It means to exclude the endpoint, > so 0...4 is the same as 0..3. But then, that's kind of odd too.) Uh-oh: my life is gonna suck. I've spent days hunting obscure bugs that were caused by a single mistyped character. Now I'll be spending days hunting obscure bugs that were caused by a single *pixel*. :-) :-) :-) MikeL
Re: Fw: perl6 operator precedence table
On Wed, 9 Oct 2002, Brad Hughes wrote: : Larry Wall wrote: : [...] : > Maybe we should ... to mean "and so on forever": : > : > @a[0...; 0...:10; 0...:100] : > : > Except then we couldn't use it to mean what Ruby means by it, which : > might be handier in real life. : : No more yada-yada-yada? Still have yada-yada-yada. That's ... when a term is expected, not when an operator is expected. Just don't write 1,2,3... when you mean 1,2,3,... Or vice versa. Larry
Re: Fw: perl6 operator precedence table
In a message dated Wed, 9 Oct 2002, Michael Lazzaro writes: > > Uh-oh: my life is gonna suck. I've spent days hunting obscure bugs > that were caused by a single mistyped character. Now I'll be spending > days hunting obscure bugs that were caused by a single *pixel*. > I've already been there, my friend. :-) MacOS X's pretty anti-aliased fonts make it impossible to tell the difference between colon and semi-colon at small type sizes. It didn't used to matter, but now it really does. I have a hot key to make my terminal's font bigger whenever I'm reading perl6 mail. :-) Trey
Re: Fw: perl6 operator precedence table
On Tue, Oct 08, 2002 at 06:07:09PM -0700, Larry Wall wrote: > I've always wondered what the ! postfix operator means. The mathematicians > think they know. :-) The Ruby folks think they know. They're method name conventions. >From "Programming Ruby" Methods that act as queries are often named with a trailing '?', such as instance_of?. Methods that are 'dangerous' or modify the receiver, might be named with a trailing '!'. For instance, String provides both a chop and a chop!. The first one returns a modified string; the second modifies the receiver in place. '?' and '!' are the only weird characters allowed as method name suffixes. So... sorted_array = array.sort # return a sorted array array.sort! # sort in place is_sorted = array.sorted? # return true if the array is sorted Interestingly enough, Ruby also supports the ?: operator as Perl does and does not require whitespace between the tokens. $foo=1?42:0; # $foo will have 42 in it. I believe that ? simply binds tighter to method names than the ?: operator. This is fine: print defined? $foo; This is a syntax error: print defined? $foo : 42; /home/schwern/tmp/foo.rb:1: parse error print defined? $foo : 42; ^ -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One Cottleston, Cottleston, Cottleston Pie. Why does a chicken, I don't know why. Ask me a riddle and I reply: "Cottleston, Cottleston, Cottleston Pie."
Re: Fw: perl6 operator precedence table
Larry Wall wrote: [...] > Maybe we should ... to mean "and so on forever": > > @a[0...; 0...:10; 0...:100] > > Except then we couldn't use it to mean what Ruby means by it, which > might be handier in real life. No more yada-yada-yada? Brad
Re: Fw: perl6 operator precedence table
On Wednesday, October 9, 2002, at 05:03 PM, Trey Harris wrote: > In a message dated Wed, 9 Oct 2002, Michael Lazzaro writes: > >> >> Uh-oh: my life is gonna suck. I've spent days hunting obscure bugs >> that were caused by a single mistyped character. Now I'll be spending >> days hunting obscure bugs that were caused by a single *pixel*. >> > > I've already been there, my friend. :-) MacOS X's pretty anti-aliased > fonts make it impossible to tell the difference between colon and > semi-colon at small type sizes. It didn't used to matter, but now it > really does. I have a hot key to make my terminal's font bigger > whenever > I'm reading perl6 mail. :-) Andale Mono is all fun and games until someone loses half an hour of their life to: int x, y, z: char ch; :-)