The functionality is not the opposite of sprintf("%O"):
| > sprintf("%O",Gmp.mpq(1234,4578)); | (1) Result: "Gmp.mpq(617/2289)" | > sprintf("%O",17); | (2) Result: "17" | > array_sscanf("17","%O"); | (3) Result: ({ /* 1 element */ | 17 | })
Theoretically: | > array_sscanf("Gmp.mpq(617/2289)","%O"); | (x) Result: ({ /* 1 element */ | Gmp.mpq(617/2289) | })
but here we want
| > array_sscanf("617/2289","%q"); | (x) Result: ({ /* 1 element */ | Gmp.mpq(617/2289) | })
Slight causality problem here: Since the string is to be sent to the constructor, the length must be known before there even exists an object.
Yes... It could send the rest of the string, and get the remainings as a result (via another function, if create never can put anything on the stack).
But another idea would be to use a flag (*-like) on all string reading types to sscanf, so you could use %[].
/ Mirar
Previous text:
2004-02-07 16:57: Subject: sscanf and Gmp.mpq
Since the functionality is the opposite of sprintf("%O"), I think it's reasonable to use %O. The trick is of course that you'd need to provide a program sometimes but not always.
Maybe sscanf could ask the object how many characters it wants.
Slight causality problem here: Since the string is to be sent to the constructor, the length must be known before there even exists an object.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)