Advertisement
Guest User

Untitled

a guest
Jan 14th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.44 KB | None | 0 0
  1. type
  2.     Color = enum
  3.         red, orange, yellow, green, blue, indigo, violet
  4.  
  5. # Goal: access the ordinal value of c
  6. # Issue: macros parameters are passed as type NimNode
  7. #        and I cannot access the ordinal value
  8. macro color_test*(c: Color): typed =
  9.     #c.intVal <- this doesn't work "f"
  10.     # what I want to do
  11.     # if ord(c) >= ord(yellow): ...
  12.     return
  13.  
  14. #this is functional
  15. var c = yellow
  16. if ord(c) > ord(orange): discard
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement