-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Consider using a trait based API instead of macros #153
Comments
Related to JuliaData/StructTypes.jl#7 |
AcuteML is like the JSX of Julia. This library aims to make it easy for developers to build their HTML or XML applications with the least amount of boilerplate code. This has several benefits:
# Here you can serialize any HTML that follows this structure. Serialization here means both parsing and creating.
@aml mutable struct Body "~"
h1, "~"
p::Vector{String}, "~"
end
@aml mutable struct Page doc"html"
body::Body, "~"
end See MusicXML.jl for an example of a library that uses AcuteML: If you plan to inject custom code to your AcuteML components there are multiple ways you can do this: You can also directly use the AcuteML's backend if you wish (although not necessary at all). I wrote VarStructs which is similar to AcuteML, but is for any type of data. You can easily define your requirements for data using VarStructs, and everything will be handled for you.
|
I don't necessarily see how what I'm thinking of is mutually exclusive. Here is an example to clarify this. Say I have a struct struct Foo
x::String
y::Int and I want to serialize it in XML, JSON and possible some other serialization format. If each of the serialization libraries defines their custom APIs with macros, it is difficult to combine them and they have to be added as dependencies. I'm asking whether it is possible to use a common API for defining the mapping to various serialization formats like Rust's Serde does. As far as I know, StructTypes.jl comes the closest to this kind of API. If it doesn't suit AcuteML, it would be useful to know what is missing so a better API can be built. |
Nice package! I really like the way JSON3.jl handles mapping structs to JSON and back. It does this by annotating structs with traits from StructTypes.jl. I wonder if a similar approach could be used with AcuteML. This way you could easily serialize your struct in either JSON or XML. I'm not sure how well XML maps to the existing StructTypes traits, but there is probably some overlap.
The text was updated successfully, but these errors were encountered: