Okay, For those of you playing the home game, Take 5, with Damian & Larry's latest inputs. ^ means xor again, and a few things have been removed. Comments?
Note that I will next post a list of hyperoperators _separately_.
If the design team could take a look, esp. at the remaining questions, in order to [APPROVE] a "final" list, that'd be wonderful. We'll then get to work on reconstructing the operator precedence table that started this monster thread and, hopefully, we can [APPROVE] that in short order as well, and be done with it. (optimist optimist optimist optimist...)
hyperoperators:
[op] - as prefix to any unary/binary operator, "vectorizes" the operator
(is whitespace allowed inside the brackets, e.g. [ + ] vs. [+] ?)
unary (prefix) operators:
\ - reference to * - list flattening ? - force to bool context ! - force to bool context, negate not - force to bool context, negate + - force to numeric context - - force to numeric context, negate +^ - force to numeric context, complement ~ - force to string context ~^ - force to string context, complement . - method call on current topic
Probably still the same, at least until we start thinking about it...
: magical whitespace modifier : _ - [maybe] remove whitespace/newline : (briefly discussed, but not an operator?)
We need something here. Underline is available.
: explicit radix specifications for integers: : (we'll just handle this issue separately, OK?)
Fine. I'm not sure we actually have to change anything here from Perl 5. Syntactic mangling could easily work for anyone who wants base 42.
: other uncategorized: : (no decisions are implied about these, e.g. are they : ops, listops, methods, whatever... decide later) : : my our - [declar] : map grep : sqrt log sin cos tan (etc...) - math : lc lcfirst uc ucfirst : int ord oct hex bin
oct and hex are arguably backwards, typewise. They don't produce octal or hex types, but rather consume them.
: Larry Wall [mailto:la...@wall.org] wrote: : > : unary (postfix) operators: : > : ... - [maybe] same as ..Inf [Damian votes Yes] : > : > I wonder if we can possibly get the Rubyesque leaving out of : > endpoints by saying something like 1..!10. : : Perhaps we could use the less-than symbol: 1 ..< 10 : : Similarly: 1 >..< 10 == 2..9
That front one is backwards--it would have to be 1 <..< 10.
But the biggest problem is that 1..<$iterator> is valid syntax.
Of course, ..! and ..^ have the same problem. But it just seems like it's really unlikely that someone would use a unary ! or ^ on the endpoint term. So with 1..!$x or 1..^$x it's likely to be right if we guess (per the longest token rule) that the operator is ..! or ..^. The same can't be said of ..<, alas. But at least it might produce a syntax error when it tries to parse the >. Or no, it wouldn't necessarily. This parses:
1..<$iterator> + 1;
but wrongly as
1 ..< $iterator > +1;
Ick.
Of course, Real Mathematicians will want [1..10) and (1..10] instead.
Double ick.
I kind like ..^ the best because ^ is currently read "exclusive of" anyway, sort of...
And the arrow can be read "up to", at least on that end of it. I think that ..^ is going to be much, much more common than ^.. will be.
There's also an issue of what (1..10) - 1 would or should mean, if anything. Does it mean (1..9)? Does 1 + (1..10) mean (2..10)?
> : > I wonder if we can possibly get the Rubyesque leaving out of > : > endpoints by saying something like 1..!10. > : > : Similarly: 1 >..< 10 == 2..9 > There's also an issue of what (1..10) - 1 would or should > mean, if anything. Does it mean (1..9)? Does 1 + (1..10) > mean (2..10)?
> And what would ('a' .. 'z') - 1 mean?
1..10-1 # 1..9 1+1..--10 # 2..9 'a'..'z'-- # a - y
?
-- ralph
PS. [op] is such a sweet improvement. the [op=] vs [op]= trick that then became possible, the move of ^ back to its previous meaning, is nice icing.
Larry Wall: # Of course, Real Mathematicians will want [1..10) and (1..10] instead. # # Double ick.
Reminds me of the number-line notation you learn about *before* precalculus (or whatever the value of $you.schooling.grade[12].class{math}.name is) confuses everything, with open vs. closed circles on a number line. How about:
(The scary part is that I'm not sure I'm joking any more...)
# There's also an issue of what (1..10) - 1 would or should # mean, if anything. Does it mean (1..9)? Does 1 + (1..10) # mean (2..10)? # # And what would ('a' .. 'z') - 1 mean?
Er, I would hope that it would be the same as scalar('a' .. 'z') - 1, or ['a' .. 'z'] - 1, or +['a' .. 'z'] - 1, or 26 - 1, or 25. But that wouldn't be weird enough, I suppose--it's looking like Perl 6 will be the official language of *The Matrix*. Free your mind! :^)
Wire telegraph is a kind of a very, very long cat. You pull his tail in New York and his head is meowing in Los Angeles. And radio operates exactly the same way. The only difference is that there is no cat. --Albert Einstein (explaining radio)
Brent Dax wrote: > Larry Wall: > # There's also an issue of what (1..10) - 1 would or should > # mean, if anything. Does it mean (1..9)? Does 1 + (1..10)
Actually, I would at first glance think, based on the parens, that:
(1..10)-1 means ((1-1)..(10-1)) means (0..9)
.... and if someone has been playing a lot with the superposition stuff, that is probably what they would indeed expect. That's also a valuable interpretation, since it means you can say things like
(1..$n) * 10
And get a list (10,20,...) without having to change $n.
However, by the same logic,
@array * 10 means @array [*] 10
which it doesn't. So maybe the correct interpretation of the above is indeed this:
(1..10)-1 # (1..10).length-1, e.g. 9 (oops!)
(1..10) [-] 1 # (0..9) (correct, if that's WYM)
meaning that (1..10)-1 almost always does The Wrong Thing(!)
Larry Wall wrote: > : ... - [maybe] range, exclusive of endpoint [Damian votes No]
> Could have ^..^ and ^..too, for all that.
OK, I just gotta say, that's _d*mn_ clever. "Exclusive of endpoint" -- It looks like what it is, and vice versa. I guess that's why you're our fearless leader. :-)
I'll revise according to the notes, do some cleanup, and repost the single, re-condensed list.
I also want to say again, for the record, I'm *really* looking forward to programming in this. It's going to be FUN. Bwah-ha-ha!
On Tue, Oct 29, 2002 at 05:16:48PM -0800, Michael Lazzaro wrote: > unary (prefix) operators:
> \ - reference to > * - list flattening > ? - force to bool context > ! - force to bool context, negate > not - force to bool context, negate > + - force to numeric context > - - force to numeric context, negate > +^ - force to numeric context, complement > ~ - force to string context > ~^ - force to string context, complement
Noe that we have gained ^ back from being a hyeroperator, could we not have ^ as a polymorphic complement operator. It can always be combined with ~ or + to force context, eg
$a = ^ +$b; $a = ^ ~$b;
We would then have a complement operator that I would assume objects could overload and do whatever they liked with.
On the other hand, I like the idea of being able to distribute an operator using this syntax...
@a = @b op $c
versus
?? = @b [op] $c
What's the difference? One maybe produces @b[x] op $c while the other produces -> { $result = $c; for @b -> $b { $c op= $b; } }
But then it's not legal any more in array context unless @b is a LoL. Erk!
> @a [&] @b # all(*@a,*@b) ???
Array s.t. @result[x] = @a[x] & @b[x]
> @a = ($b [,] @c); # @a = ($b, *@c); ???
LoL: @a[x] = ($b, @c[x])
> I'm not even sure how to hyper these two. I guess if I had an array > of "range objects" I could hyper ;
Hypersemi is probably just the same as hypercomma, since the circumlocutions needed to use it are such that you'll probably specify the construction clearly.
But if not:
@a = @b [;] @c --> @a[x] = ((@b[x]) ; (@c[x]))
> Would this write to several filehandles?
> print @file_handles [:] "fooey!\n";
> > .. - range
> And this is the one that made me start thinking about hypering the > others
You, too? Range was the first thing I started trying to hyper.
> I know that this stuff probably seems obvious to everyone, but I'd > rather have it explicit just in case :-)
if $x == any(@b[..]@c) print "In one of the ranges...\n";
or
if $x ~~ any(@b[..]@c) print "In one of the ranges...\n";
Does .. create an implicit flexpr in numeric context, or does it require smartmatch?
=Austin
__________________________________________________ Yahoo! - We Remember 9-11: A tribute to the more than 3,000 lives lost http://dir.remember.yahoo.com/tribute
I think that's correct. Actually, that's a really useful behavior...
# > , - list creator # # @a = ($b [,] @c); # @a = ($b, *@c); ??? # # > ; - "greater comma", list-of-lists creator # > : - adverbial # # I'm not even sure how to hyper these two. I guess if I had # an array of "range objects" I could hyper ;
Aren't these more syntax than operator?
# Would this write to several filehandles? # # print @file_handles [:] "fooey!\n";
Perhaps.
# > .. - range # # And this is the one that made me start thinking about # hypering the others # # @a = @b[..]@c # @a = ($b[0]..$c[0], $b[1]..$c[1], ...) ??? # @a = $b[..]@c # @a = ($b..$c[0], $b..$c[1], ...) ??? # @a = @b[..]$c # @a = ($b[0]..$c, $b[1]..$c, ...) ???
That's a really good one. My naive implementation gives this:
Wire telegraph is a kind of a very, very long cat. You pull his tail in New York and his head is meowing in Los Angeles. And radio operates exactly the same way. The only difference is that there is no cat. --Albert Einstein (explaining radio)
On Wed, Oct 30, 2002 at 09:13:02AM -0800, Austin Hastings wrote: > --- Jonathan Scott Duff <d...@cbi.tamucc.edu> wrote: > > Maybe we've gone over this before but, if so, I don't remember ...
> > On Tue, Oct 29, 2002 at 05:16:48PM -0800, Michael Lazzaro wrote: > > > hyperoperators:
> > > [op] - as prefix to any unary/binary operator, "vectorizes" the
> > > operator
> > > . - method call on current topic
> > What would [.]method() mean?
> @a = @b[.]method(); # Sets each @a[x] to @b[x].method()
No, no. I'm talking about the unary . prefix
method blah { .foo() [.]foo() # What does this mean? }
One could argue that several ways, depending on what's in the current topic. It's the exact same thing as the binary form of dot, but with the left side being implied, as 'the current topic':
topic is a scalar: hyperdot does nothing (scalar hyperop scalar == scalar op scalar)
topic is a listref: listref is automatically dereferenced, foo method is called on all elements.
(In other words, I imagine calling a hyper on scalars is not an error -- it just doesn't do anything more interesting than the normal op.)
Note you could also perhaps say something like
[.]$methodlist()
to mean "call each of these methods on (each of) the current topic(s)", tho I'm not sure the syntax is accurate there.
> On Wed, Oct 30, 2002 at 09:13:02AM -0800, Austin Hastings wrote: > > --- Jonathan Scott Duff <d...@cbi.tamucc.edu> wrote: > > > Maybe we've gone over this before but, if so, I don't remember > ...
> > > On Tue, Oct 29, 2002 at 05:16:48PM -0800, Michael Lazzaro wrote: > > > > hyperoperators:
> > > > [op] - as prefix to any unary/binary operator, "vectorizes" > the
> > > > operator
> > > > . - method call on current topic
> > > What would [.]method() mean?
> > @a = @b[.]method(); # Sets each @a[x] to @b[x].method()
> No, no. I'm talking about the unary . prefix
> method blah { > .foo() > [.]foo() # What does this mean? > }
Vector of invocations of the foo methods of the current topic.
Presumably you'd have an array in topic, or you'd use it in an array context.
for @lol -> @onelist { @a = [.]foo();
}
=Austin
__________________________________________________ Do you Yahoo!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/
: > No, no. I'm talking about the unary . prefix : > : > method blah { : > .foo() : > [.]foo() # What does this mean? : > } : : Vector of invocations of the foo methods of the current topic.
Except that the topic is by definition singular in a method, and so is a method name. So it'd be no different from ordinary dot. Maybe it's an error to use a vector op on two scalars.
: Presumably you'd have an array in topic, or you'd use it in an array : context. : : for @lol -> @onelist { : @a = [.]foo(); : }
Yes, that would work, though I'd love to see it:
for @lol -> @onelist { @a = «.»foo(); }
instead. Maybe ^[+] (or whatever) is just a workaround for people who can't figure out how to write «+». I love the "shimmers" on either side of the operator. That's a nice plural visual metaphor.
I'd even be willing to give up «foo bar baz» meaning qw(foo bar baz) for this.
> On Wed, 30 Oct 2002, Austin Hastings wrote: > : > No, no. I'm talking about the unary . prefix > : > > : > method blah { > : > .foo() > : > [.]foo() # What does this mean? > : > } > : > : Vector of invocations of the foo methods of the current topic.
> Except that the topic is by definition singular in a method, and so > is a method name. So it'd be no different from ordinary dot. Maybe > it's an error to use a vector op on two scalars.
> : Presumably you'd have an array in topic, or you'd use it in an > array > : context. > : > : for @lol -> @onelist { > : @a = [.]foo(); > : }
> Yes, that would work, though I'd love to see it:
> for @lol -> @onelist { > @a = «.»foo(); > }
How do you write a « in a Windows based environment? (Other than by copying them from Larry's emails or loading MSWord to do insert->symbol)
> instead. Maybe ^[+] (or whatever) is just a workaround for people > who can't figure out how to write «+». I love the "shimmers" on > either side of the operator. That's a nice plural visual metaphor.
Yeah, "This looks kind of fuzzy. You probably don't clearly see what's going on." Works for me.
> I'd even be willing to give up «foo bar baz» meaning qw(foo bar baz) > for this.
Holy rat-on-a-stick, Batman! That IS quite a sacrifice...
=Austin
__________________________________________________ Do you Yahoo!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/
On Wednesday, October 30, 2002, at 11:58 AM, Larry Wall wrote: > I'd even be willing to give up ´foo bar bazª meaning qw(foo bar baz) > for this.
I can't see that right (MacOSX Jaguar) in the email; to me it looks like a forwardtick and an, um, underlined 'a' -- but in spite of that, I'm game. It's just so pretty (when it works!)
On my Mac, it's spelled «op» -- can others see that correctly, or do we have a sorry disconnect in the fonts, here, for us Mac folks?
On Wednesday, October 30, 2002, at 12:17 PM, Michael Lazzaro wrote: > I can't see that right (MacOSX Jaguar) in the email; to me it looks > like a forwardtick and an, um, underlined 'a' -- but in spite of that, > I'm game. It's just so pretty (when it works!)
> On my Mac, it's spelled «op» -- can others see that correctly, or do > we have a sorry disconnect in the fonts, here, for us Mac folks?
I use Mail.app, and saw the same thing you did. When I looked at the headers for Larry's email, I saw:
This tells me that Mail.app, for some reason, didn't know that it was supposed to use UTF-8 when showing Larry's mail. When I pasted his mail into a UTF-8 document in Emacs, it looked fine.
Given that it's probably UTF-8 that Perl 6 source code is written in, I think that you and I might be better off using a smarter mailer.
> This tells me that Mail.app, for some reason, didn't know that it was > supposed to use UTF-8 when showing Larry's mail. When I pasted his mail > into a UTF-8 document in Emacs, it looked fine.
> Given that it's probably UTF-8 that Perl 6 source code is written in, I > think that you and I might be better off using a smarter mailer.
> David
Larry's mail was *marked* as UTF-8, but by the time I got it it had no French quotes in it in UTF-8, Latin-1, or any other encoding anymore. My mailer understand UTF-8 just fine, and so does vim (which I used to look at my spool file to check for encoding oddities); in my copy of his message, there's just nothing there. All I can think is that some MTA along the way - possibly our very own Exchange server - stripped them out.
-- Mark REED | CNN Internet Technology 1 CNN Center Rm SW0831G | mark.r...@cnn.com Atlanta, GA 30348 USA | +1 404 827 4754