Closed GoogleCodeExporter closed 9 years ago
Constructor is statefull.
Do you have a proposal how to do it ?
Original comment by aso...@gmail.com
on 13 Nov 2009 at 5:46
Basically the Constructors lack a method:
addConstruct(String tag, Construct construct){
yamlConstructors.put(tag, construct);
}
The trival thing would be to add this to BaseConstructor. But this might be a
bad
idea. A constructor sort of represents what the spec calls "Schema". A Schema
is a
closed set of rules. Just adding this method would allow to change the rules.
So I propose to introduce another class:
public class ExtendableConstructor extends Constructor{
addConstruct(String tag, Construct construct){
yamlConstructors.put(tag, construct);
}
}
Of course there must also be remove methods, etc.
If you like the idea I could easily implement it.
Original comment by smurn....@gmail.com
on 13 Nov 2009 at 7:44
[deleted comment]
Yes, go ahead. It is much easier to discuss when we can see the complete
picture.
Original comment by py4fun@gmail.com
on 16 Nov 2009 at 2:42
I see now that this issue and the next one (#34) are connected: add a
possibility to
easily inject a small implementation of either Construct or Represent
interfaces.
Indeed it should work for simple cases. It may also help to serialize immutable
objects.
Unfortunately anchors and aliases make the picture much more complicated. If
the
Node contains an alias how the simple Construct implementation (without
context!)
can figure out which instance to use ?
Recursive structures make anchors and aliases mandatory.
But I agree with you. We may try to implement this kind of functionality to see
the
impact (I cannot see all the consequences now)
Original comment by py4fun@gmail.com
on 18 Nov 2009 at 5:32
Sorry my previous comment is only valid for issue #34. Once you extends
Constructor
you do have the context.
Original comment by py4fun@gmail.com
on 18 Nov 2009 at 6:25
Since the reporter is not interested in the topic any more I will close the
issue.
Original comment by aso...@gmail.com
on 20 Dec 2009 at 10:47
Original issue reported on code.google.com by
smurn....@gmail.com
on 13 Nov 2009 at 5:09