Re: Musings on operator overloading

2008-03-20 Thread David Green
On 2008-Mar-19, at 1:40 pm, Mark J. Reed wrote: On Wed, Mar 19, 2008 at 1:01 PM, Larry Wall [EMAIL PROTECTED] wrote: The use of + in Python or in C++ is, I think, primarily the violation of a *linguistic* principle, not a mathematical principle. Maybe it's just 'cause I cut my teeth on

Re: Musings on operator overloading

2008-03-20 Thread Mark J. Reed
On Thu, Mar 20, 2008 at 2:24 AM, David Green [EMAIL PROTECTED] wrote: Interestingly, BASIC has gone the other direction -- at least, Visual BASIC uses + for addition and for concatenation; I'm guessing this happened when VB got variant types that could hold either numbers or strings.

Re: Musings on operator overloading

2008-03-20 Thread TSa
HaloO, Mark J. Reed wrote: For the record, I am opposed to any restriction on operator overloading that requires mathematical properties to hold. ANYTHING is fair if you predeclare. Hmm, my idea is more about defining interfaces that allow to detach implementation of (numerical) algorithms

Re: Musings on operator overloading

2008-03-20 Thread Mark J. Reed
On Thu, Mar 20, 2008 at 10:01 AM, TSa [EMAIL PROTECTED] wrote: Hmm, my idea is more about defining interfaces that allow to detach implementation of (numerical) algorithms from datatypes. E.g. the Euclidean algorithm to find the gcd requires division and a remainder that decreases in

Re: Musings on operator overloading

2008-03-20 Thread TSa
HaloO, Mark J. Reed wrote: Sure. But that's different from saying Ok, you can only define an / operator for numberish things. Well, if you adhere to the ring, field or whatever interface the overloaded / sort of ends up being numberish anyway. BTW, do we have a unary multiplikative

Re: Musings on operator overloading

2008-03-20 Thread Larry Wall
On Thu, Mar 20, 2008 at 11:03:11AM -0400, Mark J. Reed wrote: :Besides, there is nothing that inherently :associates the / symbol with division - it's only an ASCII :approximation of fraction notation. : : We all know that ASCII is a rather limited char set but one : that has the

Re: Musings on operator overloading

2008-03-20 Thread Larry Wall
On Thu, Mar 20, 2008 at 05:06:00PM +0100, TSa wrote: BTW, do we have a unary multiplikative inversion operator? That is 1/ as prefix or **-1 as postfix? Well, 1/ looks like a pretty good prefix. :) Except it's not really first class. This ain't Haskell... As for **-1, I'd suspect that of

Re: Musings on operator overloading

2008-03-20 Thread Doug McNutt
At 17:06 +0100 3/20/08, TSa wrote: BTW, do we have a unary multiplikative inversion operator? That is 1/ as prefix or **-1 as postfix? Perhaps .inv as method? Do we have .neg for additive inversion? There certainly is the unary minus even though it is badly interpreted in some languages,

Re: Musings on operator overloading

2008-03-20 Thread Mark J. Reed
On Thu, Mar 20, 2008 at 1:09 PM, Doug McNutt [EMAIL PROTECTED] wrote: Don't even think about parsing = -$x**2; so that it returns a positive result. Okay, going way off on a tangent here, but I don't think the Perl interpretation is quite as obviously correct as you think it is; there's a

Re: Musings on operator overloading (was: File-Fu overloading)

2008-03-20 Thread Aristotle Pagaltzis
Hi Jonathan, * Jonathan Lang [EMAIL PROTECTED] [2008-02-24 22:30]: So if I'm understanding you correctly, the following would be an example of what you're talking about: { use text; if $a 49 { say $a } } ...with the result being the same as Perl5's 'if $a gt 49 { say $a }' (so if $a