Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Support for Canonical Functions #77

Open
pauljoo28 opened this issue Mar 26, 2020 · 1 comment
Open

Fix Support for Canonical Functions #77

pauljoo28 opened this issue Mar 26, 2020 · 1 comment

Comments

@pauljoo28
Copy link
Collaborator

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!.

@Checkmate50
Copy link
Contributor

Checkmate50 commented Mar 26, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants