caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Patrick M Doane <patrick@watson.org>
To: Pierre Weis <Pierre.Weis@inria.fr>
Cc: John Max Skaller <skaller@ozemail.com.au>, caml-list@inria.fr
Subject: Re: compilation of lablgl examples.
Date: Thu, 8 Feb 2001 00:55:42 -0500 (EST)	[thread overview]
Message-ID: <Pine.BSF.3.96.1010208000951.23452B-100000@fledge.watson.org> (raw)
In-Reply-To: <200102072202.XAA05588@pauillac.inria.fr>

On Wed, 7 Feb 2001, Pierre Weis wrote:

> [...]
> > I.e., polymorphic variants are more useful for prototyping,
> > since types do not need to be declared before writing
> > algorithms, yet the declarations can still be added later
> > when the design is solider to check just how solid it really is.
> 
> This is an interesting idea, worth a try. I'm still not sure the
> static type checker could handle gracefully the ``partial and
> exhaustive match'' problem, but I may be wrong...
> 
> [...]
> You should try on a small example, not on a huge optimizing compiler
> for a full fledged language!

I tried two experiments that had similar goals to the ones John originally
mentioned.

The first was changing an abstract syntax to use polymorphic variants. For
this particular syntax, different subsets of variant types wanted to be
used through the syntax. This seemed to be a good match for the
polymorphic variants and it really improved the code readability.

I eventually abandoned the approach though as I tried to develop and
prototype with it. Since the abstract syntax was quite large, the
"exhaustive match" errors were also very large. At one point I had to
switch the project back to using regular variants simply to fix a problem
I couldn't track down. Maybe some kind of tree-based difference algorithm
could improve the error messages here? 

The second experiment was with a set of types that were refined over time
in a fashion similar to a compiler. There were particular components that
were similar at every stage, but the associated data evolved throughout
the flow. My first attempt was to introduce polymorphic type variables to
the constructors but this became unwieldy because of cyclic dependencies
among types. I needed about 8 type variables for every type throughout the
module. This really hurt readability and couldn't be reasonably used.

Switching to polymorphic variants worked quite well. Although I quickly
discovered that the expressiveness of this approach is much better for
code that is purely functional. For example, you can't translate a
hashtable containing one variant type to a subset through imperative
update. Since a large body of the transformations I need to express were
imperative, this approach didn't work in practice.

I do think that it is reasonable to try this on a multi-phase compiler and
the approach could provide many benefits. It is probably best to test on a
small toy language first though.

Patrick Doane



  reply	other threads:[~2001-02-08 18:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-03 22:35 Peter Ronnquist
2001-02-05 17:41 ` John Max Skaller
2001-02-06 15:55   ` Pierre Weis
2001-02-07  1:28     ` John Max Skaller
2001-02-07 22:02       ` Pierre Weis
2001-02-08  5:55         ` Patrick M Doane [this message]
2001-02-08 16:33         ` John Max Skaller
2001-02-08 19:15           ` Pierre Weis
2001-02-08  2:06       ` Jacques Garrigue
2001-02-06  2:34 ` Jacques Garrigue
2001-02-06 18:00   ` Sven LUTHER
2001-02-07 12:09   ` Peter Ronnquist
2001-02-08  7:22     ` Sven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.BSF.3.96.1010208000951.23452B-100000@fledge.watson.org \
    --to=patrick@watson.org \
    --cc=Pierre.Weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=skaller@ozemail.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).