gator icon indicating copy to clipboard operation
gator copied to clipboard

Fix Support for Canonical Functions

Open pauljoo28 opened this issue 4 years ago • 1 comments

Canonical functions are currently not being supported at all. Currently in /test-u/basics.lgl the following code results in the error: Fatal error: exception Gatorl.CheckUtil.TypeException("Line: 7 -- Invalid canonical function canon b _ab(a v)").

canon b _ab(a v) {
    return (v + [1., 1.]) as! b;
}

In fact if we change the code to the following,

canon b _ab(b v) {
    return (v);
}

we still get the same error indicating the the problem is not only in the casting as!.

pauljoo28 avatar Mar 26 '20 20:03 pauljoo28

Ah, fortunately, this is not an error but a feature! We now require in Gator that canonical functions map between two geometric objects. To fix this code, simply change the function to act on reference frames a and b rather than the raw types a and b.

For example, we might write:

canon cart3<b>.point _ab(cart3<a>.point v) {
    return (v + [1., 1.]) as! cart3<b>.point;
}

And we get the original intended behavior!

However, I will leave this issue open, since clearly the current error message is not helpful for debugging. Also, I should update the documentation to illustrate this updated behavior.

Checkmate50 avatar Mar 26 '20 20:03 Checkmate50