develooper Front page | perl.perl6.language | Postings from January 2004

Re: Semantics of vector operations

Thread Previous | Thread Next
Larry Wall
January 22, 2004 11:26
Re: Semantics of vector operations
Message ID:
On Thu, Jan 22, 2004 at 01:10:25PM -0500, Austin Hastings wrote:
: > -----Original Message-----
: > From: Larry Wall []
: > I think some people will want to think of it one way, while others
: > will want to think of it the other way.  If that's the case, the
: > proper place to put the marker is between the operand and the operator.
: How do you handle operator precedence/associativity?

Me?  I handle it by making it an adverb on the base operator.  :-)

: That is,
:    $a + $b + $c
: If you're going to vectorize, and combine, then you'll want to group. I
: think making the vectorizer a grouper as well kills two birds with one
: stone.
:   $a + >>$b + $c<<

Er, pardon me, but bletch.

: vs.
:   $a +<< ($b + $c)

That's much clearer to me.  (Ignoring the fact that you can't add
references. :-)

: > You might argue that we should force people to think of it one way or
: > the other.  But there's a reason that some people will think of it
: > one way while others will think of it the other way--I'd argue that
: > vectorization is not something that happens to *either* the operand
: > or the operator.  Vectorization is a different *relationship* between
: > the operator and the operand.  As such, I still think it belongs
: > between.
: >
: > Plus, in the symmetrical case, it *looks* symmetrical.  Marking the
: > args in front makes everything look asymmetrical whether it is or not.
: Just a refresher, what *exactly* does vectorization do, again?  I think of
: it as smart list-plus-times behavior, but when we go into matrix arithmetic,
: that doesn't hold up. Luke?

It really means "please dereference this scalar in an intelligent
fashion for this particular operator".  The exact behavior is
allowed to depend on the operator and the types of both arguments
(if both sides are vectorized).  That is, it's probably a multimethod
in disguise.

Actually, it's a bit misleading to call it a vectorizing operator.
It's really a dwim operator that will commonly be used for vectorizing
in the case of one-dimensional lists.  For higher dimensional beasties,
it means "make these conform and then apply the operator in some kind
of distributed fashion, with a bias toward leaf operations".

I don't think that »X« means "Do whatever the mathematicians want X
to do."  Unicode operators have to be good for something, after all.

So perhaps its best to call » and « "distribution modifiers" or
some such.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About