octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #51605] operands ++ and -- via function


From: Ernst Reissner
Subject: [Octave-bug-tracker] [bug #51605] operands ++ and -- via function
Date: Fri, 4 Aug 2017 09:13:35 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0

Follow-up Comment #4, bug #51605 (project octave):

Yes, i would like to do the implementation. 
The usefulness can also be explained: 

in matlab, oo allows to overwrite most operations. 
Among those also +, -, *, /. 
The result is, that these can be used with objects also. 

This works as follows: 
To these operation are tied functions 
plus, minus, mtimes, mrdivide. 
Overwriting these functions 
results in overwriting the according operations. 
So a+b is just a shortcut for plus(a, b). 

Unlike Matlab, Octave provides besides the assignment operation = 
also the shortcuts +=, -=, *= and /=. 
As you know, a += b is just a shortcut for a = a + b 
and this in turn for a = plus(a,b). 
So to use += in the oo context, i.e. with objects, 
one can write a += b only, if this has the meaning of 
a = plus(a,b). 

Also unlike Matlab, Octave has operator ++, 
both prefix and postfix. 
++a is just a shortcut for a += 1. 
So ++a means nothing but a = plus(a, 1). 

But what is 1 in the oo-context? i suggest just cln(1), 
where cln is the name of the class and thus of the constructor. 
If this is not defined, then adding 1 does not make sense 
and I think adding in general does not. 

So So ++a means nothing but a = plus(a, cln(1)). 

Think of using this in the context of a polynomial 
or of defining another kind of arithmetics in octave 
like rational arithmetics, 
interval arithmetics, 
continued fractions or something else 
(which is actually what i do). 



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51605>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]