Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Perl6 Operator List, Take 5
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 102 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michael Lazzaro  
View profile  
 More options Oct 29 2002, 8:48 pm
Newsgroups: perl.perl6.language
From: mlazz...@cognitivity.com (Michael Lazzaro)
Date: Tue, 29 Oct 2002 17:16:48 -0800
Local: Tues, Oct 29 2002 8:16 pm
Subject: [RFC] Perl6 Operator List, Take 5
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

   ++    - preincrement
   --    - predecrement

unary (postfix) operators:

   ++    - postincrement
   --    - postdecrement

   ...   - [maybe] same as ..Inf     [Damian votes Yes]

other postfix operators:

   ()    - (when operator is expected)
   []    - array access
   {}    - hash access

binary operators:

   (do more of these have possible +~? prefix modifiers,
    or only the boolean &|^ ops?)

    +     -     *     /     %     **     x     xx     ~      - arithmetic
    +=    -=    *=    /=    %=    **=    x=    xx=    ~=

   <      >     <=    >=    ==    !=    <=>      - comparision
   lt     gt    le    ge    eq    ne    cmp

    &&      ||      ^^      //              - boolean operations
    &&=     ||=     ^^=     //=
    and     or      xor     err

    .&      .|      .^      <<      >>      - bitwise (integer)
operations
    .&=     .|=     .^=     <<=     >>=

    ~&      ~|      ~^              - charwise (string) operations
    ~&=     ~|=     ~^=

    ?&      ?|      ?^              - [maybe] C-like bool operations
    ?&=     ?|=     ?^=             - (result is always just 1 or 0)

    &       |       ^               - superpositional operations
    &=      |=      ^=              - conjunctive, disjunctive, exclusive
    all     any     one   none      - conj, disj, excl, dismissive
    sum     prod    cat   reduce    - [maybe]

    ~~      !~                      - smart match, smart non-match
   like   unlike                    - [maybe]  [Damian votes No]

   =>   - pair creator
   ,    - list creator
   ;    - "greater comma", list-of-lists creator
   :    - adverbial
   .    - method call

   ..   - range
   ...  - [maybe] range, exclusive of endpoint   [Damian votes No]

   =    - assignment
   :=   - binding
   ::=  - binding, but more so

trinary operator:

   ?? ::    - if/else

parens, misc, and quotelike operators

   ()
   []    - [when term is expected]
   {}    - [when term is expected]

   m//   - shorthand, "matches"
   s///  - shorthand, "substitute"
   tr/// - shorthand, "transliterate"

   '...'  "..."   `...`   /.../   << >>
     q     qq      qx      rx      qw     [qm?]
                        [+ qr ?]

   <...>        - readline
   (heredocs)   - [exact format unknown]

named unary (prefix) operators, terms, and other important assorteds,
identified
when possible:

   -X       [-X]       - [op] filetest operators

   ref      [ref]      - [op]
   exists   [exists]   - [op]
   delete   [delete]   - [op]
   defined  [defined]  - [op]
   undef    [undef]    - [op]
   undef               - [term]
   temp        ?       - [op]
   let         ?       - [op]
   but         ?       - [op] val properties

   ${ }                - [deref] dereference scalarref
   @{ }                - [deref]
   %{ }                - [deref]
   &{ }                - [deref]

   ...                 - [term] yada**3
   Inf                 - [term]
   Nan                 - [term]

   is                  - [declar] var properties
   ->                  - [declar] like 'sub'
   hash                - [declar] force hash context

--- taken out, for now ----

magical whitespace modifier
   _     - [maybe] remove whitespace/newline
   (briefly discussed, but not an operator?)

