Trouble understanding macros: creating a struct on the fly

macro make_struct(name, schema)
  fields=[:($(Symbol(entry[1]))::$(Symbol(titlecase(entry[2])))) for entry in eval(schema)]
  :(struct $(esc(name))
    $(map(esc,fields)...)
   end)
end
@make_struct STRUCT_NAME [["x","int32"]]

I’d say the thing you missed was adding the newline immediately after the struct name. It needs this for some reason.

Also you should probably escape the name of the struct and it’s fields otherwise the structs will be defined in the module the macro is defined in and it will look for DataType’s used in the fields there too.