Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- @def
- Macro used to create sections of code that can
- be copy/pasted into other code
- """
- macro def(name, definition)
- return quote
- macro $(esc(name))()
- esc($(Expr(:quote, definition)))
- end
- end
- end
- # Example of macro that adds some default fields
- @def add_default_fields begin
- name::String
- size::Int
- end
- # Object that has fields from add_default_fields copy/pasted into it
- struct Thing1
- @add_default_fields
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement