Re: meta_postfix:*

2008-07-16 Thread Larry Wall
On Sun, Jul 13, 2008 at 12:46:30PM +0200, TSa (Thomas Sandlaß) wrote:
: HaloO,
: 
: I know that the hot phase of the operator discussions are over.
: But here's a little orthogonalizing idea from my side. The observation
: is that * can be regarded as repeated addition: 5 * 3 == 5 + 5 + 5
: and ** as repeated multiplication. Now imagine having a meta_postfix:*
: that gives +* as multiplication (perhaps abbreviated as *) and ** as
: (integer) exponentiation. We can then continue with replication as ~*
: for strings and ,* for lists thus freeing x and xx as some generic
: multiplication operators.

I think this is not going to fly from the standpoint of keeping common
operators visually distinct.  Also, how will you parse 1..* and such?

(Another consideration is that every time you add another metaoperator
you're potentially exploding the number of operators that the longest
token matcher needs to deal with, though STD currently cheats on this.)

: The meta * also is useful e.g. as (1,2) Z* 3 === (1,1,1),(2,2,2). Also
: when we apply it to unary postfix as well: $x++* 3 === $x++.++.++ which
: is useful when $x is of some class with overloaded ++ where the single
: steps are important. The meta postfix * could also be stacked and tetration
: falls out naturally as ***.

Speaking on behalf of the mere mortal, My Eyes Glaze Over.

Speaking as a parser writer, you're confusing the parser with a
metaoperator that changes expectation of term vs infix.

Sepaking as a programmer, $x++.++.++ won't do what you seem to think it does.

: With + as the default case for meta_postfix:* we win the advantage that
: we have +* and * as multiplication operators with the latter being a special
: form of the former. But for Vectors +* would automatically yield the scalar
: multiplication infix:+*:(Vector,Num) when infix:+:(Vector,Vector) is
: defined as expected.

You can, of course, do anything you like with your own copy, but the
standard reserves most of Unicode as the playground of mathematicians,
so please leave our poor little * alone.  :)

Larry


Re: meta_postfix:*

2008-07-15 Thread Dave Whipp

Jon Lang wrote:

So you're suggesting that

  A op* n

should map to

  [op] A xx n


I don't think that that mapping works for Thomas' proposal of a 
repetition count on post-increment operator. I.e.


  $a ++* 3

is not the same as

  [++] $a xx 3

(which I think is a syntax error)

and also not the same as

  $a++ * 3

Also, he's suggesting getting rid of the xx operator, and replacing it 
with ,* -- I'm sure I could get used to that


Re: meta_postfix:*

2008-07-15 Thread Jon Lang
Dave Whipp wrote:

 Jon Lang wrote:

 So you're suggesting that

  A op* n

 should map to

  [op] A xx n


 I don't think that that mapping works for Thomas' proposal of a repetition
 count on post-increment operator. I.e.

  $a ++* 3

 is not the same as

  [++] $a xx 3

 (which I think is a syntax error)


It is.


 Also, he's suggesting getting rid of the xx operator, and replacing it
 with ,* -- I'm sure I could get used to that


Currently, it's being assumed that the repetition meta-operator will be
appended to the operator, followed by the repetition count:

  $value op* $count

This makes it difficult to apply the replication meta-operator to a prefix
operator.  However, a second option could be provided, where the
meta-operator gets prepended:

  $count *op $value

So:

  5 *, $n === $n ,* 5 === $n, $n, $n, $n, $n
  $n ++* 5 === $n++)++)++)++)++
  5 *++ $n === ++(++(++(++(++$n

And obviously the metaoperator is nonsensical when applied to a binary
operator with different types of values on its left and right sides.

As with other meta-operators, it should be possible to explicitly define a
symbol that would otherwise be interpreted as a meta'd operator, because of
efficiency; because the operator in question has capabilities above and
beyond what the meta-operator would indicate; or because the operator in
question doesn't bear any resemblance to the replicated use of a shorter
operator.  In particular, ** would be overloaded in this manner: to make
reasonable sense, the count of a repetition meta-operator must be an
unsigned integer of some sort, whereas exponents can be any type of number.
Heck, they don't even have to be real.

-- 
Jonathan Dataweaver Lang


meta_postfix:*

2008-07-13 Thread TSa (Thomas Sandlaß)
HaloO,

I know that the hot phase of the operator discussions are over.
But here's a little orthogonalizing idea from my side. The observation
is that * can be regarded as repeated addition: 5 * 3 == 5 + 5 + 5
and ** as repeated multiplication. Now imagine having a meta_postfix:*
that gives +* as multiplication (perhaps abbreviated as *) and ** as
(integer) exponentiation. We can then continue with replication as ~*
for strings and ,* for lists thus freeing x and xx as some generic
multiplication operators.

The meta * also is useful e.g. as (1,2) Z* 3 === (1,1,1),(2,2,2). Also
when we apply it to unary postfix as well: $x++* 3 === $x++.++.++ which
is useful when $x is of some class with overloaded ++ where the single
steps are important. The meta postfix * could also be stacked and tetration
falls out naturally as ***.

With + as the default case for meta_postfix:* we win the advantage that
we have +* and * as multiplication operators with the latter being a special
form of the former. But for Vectors +* would automatically yield the scalar
multiplication infix:+*:(Vector,Num) when infix:+:(Vector,Vector) is
defined as expected.


Regards, TSa.
-- 
The unavoidable price of reliability is simplicity -- C.A.R. Hoare
Simplicity does not precede complexity, but follows it. -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan


Re: meta_postfix:*

2008-07-13 Thread Jon Lang
So you're suggesting that

  A op* n

should map to

  [op] A xx n

?

-- 
Jonathan Dataweaver Lang