What's wrong with
void method(string &var) {}
?
It looks like the variable &var is declared as a string. I'd prefer "reference(string) var" or "ref(string) var". It impacts less on all the parsers that has to be updated as well.
/ Martin Nilsson (har bott i google)
Previous text:
2003-04-16 01:04: Subject: Pointers/lvalues
Without arguing the case whether pike should get official pointers (as opposed to reference types that kind-of become like pointers), why use pointer(string)? What's wrong with
void method(string &var) {}
? It'd be using the C++ reference syntax rather. Even traditional C-syntax would work:
void method(string *var) {}
The use of type* as an alias for array(type) has been deprecated long enough to be repurposed (with the possible problem that backwards compatibility might become tricky).
Overall, do we need "pointer" syntax or is it enough to be able to pass all variables by reference? By reference I mean the C++ "reference" idea, such as:
void getXY(int pos, int &x, int& y) { x = (pos>>8)&0xff; y = pos&0xff; }
... int my_x, my_y; getXY(my_pos, my_x, my_y);
The benefit is that you don't need to mix in pointer syntax and all the issues related to that. The drawback is that it's less clear from the calling method point of view. Other drawbacks in terms of the implementaiton I won't comment on since I'm not qualified to do so.
/ David Hedbor