Skip to content

Decide on which functions are "public" #1752

@doug-q

Description

@doug-q

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions