-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support MSON inheritance #26
Comments
I think refract implementations should provide this lookup – expansion – at least we are going to implement it in the C++ counterpart (cc @klokane) |
@zdne @danielgtaylor This is something we need to decide. How does an MSON structure get converted into a normal Refract structure? I don't think Minim should handle that explicitly, though I think we can make some things that derive element definitions from a structure (which is essentially what MSON does). First, let me change up the example above to match the MSON. MSON:
Refract ["object", { "title": "Data types" }, {}, [
["object", { "id": "A", "name": "A" }, {}, {}],
["A", { "id": "B", "name": "B" }, {}, [
["string", { "name": "C" }, {}, "test"]
]]
]] At this point, this is all Refract should do. MSON structures have their own way of representing the data. If you ran through something to convert to use MSON inheritance there are several steps we could take. First, convert ["object", { "title": "Data types" }, {}, [
["object", { "id": "A", "name": "A" }, {}, {}],
["extend", { "id": "B", "name": "B" }, {}, [
["ref", {}, {}, "A"],
["object", {}, {}, [
["string", { "name": "C" }, {}, "test"]
]]
]]
]] Then dereference the ["object", { "title": "Data types" }, {}, [
["object", { "id": "A", "name": "A" }, {}, {}],
["extend", { "id": "B", "name": "B" }, {}, [
["object", { "ref": "A" }, {}, {}],
["object", {}, {}, [
["string", { "name": "C" }, {}, "test"]
]]
]]
]] Finally compute extend: ["object", { "title": "Data types" }, {}, [
["object", { "id": "A", "name": "A" }, {}, {}],
["object", { "id": "B", "name": "B", "ref": "A" }, {}, [
["string", { "name": "C" }, {}, "test"]
]]
]] Is this correct? Thoughts? I think we can make the jump straight to the end, but wanted to show some intermediate steps. |
I'm not sure the best way to do this. I'd be interested to see what the C++ say above doing this. I'm wondering if we will have to make two passes on the document. |
I still have no completed expansion. But way how i will to complete it
How I understand to refract, expansion should provide complete resolution of every any type up to primitives w/o any linking. I hope we will discuss it today with @zdne |
I like it. Seems correct.
I think you're correct, but there are some cases around this to discuss. For example, Refract inheritance by default is simply inheriting the definition of the element, but does not inherit the actual data. In MSON, though, elements will actually inherit data from their respective parents. I think we need to discuss how to convey this, because I think by default Refract will act differently than MSON. Hope that makes sense. |
Good to know, I miss it :) |
Right now this won't behave as expected. Think of the MSON which defines one type which is an object, then another which inherits from it:
test
Without expansion/preprocessing it's likely it will get expanded to something like this:
In the above example we'll get an
ElementType
forB
instead ofObjectType
because there is no registered type forA
. That means thatB.content
will be the raw content above instead of proper element instances. The solution may be to create some kind of lookup tree for the base type or some kind of preprocessing loop. Ideas?The text was updated successfully, but these errors were encountered: