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

Decide on which functions are "public" #1752

Open
doug-q opened this issue Dec 10, 2024 · 0 comments
Open

Decide on which functions are "public" #1752

doug-q opened this issue Dec 10, 2024 · 0 comments

Comments

@doug-q
Copy link
Collaborator

doug-q commented Dec 10, 2024

We don't currently have a notion of "public" functions.

In the spec, "main" is defined as the "entry point", but surely there are cases where the HUGR is a library and some subset of the top-level functions are "public".

The notion of publicity is important at least for:

  • removing unused functions (a public function and all it's transitive callees should not be deleted)
  • dataflow analysis (for a public function we cannot assume we know all callsites)

Maybe a FuncDecl is public, or maybe it is a private alias to a public function. It's not clear to me when the publicity of a FuncDecl would matter. (I suppose when deleting unused functions?

LLVM has the concept of "linkage" which contains this binary notion of publicity. Linkage has lots of details allowing it to model weak symbols etc.

We could:

  • add a public: bool field to FuncDefn,
  • establish a convention where hugr.public: true metadata means public.
  • leave it unspecified, anything that cares should take a set of nodes identifying all public funcs.
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

1 participant