On Thu, 20 Dec 2012, Sven Schreiber wrote:
On 12/19/2012 11:55 PM, Allin Cottrell wrote:
> Hello all + season's greetings
>
> Up till now gretl has supported only very limited usage of the
> increment (++) and deccrement (--) operators. The only acceptable
> usage has been in stand-alone expressions (e.g.)
>
> j++ # shorthand for j = j + 1
> j-- # shorthand for j = j - 1
>
> for "j" the name of a user-defined scalar variable.
>
> As of today's CVS I'm experimenting with fuller support for
> something that is really quite handy in C and similar languages,
> namely the ability to embed constructs such as "j++" and "j--"
in
> more or less arbitrary contexts. For example:
>
> k = j++ # k = current value of j; then increment j
> m[j++] = x # assign x to element j of m; increment j
> x = foo(j--) # evaluate foo(j); decrement j
>
Hi Allin,
I guess it's hard to argue against new features, but for non-C people
like me I must say that the above example are a little
counter-intuitive. What I mean is the ordering of operations. For my
eyes the innermost operation would be the in-/decrementing that comes
first, then the function call / assignment.
So I'm not sure I like the C idioms taking over hansl...
Just my 2c,
Sven: I see your point, but I can assure you that once you get used to it,
it's very natural. Besides, while it's true that these are C idioms, it is
also true that they have spread to other matrix-oriented languages that
are in massive use today, such as the matlab family and ox (not sure about
gauss). Can't be a bad idea, can it?
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------