[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] SRFI-99 - What is a variant type?
From: |
Thomas Chust |
Subject: |
Re: [Chicken-users] SRFI-99 - What is a variant type? |
Date: |
Mon, 15 Dec 2014 16:15:01 +0100 (CET) |
User-agent: |
Alpine 2.03 (LNX 1266 2009-07-14) |
On Mon, 15 Dec 2014, Bahman Movaqar wrote:
Reading the docs on SRFI-99 [1], I need some help understanding what is
a "variant type". Would someone please pass me a relevant link to read?
Hello,
a variant type is the same as an extensible tagged union type. Some
documentation about this functionality of the SRFI-99 egg can be found at
http://www.chust.org/fossils/srfi-99/wiki?name=variant+types. You can
define an abstract base type and a set of derived type cases using a
shorthand syntax with the egg.
I remember faintly that I used the same nomenclature as some library from
the Racket programming language ecosystem, but I can't seem to find it any
longer.
Many functional computer languages allow the definition of variant types
and support the deconstruction of values of those types using pattern
matching. The variant type functionality in the SRFI-99 egg allows just
that for Scheme as well. However, the variant types defined using the egg
are open in the sense that new type cases can be added to them
independently of the original definition. Whether that is a good or a bad
thing depends on the situation but it seems to fit in more nicely with the
dynamic nature of Scheme and with the way SRFI-99 works.
Ciao,
Thomas
--
When C++ is your hammer, every problem looks like your thumb.