Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: [Caml-list] Visitor pattern (was copy of parametrized object)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] Visitor pattern (was copy of parametrized object)
Bow-Yaw Wang wrote:

> Thanks a lot. Using polymorphic variants solves the problem
> beautifully. I'll reorganize my code. Thanks!
I use polymorphic variants almost exclusively.

They're much more expressive than the ordinary kind.

They're generally easier to program with too,
but there is one downside, and it is a BIG downside.

When you make a mistake, and your variants are
large, you can get 200++ line error messages.
The situation has been improved so that now
the compiler sometimes recognizes when you left
out a case (xxx has tag AAA but yyy doesn't).

I suggest that polymorphic variants require

a lazier, rapid prototyping style of programming:
build and test OFTEN so you know that when
there is an error, it had to be in the last
change you made. That way, you can often
ignore the content of the error message,
and just look direcly at the code for
an error.

Also: you will need to use type annotations
a bit more heavily to help localise errors.

John Max Skaller,
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: