J
Jorge
Hi,
We've got i++, which is an expression that assigns i+1 to i, but
evaluates to the original value of i. It's called the postfix
increment, or post-increment operator, isn't it ?
I think that it would have been nice to have too a "post-assignment"
operator, let's say ":=", that would assign a new value, but would
evaluate to the original value:
i := i+1; // emulates an i++
I was writing this the other day:
callBack= queue;
queue= nop;
callBack();
With this "post-assignment" operator I could have written instead:
( queue := nop )(); // which is nicer
It's ideal for swapping as it avoids the need for tmp. vars:
tmp= a;
a= b;
b= tmp;
could be written as :
a= (b := a);
properly optimized, it could even be slightly faster, or not ?
But, my idea must have some problem: why if not it's not in any
language ?
(now me ducks and runs)
Any thoughts ?
Thanks,
We've got i++, which is an expression that assigns i+1 to i, but
evaluates to the original value of i. It's called the postfix
increment, or post-increment operator, isn't it ?
I think that it would have been nice to have too a "post-assignment"
operator, let's say ":=", that would assign a new value, but would
evaluate to the original value:
i := i+1; // emulates an i++
I was writing this the other day:
callBack= queue;
queue= nop;
callBack();
With this "post-assignment" operator I could have written instead:
( queue := nop )(); // which is nicer
It's ideal for swapping as it avoids the need for tmp. vars:
tmp= a;
a= b;
b= tmp;
could be written as :
a= (b := a);
properly optimized, it could even be slightly faster, or not ?
But, my idea must have some problem: why if not it's not in any
language ?
(now me ducks and runs)
Any thoughts ?
Thanks,