Defining classes in eopsin #39
Replies: 4 comments 8 replies
-
The |
Beta Was this translation helpful? Give feedback.
-
I have used some custom classes but am encountering a compiler error which I am trying to narrow down - return compile(source, filename, mode, flags,
|
Beta Was this translation helpful? Give feedback.
-
Thanks - all rookie mistakes - VsCode caught the lack of : in the if statement - thanks for all the help and suggestions! |
Beta Was this translation helpful? Give feedback.
-
for reference the following is the code which successfully compiles after removing all of the bugs and using eopsin-lang-0.7.7
|
Beta Was this translation helpful? Give feedback.
-
When defining new classes for use inside eopsin, note the following
That is 1. is has to be tagged as dataclass 2. it has to inherit from PlutusData 3. the CONSTR_ID is optional but needs to be assigned a constant integer if set 4. all other attributes are listed and annotated with a type, but never set to a default value.
Also, if you want to create and use a union of dataclasses, make sure they have different CONSTR_IDs!
Check the documentation on dataclasses if you are unfamiliar with how they work: https://docs.python.org/3.8/library/dataclasses.html
Beta Was this translation helpful? Give feedback.
All reactions