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

defer, %defer, and ?defer #110

Closed
7 of 10 tasks
andrewrk opened this issue Feb 6, 2016 · 4 comments
Closed
7 of 10 tasks

defer, %defer, and ?defer #110

andrewrk opened this issue Feb 6, 2016 · 4 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Feb 6, 2016

  • defer expr, evaluates expr when control flow leaves scope
  • %defer expr, evaluates expr when control flow leaves scope by returning an error from the function
  • ?defer expr, evaluates expr when control flow leaves scope by returning null from the function
  • defer valid at statement level only in parser
  • error when there is a defer with 0 block exit paths
  • make the returns respect defer
  • error when there is a %return in a function with void return type
  • optimization where the node remembers if it was error wrapped from a payload, if that is returned, then we know it is not an error. when %return returns it is for sure an error. otherwise we have to do a runtime check to find out if it's an error and then do the defer expression
  • better defer implementation - instead of duplicating the code at every exit path, make a basic block that exit paths point to.
  • error for control flow inside an expression exiting the defer expression scope? for example you probably shouldn't be able to return in a defer.
@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Feb 6, 2016
@andrewrk andrewrk added this to the debut milestone Feb 6, 2016
andrewrk added a commit that referenced this issue Feb 6, 2016
andrewrk added a commit that referenced this issue Feb 6, 2016
andrewrk added a commit that referenced this issue Feb 6, 2016
andrewrk added a commit that referenced this issue Feb 7, 2016
also defer only valid at statement level now

see #110
@ddevault
Copy link

Not sure how it would take shape, but it would be nice to be able to assign and defer in one go (sugar wise). Something to this effect:

const foo %defer deallocate_foo(foo) = %return try_to_foo();

Further sugared:

const foo %defer deallocate_foo = %return try_to_foo();

With the implication being that deallocate_foo just takes one parameter that is foo.

@andrewrk
Copy link
Member Author

The point of this syntax is so that the deallocation becomes "attached" to the allocation and you can't accidentally separate them. Is that right?

@ddevault
Copy link

No, it's just sugar to make it so you can write less code.

@andrewrk
Copy link
Member Author

Moved to individual issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

No branches or pull requests

2 participants