Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Nate Nystrom <nystrom@cs.cornell.edu>
Cc: caml-list@yquem.inria.fr, Andrew Myers <andru@cs.cornell.edu>
Subject: Re: [Caml-list] Possibility of Nested Classes and Nested Inheritance?
Date: 25 Dec 2004 11:26:49 +1100	[thread overview]
Message-ID: <1103934408.6201.215.camel@pelican.wigram> (raw)
In-Reply-To: <CFEDD357-55E4-11D9-9B74-000A958B604C@cs.cornell.edu>

On Sat, 2004-12-25 at 06:48, Nate Nystrom wrote:

>  Using the traditional visitor pattern,
> you will have to parameterize the visitor class on every AST node class.

Given a term for expressions, and a map_expr function
which is a functional visitor, I can write:

let rec cfold x = 
	match map_expr cfold x with
	| `Add (`Int a, `Int b) -> `Int (a + b)
	| other -> other

The fact that this formulation admits any number of extra
variants without change is a problem! I could add
a new term `Sub for subtraction and forget to add
the code to fold subtraction of constants.

In fact I have done just that, it took several hours 
to find the bug.

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net




  reply	other threads:[~2004-12-25  0:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20041217184433.GA1036@balm.cs.cornell.edu>
2004-12-24 19:48 ` Nate Nystrom
2004-12-25  0:26   ` skaller [this message]
2004-12-25 10:59   ` Jacques Garrigue
2004-12-27  2:24   ` Jacques Garrigue
2004-12-16 14:59 Jørgen Hermanrud Fjeld
2004-12-16 21:50 ` [Caml-list] " John Prevost
2004-12-17  1:31 ` Jacques Garrigue

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=1103934408.6201.215.camel@pelican.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=andru@cs.cornell.edu \
    --cc=caml-list@yquem.inria.fr \
    --cc=nystrom@cs.cornell.edu \
    /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