explicit radix specifications for integers:
   (we'll just handle this issue separately, OK?)

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

MikeL


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile  
 More options Oct 29 2002, 9:48 pm
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Tue, 29 Oct 2002 18:39:01 -0800 (PST)
Local: Tues, Oct 29 2002 9:39 pm
Subject: Re: [RFC] Perl6 Operator List, Take 5
On Tue, 29 Oct 2002, Michael Lazzaro wrote:

:    (is whitespace allowed inside the brackets, e.g. [ + ] vs. [+] ?)

I don't think so.

: unary (prefix) operators:
:    .     - method call on current topic

I think we have to have unary .= as well, if we're to do the

    .=replace

trick on $_.

: 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.

: other postfix operators:
:
:    ()    - (when operator is expected)
:    []    - array access
:    {}    - hash access

These now consistently require no space, and they're all
when an operator is expected, not just ().

: binary operators:
:
:    (do more of these have possible +~? prefix modifiers,
:     or only the boolean &|^ ops?)

Well, things like < already imply numeric, and things like lt already
imply string.  The booleans are already officially polymorphic.

:     +     -     *     /     %     **     x     xx     ~      - arithmetic
:     +=    -=    *=    /=    %=    **=    x=    xx=    ~=

I don't think of x or ~ as arithmetic exactly...

:     .&      .|      .^      <<      >>      - bitwise (integer)
: operations
:     .&=     .|=     .^=     <<=     >>=

These should be +& etc.

:     sum     prod    cat   reduce    - [maybe]

That's Apocalypse 29.  :-)

:     ~~      !~                      - smart match, smart non-match
:    like   unlike                    - [maybe]  [Damian votes No]

Undecided.

:    ..   - range
:    ...  - [maybe] range, exclusive of endpoint   [Damian votes No]

Still thinking about ..! or ..^ or some such.  Could have ^..^ and ^..
too, for all that.

:    ::=  - binding, but more so

Cute, but nonexplanatory.  Binding at compile time.

: trinary operator:
:
:    ?? ::    - if/else
:
: parens, misc, and quotelike operators
:    ()
:    []    - [when term is expected]
:    {}    - [when term is expected]

Again, all of these are when a term is expected, not just the latter two.

:    m//   - shorthand, "matches"
:    s///  - shorthand, "substitute"
:    tr/// - shorthand, "transliterate"
:
:    '...'  "..."   `...`   /.../   << >>
:      q     qq      qx      rx      qw     [qm?]
:                         [+ qr ?]

No, the qr is dead.  Long live the rx.

:    <...>        - readline

Iterate interator.

:    (heredocs)   - [exact format unknown]

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Whipp  
View profile  
 More options Oct 29 2002, 11:48 pm
Newsgroups: perl.perl6.language
From: david_wh...@fast-chip.com (David Whipp)
Date: Tue, 29 Oct 2002 20:45:31 -0800
Local: Tues, Oct 29 2002 11:45 pm
Subject: RE: [RFC] Perl6 Operator List, Take 5

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

Dave.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile  
 More options Oct 30 2002, 1:48 am
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Tue, 29 Oct 2002 22:29:26 -0800 (PST)
Local: Wed, Oct 30 2002 1:29 am
Subject: RE: [RFC] Perl6 Operator List, Take 5
On Tue, 29 Oct 2002, David Whipp wrote:

: 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)?

And what would ('a' .. 'z') - 1 mean?

I think I'd better go to bed now...

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Me  
View profile  
 More options Oct 30 2002, 2:48 am
Newsgroups: perl.perl6.language
From: m...@self-reference.com (Me)
Date: Wed, 30 Oct 2002 01:08:42 -0600
Local: Wed, Oct 30 2002 2:08 am
Subject: Re: [RFC] Perl6 Operator List, Take 5

> : > 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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brent Dax  
View profile  
 More options Oct 30 2002, 2:48 am
Newsgroups: perl.perl6.language
From: brent...@cpan.org (Brent Dax)
Date: Tue, 29 Oct 2002 23:23:21 -0800
Local: Wed, Oct 30 2002 2:23 am
Subject: RE: [RFC] Perl6 Operator List, Take 5
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:

        1 oo 10   # (1, 10)
        1 o. 10   # (1, 10]
        1 .o 10   # [1, 10)
        1 .. 10   # [1, 10]

(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!  :^)

--Brent Dax <brent...@cpan.org>
@roles=map {"Parrot $_"} qw(embedding regexen Configure)

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)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Lazzaro  
View profile  
 More options Oct 30 2002, 2:48 am
