When doing call-by-reference, you will still need to allocate an lvalue, and all references to that variables will have to do an extra indirection, so I'm not sure that it will actually be any faster.
The second argument seems like a good one though. Although, I would mostly go for the simplifications that could be made in the compiler since x+=y; could be compiled as _tmp=&x; *_tmp=*_tmp+y;
/ Fredrik (Naranek) Hubinette (Real Build Master)
Previous text:
2003-04-16 16:07: Subject: Pointers/lvalues
Multiple return values? Call-by-reference?
Yes, call-by-reference where modification of the arguments is wanted; pike uses call-by-reference extensively already but it doesn't allow that. Pointers as argument would typically work as a replacement for multiple return values. It offers the benefit of accurate typing compared to the current implementation of multiple return values, and it's also slightly more efficient since dynamic allocation of short lived arrays is avoided.
Iteration?
Not really; the iterators already covers that. It's mostly a matter of syntactic sugar for dereferencing them.
Something else?
Yes, the possibility to return pointers that can be used in lvalue contexts. This is very interesting for collections and iterators. I.e. `[]= can be replaced with `&[] in collections where the values are modifiable and it would work efficiently in cases like foo[17] += ({0}), foo[17] &= (<1,2,3>) etc. The alternative approach to allow optimization of such operations is to introduce a plethora of lfuns like `[]+=, `[]&=, `[]*=, etc.
/ Martin Stjernholm, Roxen IS