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

Function purity #4

Open
rymiel opened this issue Jul 3, 2022 · 0 comments
Open

Function purity #4

rymiel opened this issue Jul 3, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@rymiel
Copy link
Member

rymiel commented Jul 3, 2022

Implement a heuristic which designates a function as "pure". There may be a want for "attribute" syntax i.e. @pure to force a declaration to be pure, and make it a compile time error not to.

A pure function doesn't touch any external state, or handle any references.

Purity could be used to replace two identical functions with the same parameters with the same result. Slices may be stack allocated when only ever passed into pure functions. Note that in this latter case, returning inhibits this optimization as well.

See CtorExpr compiler method and its many TODOs

@rymiel rymiel added the enhancement New feature or request label Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant