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

Add syntax for global variables #169

Closed
doug-q opened this issue Mar 12, 2024 · 5 comments · Fixed by #236
Closed

Add syntax for global variables #169

doug-q opened this issue Mar 12, 2024 · 5 comments · Fixed by #236
Assignees

Comments

@doug-q
Copy link
Contributor

doug-q commented Mar 12, 2024

I would like to write a guppy program such as:

@guppy.global(float)
rot = 1.0

@guppy
main() -> float:
  return rot

which compiles to a hugr containing a global Const node representing rot, which would be some CustomConst including a symbol name and a type. This Const would be further lowered to an extern symbol during codegen.

The syntax used above is purely for explanation and I have no attachment to it.

@ss2165
Copy link
Member

ss2165 commented Mar 12, 2024

does this do the job? (it works now I believe)

rot = 1.0

@guppy
main() -> float:
  return py(rot)

@doug-q
Copy link
Contributor Author

doug-q commented Mar 12, 2024

does this do the job? (it works now I believe)

No it doesn't, although I accept this is a problem with my example. Perhaps It would be clearer to write rot = guppy.GlobalSymbol("rot"). The point is that I need this to compile to an external symbol. Your example will paste "1.0" wherever py(rot) is written.

@ss2165
Copy link
Member

ss2165 commented Mar 14, 2024

yes 👍
for compilation target, does this do the job: CQCL/hugr#233

@qartik
Copy link
Member

qartik commented Apr 2, 2024

I think it might be easier to share intent if we replace "global" with "extern"/
"external", e.g., ExternSymbol.

@mark-koch mark-koch self-assigned this Apr 3, 2024
@doug-q
Copy link
Contributor Author

doug-q commented May 29, 2024

CQCL/hugr#1123 Adds a CustomConst intended to be used here.

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

Successfully merging a pull request may close this issue.

4 participants