Version française
Home     About     Download     Resources     Contact us    
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, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners