Hello everyone! I want to convert that code to Nim but i don't know how :(
enum Opcode {
Push(i64),
Add,
PopN(usize),
}
Any ideas?Something like this:
type
OpcodeKind = enum
Push, Add, PopN
Opcode = object
case kind: OpcodeKind
of Push:
i: int64
of Add:
discard
of PopN:
u: uint
Welcome to Nim :)
I'm curious if it would be possible to get a nicer syntax for these through macros?
Yep, it's possible. The patty package provides this:
https://github.com/andreaferretti/patty#constructing-variant-objects