There was a thread last spring about adding a reference/pointer data type to Pike (title "Pointers/lvalues", message 10034173 for those that use LysKOM). I still think it'd be a useful thing. But it wouldn't behave like C++ references (that requires strong typing), so using it to implement sscanf as a normal function wouldn't work.
Besides, I don't really see the problem that sscanf is a special construct.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-12-23 04:34: Subject: Re: C#-like properties
On Tue, Dec 23, 2003 at 04:19:57AM +0100, Martin B?hr wrote:
we are trying to reduce the syntax (in this discussion anyways)
Uhm... I thoutgh we are trying to improve it :)
[foo, bar, baz] = array_sscanf(...);
And if you need elements 1, 5, 7 only? Again - array will be allocated anyway - which is too much overhead.
how many calls to sscanf will it take before this difference becomes significant?
1 million, 50 millions, few billions... That's typical when you process large data files (billing-like apps), or anything that involves a lot of input data (log files, etc).
As I said before - user input is not only case where sscanf() is used and/or convenient.
And, honestly, sometimes I miss this feature - passing by reference for ints/floats/strings... After all, passing by reference (in case of interpreted languages) is more effective (you don't need to make a copy, you don't need to allocate additional memory (svalue), etc) - that't why arrays/mappings/etc passed by reference.
Hmm... Just an idea... Why not pass "scalar" types by reference (avoid copying) and implement "copy-on-write"? :) Since most of the time values passed are not modified (well, depends on app - but anyway) - it may give a significant performance gain, or?
Even simplier - compiler always (almost) "knows" - is value modified in function or not, so sometimes it is safe enough just to pass reference to svalue instead of a copy...
Regards, /Al
/ Brevbäraren