SHARE
TWEET

Untitled

a guest Aug 24th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. @def
  3.  
  4. Macro used to create sections of code that can
  5. be copy/pasted into other code
  6. """
  7. macro def(name, definition)
  8.   return quote
  9.       macro $(esc(name))()
  10.           esc($(Expr(:quote, definition)))
  11.       end
  12.   end
  13. end
  14.  
  15. # Example of macro that adds some default fields
  16. @def add_default_fields begin
  17.   name::String
  18.   size::Int
  19. end
  20.  
  21. # Object that has fields from add_default_fields copy/pasted into it
  22. struct Thing1
  23.   @add_default_fields
  24. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top