Newsgroups: perl.perl6.language
From: mlazz...@cognitivity.com (Michael Lazzaro)
Date: Tue, 29 Oct 2002 23:39:26 -0800
Local: Wed, Oct 30 2002 2:39 am
Subject: Re: [RFC] Perl6 Operator List, Take 5

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(!)

MikeL


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Lazzaro  
View profile  
 More options Oct 30 2002, 2:48 am
Newsgroups: perl.perl6.language
From: mlazz...@cognitivity.com (Michael Lazzaro)
Date: Tue, 29 Oct 2002 23:05:10 -0800
Local: Wed, Oct 30 2002 2:05 am
Subject: Re: [RFC] Perl6 Operator List, Take 5

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!

MikeL


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Barr  
View profile  
 More options Oct 30 2002, 3:48 am
Newsgroups: perl.perl6.language
From: gb...@pobox.com (Graham Barr)
Date: Wed, 30 Oct 2002 08:25:03 +0000
Local: Wed, Oct 30 2002 3:25 am
Subject: Re: [RFC] Perl6 Operator List, Take 5

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.

Graham.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Cozens  
View profile  
 More options Oct 30 2002, 4:48 am
Newsgroups: perl.perl6.language
From: si...@ermine.ox.ac.uk (Simon Cozens)
Date: 30 Oct 2002 09:21:37 +0000
Local: Wed, Oct 30 2002 4:21 am
Subject: Re: [RFC] Perl6 Operator List, Take 5

la...@wall.org (Larry Wall) writes:
> Still thinking about ..! or ..^ or some such.  Could have ^..^ and ^..
> too, for all that.

We could indeed have a whole range of Japanese smiley operators.

--
A year spent in artificial intelligence is enough to make one believe in God.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angel Faus  
View profile  
 More options Oct 30 2002, 5:48 am
Newsgroups: perl.perl6.language
From: af...@corp.vlex.com (Angel Faus)
Date: Wed, 30 Oct 2002 15:09:18 +0100
Local: Wed, Oct 30 2002 9:09 am
Subject: Re: [RFC] Perl6 Operator List, Take 5
LW said:

> :    <...>        - readline

> Iterate interator.

Couldn't we go the python way and assume that  <..> is implicit in
"for" statments:

$fh = open(..);
for $fh {             # instead of for <$fh>
        print $_;

}

For explicit iteration, we could well do just with a ".next" method:

while ($line = $fh.next) {
        print $line;

}

And the old perl construct:

while (<>) {
        print $_

};

Could be replaced with a open() without arguments, such as:

for open() {
        print $_;

}

And then <..> could go back to being a gentler replacement of qw<..>.

Or is there any problem that my blind eyes can't see?

-angel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Scott Duff  
View profile  
 More options Oct 30 2002, 10:48 am
Newsgroups: perl.perl6.language
From: d...@cbi.tamucc.edu (Jonathan Scott Duff)
Date: Wed, 30 Oct 2002 09:16:06 -0600
Local: Wed, Oct 30 2002 10:16 am
Subject: Re: [RFC] Perl6 Operator List, Take 5

On Tue, Oct 29, 2002 at 11:39:26PM -0800, Michael Lazzaro wrote:
> So maybe the correct interpretation of the above is indeed this:

>     (1..10)-1 # (1..10).length-1, e.g. 9 (oops!)

Do "range objects" return their length in scalar context?

>     (1..10) [-] 1   # (0..9)   (correct, if that's WYM)

That's how I would write it if that's what I meant.

> meaning that (1..10)-1 almost always does The Wrong Thing(!)

Indeed.

-Scott
--
Jonathan Scott Duff
d...@cbi.tamucc.edu


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Scott Duff  
View profile  
 More options Oct 30 2002, 11:48 am
Newsgroups: perl.perl6.language
From: d...@cbi.tamucc.edu (Jonathan Scott Duff)
Date: Wed, 30 Oct 2002 10:33:49 -0600
Local: Wed, Oct 30 2002 11:33 am
Subject: Re: [RFC] Perl6 Operator List, Take 5
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?

>    <      >     <=    >=    ==    !=    <=>      - comparision
>    lt     gt    le    ge    eq    ne    cmp

