The functionality is not the opposite of sprintf("%O"):
On a higher level of abstraction it is. sprintf("%O") converts an object to a (class specfic) string representation. What your proposed conversion character does is to convert a (class specific) string representation to an object.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2004-02-07 17:19: Subject: sscanf and Gmp.mpq
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