[E-Lang] Operator expansion names, Part 1: Intro

Ben Laurie ben@algroup.co.uk
Mon, 23 Apr 2001 14:37:53 +0100


Bill Frantz wrote:
> 
> At 5:17 PM -0700 4/6/01, Mark S. Miller wrote:
> >For example, we might say the "normal" math notion of "+" is something like:
> >
> >    For each data type T to which + applies (after coercions), + should
> >    be closed over T, such that for any t1 and t2 in T, t1 + t2 should also be
> >    in T.  For any such type T, there must also be a zero element of that
> >    type t0, such that t1 + t0 -> t1 and t0 + t1 -> t1.  + must also be
> >    associative.
> >
> >This is violated by both
> >
> >    [1, 2] + [3, 4] -> [1, 2, [3, 4]]
> >
> >and
> >
> >    'a' + 3 -> 'd'
> 
> I don't know that the definition speaks to the issue where the second
> operand isn't of type T, which applies to the second example.
> 
> However, consider that T is lower case letters, and the addition is
> modular.  (We end up with the strange definition that the additive identity
> element is 'z', but heck, that's better then defining pi as being 3.  :-))
> We also have a coercion of numbers to letters:
> 
> 0 -> 'z'
> 1 -> 'a'
> n mod 26 -> ...
> etc.
> 
> Note that if we follow the C rule that 'c' is a short hand for an integer,
> we get the same kind of logical consistency.

Weirdo - why not start at 0 -> 'a'?

> 
> Normal addition obeys the rule: a + b equals b + a.  If the goal is to
> encourage people building types to model the mathematical concepts of group
> and ring, then we want:
> 
> If a and b are in T, then a + b is always in T
> a + 0 equals a
> a + b equals b + a
> (a + b) + c equals a + (b + c)
> 
> My naive belief is that bags and sets obey these rules.

a+b is only equal to b+a in an Abelian group.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

ApacheCon 2001! http://ApacheCon.com/