What do these do?

        if $a [<] @b { ... }         # if $a < all(*@b)           ???
        if @a [<] @b { ... }         # if $a[0] < all(*@b) &&
                                        #    $a[1] < all(*@b) &&
                                        #    $a[2] < all(*@b) &&  ...  ???

>     &       |       ^               - superpositional operations

        $a [&] @b                   # all($a,*@b)           ???
        @a [&] @b                   # all(*@a,*@b)          ???

>    =>   - pair creator

        %hash = (@a [=>] @b);                # %hash{@a} = @b;       ???
        %hash = (@a [=>] $b);                # %hash{@a} = ($b) x @a;        ???

>    ,    - 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 ;

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

        @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, ...)      ???

I know that this stuff probably seems obvious to everyone, but I'd
rather have it explicit just in case  :-)

-Scott
--
Jonathan Scott Duff
d...@cbi.tamucc.edu


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Hastings  
View profile  
 More options Oct 30 2002, 12:48 pm
Newsgroups: perl.perl6.language
From: austin_hasti...@yahoo.com (Austin Hastings)
Date: Wed, 30 Oct 2002 09:13:02 -0800 (PST)
Local: Wed, Oct 30 2002 12:13 pm
Subject: Re: [RFC] Perl6 Operator List, Take 5

--- 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()

Thinking out loud ...

@a = @b[.method()];  # Sets @a to the value stored in @b indexed by
                     # current context.method()

> >    <      >     <=    >=    ==    !=    <=>      - comparision
> >    lt     gt    le    ge    eq    ne    cmp

> What do these do?

>    if $a [<] @b { ... }         # if $a < all(*@b)

Credible.

>    if @a [<] @b { ... }         # if $a[0] < all(*@b) &&
>                                    #    $a[1] < all(*@b) &&
>                                    #    $a[2] < all(*@b)

My inclination here is that $a[0] < $b[0] && $a[1] < $b[1] ...

>    $a [&] @b                   # all($a,*@b)           ???

Questionable. Perhaps an array s.t. @result[x] = $a & @b[x]  ?

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

>    @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, ...)      ???

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brent Dax  
View profile  
 More options Oct 30 2002, 12:48 pm
Newsgroups: perl.perl6.language
From: brent...@cpan.org (Brent Dax)
Date: Wed, 30 Oct 2002 09:39:36 -0800
Local: Wed, Oct 30 2002 12:39 pm
Subject: RE: [RFC] Perl6 Operator List, Take 5
When I'm trying to figure out what the "default" hypering semantics for
an operator would be, I use this:

***BEGIN CODE***

{
use strict;
use warnings;

sub _is_arrayref { ref $_[0] && ref $_[0] eq 'ARRAY' }

sub hyper(&\@\@) {
        my($code, $a, $b)=@_;
        my @results;

        if(_is_arrayref($a)) {
                if(_is_arrayref($b)) {
                        my $alen=$#{$a};
                        my $blen=$#{$b};
                        my $maxlen=$alen;

                        if($alen > $blen) {
                                for($blen + 1 .. $alen) {
                                        $b->[$_]='';
                                }

                        }
                        elsif($blen > $alen) {
                                for($alen + 1 .. $blen) {
                                        $a->[$_]='';
                                }
                                $maxlen=$blen;
                        }

                        for(0..$maxlen) {
                                push @results, &vector($code, $a->[$_] ,
$b->[$_]);
                        }

                        if($alen > $blen) {
                                $#{$b}=$blen;
                        }
                        elsif($blen > $alen) {
                                $#{$a}=$alen;
                        }
                }
                else {
                        for(@$a) {
                                push @results, &vector($code, $_, $b);
                        }
                }

        }
        elsif(_is_arrayref($b)) {
                for(@$b) {
                        push @results, &vector($code, $a, $_);
                }
        }
        else {
                no strict 'refs';
                no warnings 'once';
                local *{caller().'::a'}=\$a;
                local *{caller().'::b'}=\$b;
                return $code->();
        }
        return @results;

}
}

my @a=qw(1 2 3); my @b=([qw(4 5 6)], [qw(7 8 9)], [qw(10 11 12)]);
print join ' ', hyper { $a + $b } @a, @b;

