Thursday, February 18, 2010

On Comparison

I pretty printed the whole source code and found a few bugs. One most noteworthy is how I handle comparison on complex objects, I consistently miss a case.

I am not entirely happy about that simple mistake, and there doesn't seem to be a trivial fix I like. There are a few options:

  1. Keep it as it is, and handle all comparisons explicitly through the Ord interface, but live with potential bugs.
  2. Use some tagging scheme, for instance, unwind all structures to unique lazy lists of integers. Live with less potential bugs, and also, look at whether an inverse function for that would exist. I.e. serialization for free?
  3. Build a fast but simple comparison routine into the language runtime, which means the least code, a minimal chance of bugs, but is something I don't like since I'ld rather express everything in the language directly.
  4. Implement deriving as in Haskell.
  5. Anything I didn't think off....
No easy way out.

021810: I Like the second option the most, but, given time, I am going for the third.
021910: Wow, bad call. There turned out to be no point in doing anything general, since most of the equalities I employ are either a) very basic, there's no need for something elaborate, b) not basic but also not based on structural equality. I.e., in the compiler, the most difficult values are those of the ast, and these are all parameterized with the start-position of the expression, so none of the above schemes really work. It turned out to be easy with another scheme, though, so I am happy for the time being.

Stairway to Heaven...

No comments:

Post a Comment