[mercury-users] Request for code review

Keith Braithwaite keith at keithbraithwaite.demon.co.uk
Tue May 27 08:40:28 AEST 2003


Folks,
I wanted to learn logic programming (the only programming style I've no 
experience with), and having dabbled in Haskell, Mercury looked like a 
good bet. So as to have something to do, I've set off writing some code 
to use in the game-play engine of the Go program I've been using as my 
excuse to learn Squeak Smalltalk. Anyway, coming from the XP camp, felt 
the need of a JUnit-like test framework as a sub-goal, and first 
functioning thing to write in Mercury.

Attached are the modules I've got to. What I'd appreciate is some 
pointers as to:
1) where what I've written isn't idiomatic Mercury
2) how this code could be improved, particularly
	a: is there any reflection like mechanism available to avoid having to 
give the name of the test function?
	b: what's to choose between the io__print and and io__write 
facilities? Or rather, how should I choose between them?
3) how could I use modes (or whatever) to strengthen the contract 
between module mtest and particular test modules, as with gotests. I've 
begun with type mtest__tests, but feel that there's much more to do 
there.

Let me also say that I'm very impressed with Mercury, both the language 
and the tool set! My first thought when I saw Mercury code was that it 
was ugly and verbose, but having learned more about what the syntax is 
for (and a little of how it go that way), I'm rather taken with it. 
Certainly, Mercury is very strongly in Brooks' program-system-product 
arena, and the syntax (and semantics) reflect that, so maybe it's 
inevitable that "hello world" is going to look silly.

Any comments welcomed.

Keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: go.m
Type: application/octet-stream
Size: 592 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20030526/c34babb1/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gotests.m
Type: application/octet-stream
Size: 919 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20030526/c34babb1/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mtest.m
Type: application/octet-stream
Size: 1155 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20030526/c34babb1/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.m
Type: application/octet-stream
Size: 294 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20030526/c34babb1/attachment-0003.obj>
-------------- next part --------------



More information about the users mailing list