***END CODE***

With that in mind...

Jonathan Scott Duff:
# What would [.]method() mean?

Presumably, @foo[.]method() would call .method on each object.

# >    <      >     <=    >=    ==    !=    <=>      - comparision
# >    lt     gt    le    ge    eq    ne    cmp
#
# What do these do?
#
#       if $a [<] @b { ... }         # if $a < all(*@b)  
#       ???
#       if @a [<] @b { ... }         # if $a[0] < all(*@b) &&
#                                       #    $a[1] < all(*@b) &&
#                                       #    $a[2] < all(*@b)
# &&  ...  ???

Create a list of the results.  For example:

        @a=qw(1 2 3);
        @b=qw(3 2 1);
        print join ' ', hyper { $a < $b } @a, @b;
        #prints 1 0 0

# >     &       |       ^               - superpositional operations
#
#       $a [&] @b                   # all($a,*@b)           ???
#       @a [&] @b                   # all(*@a,*@b)          ???
#
# >    =>   - pair creator
#
#       %hash = (@a [=>] @b);                # %hash{@a} = @b;       ???
#       %hash = (@a [=>] $b);                # %hash{@a} = ($b) x
# @a;   ???

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:

1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 2 3 4 5 6 7 2 3 4 5 6 7 8 2 3 4 5 6 7 8 9
3 4 5 6 7 8 9 10 3 4 5 6 7 8 9 10 11 3 4 5 6 7 8 9 10 11 12

Perhaps that would be:

[1 2 3 4] [1 2 3 4 5] [1 2 3 4 5 6] [2 3 4 5 6 7 8] [2 3 4 5 6 7 8 9] [3
4 5 6 7 8 9 10] [3 4 5 6 7 8 9 10 11] [3 4 5 6 7 8 9 10 11 12]

--Brent Dax <brent...@cpan.org>
@roles=map {"Parrot $_"} qw(embedding regexen Configure)

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)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Scott Duff  
View profile  
 More options Oct 30 2002, 12:48 pm
Newsgroups: perl.perl6.language
From: d...@cbi.tamucc.edu (Jonathan Scott Duff)
Date: Wed, 30 Oct 2002 11:44:08 -0600
Local: Wed, Oct 30 2002 12:44 pm
Subject: Re: [RFC] Perl6 Operator List, Take 5

No, no.  I'm talking about the unary . prefix

        method blah {
           .foo()
           [.]foo()             # What does this mean?
        }

> >       if @a [<] @b { ... }         # if $a[0] < all(*@b) &&
> >                                       #    $a[1] < all(*@b) &&
> >                                       #    $a[2] < all(*@b)

> My inclination here is that $a[0] < $b[0] && $a[1] < $b[1] ...

Oops, that's what I meant.  I had originally written

        if all(*@a) < all(*@b)

but then realized that the semantics would be all wrong.

-Scott
--
Jonathan Scott Duff
d...@cbi.tamucc.edu


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Lazzaro  
View profile  
 More options Oct 30 2002, 1:48 pm
Newsgroups: perl.perl6.language
From: mlazz...@cognitivity.com (Michael Lazzaro)
Date: Wed, 30 Oct 2002 09:53:56 -0800
Local: Wed, Oct 30 2002 12:53 pm
Subject: Re: [RFC] Perl6 Operator List, Take 5

>       [.]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.

MikeL


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Hastings  
View profile  
 More options Oct 30 2002, 2:48 pm
Newsgroups: perl.perl6.language
From: austin_hasti...@yahoo.com (Austin Hastings)
Date: Wed, 30 Oct 2002 11:45:10 -0800 (PST)
Local: Wed, Oct 30 2002 2:45 pm
Subject: Re: [RFC] Perl6 Operator List, Take 5

--- Jonathan Scott Duff <d...@cbi.tamucc.edu> wrote:

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/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile  
 More options Oct 30 2002, 3:00 pm
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Wed, 30 Oct 2002 11:58:42 -0800 (PST)
Local: Wed, Oct 30 2002 2:58 pm
Subject: Re: [RFC] Perl6 Operator List, Take 5
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();
    }

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.

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Austin Hastings  
View profile  
 More options Oct 30 2002, 3:48 pm
