[mercury-users] [petdr at miscrit.be: Report on the ICFP 2000 prog contest]

schachte at cs.mu.OZ.AU schachte at cs.mu.OZ.AU
Wed Sep 6 10:57:17 AEDT 2000


> It is instructive to note that one of the bugs that took the longest to
> find was in the following code:
> 
>     inside_sphere(Point, Trans) :-
> 	Point = point_to_object_space(Trans, Point),
> 	mag2(Point) =< 1.0.

That's an interesting bug; it's such an easy mistake to make, and so
hard to see.  The interesting thing about it is that the code doesn't
say what you intended, but you *could* have intended what you wrote, so
the language really can't find it for you.  Unless you require different
operators for assignment and equality testing, which would be too
horrible to contemplate.

Perhaps the best way to avoid this sort of bug would be through
feedback while editing.  A language sensitive editor could show the
first occurrence of each variable in the clause in a different color. 
Once you got used to that, you'd probably pick up that both occurrences
of Point in that line had the same color.

Anyway, how did you try to debug it?  I would have thought the
declarative debugger would have pinpointed it very quickly.

-- 
Peter Schachte                     The use of COBOL cripples the mind; its
mailto:schachte at cs.mu.OZ.AU        teaching should, therefore, be regarded
http://www.cs.mu.oz.au/~schachte/  as a criminal offense.
PGP: finger schachte at 128.250.37.3      -- E. W. Dijkstra 




--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list