algebraic datatypes
Ronald Legere
legere at adelphia.net
Sat Jun 23 06:32:46 EDT 2001
I would like to define something like
the scheme 'define-datatype' macro (from Essentials of programming languages
2) in python.
Essentially,
datatype Tree = Node Tree Tree | Leaf Int
should translate into a class structure like this:
#class Tree
# abstract
class Node:
def __init__ (self, atree,atree)
self.r = atree
self.l = atree
# and some accessors etc...
class Leaf:
def __init__ (self,anint)
self.aninit = aninit
# AND so on....
Is this something that I can do? Should I use the parser library and make a
preprocessor? Is this to hard to do that way? Is there an easier way?? Am I
missing something?
Cheers!
More information about the Python-list
mailing list