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

Use implicit convention for extern function names? #681

Open
Timmmm opened this issue Aug 30, 2024 · 3 comments
Open

Use implicit convention for extern function names? #681

Timmmm opened this issue Aug 30, 2024 · 3 comments

Comments

@Timmmm
Copy link
Contributor

Timmmm commented Aug 30, 2024

I was thinking... instead of this:

val rem_round_zero = {ocaml: "rem_round_zero", interpreter: "rem_round_zero", lem: "hardware_mod", c: "tmod_int", coq: "Z.rem"} : (int, int) -> int

Might it not be better to just have something like

extern val rem_round_zero : (int, int) -> int

And then the names actually used for each backend are constructed by convention. E.g. OCaml gets SailExtern.$name, C gets sail_extern_$name, interpreter gets $name (or sail_extern_$name?, etc.

It's a little bit more "magical" and less greppable/discoverable. But it means the Sail code doesn't have to care about a list of backends any more.

@Alasdair
Copy link
Collaborator

This would be nice, but I'm not sure how easy it would be to go back and clean everything up to make this work without causing a lot of backwards-compatibility headaches.

We do also allow:

val f : {c: "some_fast_implementation"} : T

// slow Sail implementation for other backends
function f() = ...

which would be a bit harder with this simpler scheme.

@Timmmm
Copy link
Contributor Author

Timmmm commented Sep 12, 2024

Good point. I also saw some declarations like:

val foo = "foo" : T

What does that mean? Is that from a time when there was only one backend or something?

@Alasdair
Copy link
Collaborator

That's for when the name is the same in all the backends, it's a shorthand for {_: "foo"}

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