Guido van Rossum wrote:

> I guess by "algebraic types" you meant enumerated types?

An algebraic type is somewhat more than that -- think
of it as something like a tagged tuple.

A less degenerate example would be (using a more
Haskell-like syntax):

   Tree t = Leaf t | Node (Tree t) (Tree t)

This says that a Tree of items of type t is either a
Leaf containing something of type t, or a Node containing
two other things of type Tree of t.

Leaf and Node can then be used as functions that construct
data items, e.g.

   let x = Node (Leaf 1) (Node (Leaf 2) (Leaf 3))

An equivalent Python data structure might be something like

   x = ('Node', ('Leaf', 1), ('Node', ('Leaf', 2), ('Leaf', 3)))

Which wouldn't be all that useful unless you could to
Haskell-style pattern matching on it as well. So you're
probably right that algebraic types don't really belong
in Python.

--
Greg
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to