Skip to content
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

Getting custom code for defining methods #107

Closed
aminya opened this issue Mar 1, 2020 · 1 comment · Fixed by #113
Closed

Getting custom code for defining methods #107

aminya opened this issue Mar 1, 2020 · 1 comment · Fixed by #113
Labels
enhancement New feature or request Methods

Comments

@aminya
Copy link
Owner

aminya commented Mar 1, 2020

It is very useful to be able to get custom code from user and use them later for defining the extractor, creator, etc methods.

Two ways to do that:

  • have a field in each @aml structure, that is a Dict, and can store different codes
@aml mutable struct Foo
a::Int64, "~"
b::String, "~"
code = Dict(:creator_start => :(b=a), :extractor_end => :(if a>b a = b else b = a end))
end
  • have extra macros in each @aml
@aml mutable struct Foo
a::Int64, "~"
b::String, "~"
@aml_creator_start b = a
end
@aminya
Copy link
Owner Author

aminya commented Mar 1, 2020

Using macro is a better solution because it gives us the ability to put the macro between the fields, and insert the code even in between the XML/HTML operations.

@aml mutable struct Foo
@amlcreator b = 0 # start of amlcreator
a::Int64, "~"
@amlcreator b = a * 2 # middle of amlcreator
b::String, "~"
@amlcreator b = a # end of amlcreator
end

@aminya aminya mentioned this issue Mar 3, 2020
3 tasks
@aminya aminya pinned this issue Mar 3, 2020
@aminya aminya unpinned this issue Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Methods
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant