Hmm. Isn't it enough to provide an _encode and _decode method to allow objects to be en/decoded? I get this:
Cannot encode objects without an "encode_object" function in the codec. pgallery.pike:24: pgallery()->main(1,({"/home/neotron/src/pgallery/pgallery.pike"}))
The documentation states that the Codec in the master will be used if none is provided - well, it has:
mixed encode_object(object x) { if(x->_encode) return x->_encode(); error("Cannot encode objects yet.\n"); }
Am I missing something? Hmm. Ok, so it DOESN'T use the default codec in the master it seems. It works with:
encode_value(o, master()->Codec());
Documentation error, bug or something that is new in Pike 7.5?
It seems to be a bit confused:
o The doc for decode_value says it uses the master itself as codec if none is given.
o The doc for encode_value says nothing but hints that a codec object must be given explicitly: "To encode objects, programs and functions, a codec object must be provided."
o Both encode_value and decode_value uses the master itself as fallback.
o The master doesn't implement the functions to act as a codec (the Codec class in the master does).
I'd like to solve this by removing the fallback to the master, thereby requiring a codec to be given explicitly. One reason is that it would avoid the often unnecessary overhead of instantiating a Codec object. Another is that more explicit control over the codec almost always is required to handle objects, functions and programs in a good way.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-01-06 09:30: Subject: encode_value for objects
Hmm. Isn't it enough to provide an _encode and _decode method to allow objects to be en/decoded? I get this:
Cannot encode objects without an "encode_object" function in the codec. pgallery.pike:24: pgallery()->main(1,({"/home/neotron/src/pgallery/pgallery.pike"}))
The documentation states that the Codec in the master will be used if none is provided - well, it has:
mixed encode_object(object x) { if(x->_encode) return x->_encode(); error("Cannot encode objects yet.\n"); }
Am I missing something? Hmm. Ok, so it DOESN'T use the default codec in the master it seems. It works with:
encode_value(o, master()->Codec());
Documentation error, bug or something that is new in Pike 7.5?
/ David Hedbor
o Both encode_value and decode_value uses the master itself as fallback.
Ah, that makes a bit more sense then...
/ David Hedbor
Previous text:
2003-01-06 13:05: Subject: encode_value for objects
It seems to be a bit confused:
o The doc for decode_value says it uses the master itself as codec if none is given.
o The doc for encode_value says nothing but hints that a codec object must be given explicitly: "To encode objects, programs and functions, a codec object must be provided."
o Both encode_value and decode_value uses the master itself as fallback.
o The master doesn't implement the functions to act as a codec (the Codec class in the master does).
I'd like to solve this by removing the fallback to the master, thereby requiring a codec to be given explicitly. One reason is that it would avoid the often unnecessary overhead of instantiating a Codec object. Another is that more explicit control over the codec almost always is required to handle objects, functions and programs in a good way.
/ Martin Stjernholm, Roxen IS
pike-devel@lists.lysator.liu.se