Newsgroups: perl.perl6.language
From: austin_hasti...@yahoo.com (Austin Hastings)
Date: Wed, 30 Oct 2002 12:11:51 -0800 (PST)
Local: Wed, Oct 30 2002 3:11 pm
Subject: Re: [RFC] Perl6 Operator List, Take 5

--- Larry Wall <la...@wall.org> wrote:

> 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.

method blah()
{
  @values = [.]@list_of_methods();  # Are method pointers meaningful?

}

> : 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/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Lazzaro  
View profile  
 More options Oct 30 2002, 3:48 pm
Newsgroups: perl.perl6.language
From: mlazz...@cognitivity.com (Michael Lazzaro)
Date: Wed, 30 Oct 2002 12:17:42 -0800
Local: Wed, Oct 30 2002 3:17 pm
Subject: Re: [RFC] Perl6 Operator List, Take 5

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?

MikeL


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Wheeler  
View profile  
 More options Oct 30 2002, 3:48 pm
Newsgroups: perl.perl6.language
From: da...@wheeler.net (David Wheeler)
Date: Wed, 30 Oct 2002 12:23:53 -0800
Local: Wed, Oct 30 2002 3:23 pm
Subject: Re: [RFC] Perl6 Operator List, Take 5

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:

   Content-Type: text/plain; charset=UTF-8;

But when I saw yours, you had:

   Content-Type: text/plain; charset=ISO-8859-1; format=flowed

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

--
David Wheeler                                     AIM: dwTheory
da...@wheeler.net                                 ICQ: 15726394
http://david.wheeler.net/                      Yahoo!: dew7e
                                                Jabber: The...@jabber.org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark J. Reed  
View profile  
 More options Oct 30 2002, 3:48 pm
Newsgroups: perl.perl6.language
From: mark.r...@turner.com (Mark J. Reed)
Date: Wed, 30 Oct 2002 15:33:57 -0500
Local: Wed, Oct 30 2002 3:33 pm
Subject: Re: [RFC] Perl6 Operator List, Take 5
On 2002-10-30 at 12:23:53, David Wheeler wrote:
> 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Vectorizing operators for Hashes" by fearc...@figaro.weizmann.ac.il
fearcadi  
View profile  
 More options Oct 30 2002, 3:48 pm
Newsgroups: perl.perl6.language
From: fearc...@figaro.weizmann.ac.il
Date: Wed, 30 Oct 2002 23:43:10 +0200 (IST)
Local: Wed, Oct 30 2002 4:43 pm
Subject: Re: Vectorizing operators for Hashes

Proposal : Vector operations for Hashes

%a ^{+} %b

the direct generalization would be as follows :

@a ^[op] @b

for @a ; @b ->
    $x ; $y {
                 $x op $y
            }

%a op %b

# find common keys
@k = keys hash{ map { { _=>1 } } *( %a.keys , %b.keys ) };

#return hash
hash {
        for @k -> $x {
                { $x => %a{$x} op %b{$x} }
        }  
     }

so in words , find coomon keys and then vectorize op as if
hash keys are array indexes.

Probably that behaviour may be tuned or conrolled by properties of
hashes just like what happens inside <regexes> .

maybe this could be made more general , since
Larry noted  that junctions ( 1 | 2 | 3 ) are similar to hashes  

> %hash = ( 1 | 2 | 3 ) ;

dont have any Idea how.

arcadi.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile  
 More options Oct 30 2002, 3:48 pm
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Wed, 30 Oct 2002 12:41:52 -0800 (PST)
Local: Wed, Oct 30 2002 3:41 pm
Subject: Re: Vectorizing operators for Hashes
On Wed, 30 Oct 2002 fearc...@figaro.weizmann.ac.il wrote:
: # find common keys
: @k = keys hash{ map { { _=>1 } } *( %a.keys , %b.keys ) };

It seems a bit odd to privilege the intersection over the union.

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 102   Newer >
« Back to Discussions « Newer topic     Older topic »