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

Allow transforming local function without putting restriction on the wrapping function #16

Open
kevinresol opened this issue Jun 9, 2017 · 8 comments
Assignees
Labels

Comments

@kevinresol
Copy link
Member

I would like to do this:

@:await
class Await {
  public function wrapper() {
    @:async function local() {
      // ...
    }
  }
}

Note that wrapper is not tagged by @:await nor @:async

@benmerckx
Copy link
Member

That means we'd have to check all expressions of every method to see if it contains the metadata. But if this is something you regularly need, we could enable it behind a flag and see how it goes?

@kevinresol
Copy link
Member Author

Or introducing another meta besides await and async which is used to only indicate there are something to get transformed inside?

@benmerckx
Copy link
Member

That's what @:await on a method is already there for?

@:await
class Await {
	@:await function wrapper() {
		@:async function local() {
			return @:await something();
		}
		// ... use local ...
	}
}

@kevinresol
Copy link
Member Author

Oh I thought @:await forces the function to return Void. If that's not the case, this can be closed.

@benmerckx
Copy link
Member

It doesn't :) It works as you proposed:

to only indicate there are something to get transformed inside

I've added a test here, but let's keep this open so I can add some info in the docs. I didn't before because I wasn't sure about the name (as @:await now has a different meaning on either class/method/expr). But after this time I don't think I'm going to come up with something better :)

@benmerckx benmerckx self-assigned this Jun 9, 2017
@benmerckx
Copy link
Member

Oh, wait I spoke too soon. A method marked @:await does force its return type to Void, but only once an @:await expression is used. I need a minute to check that restriction..

@benmerckx
Copy link
Member

So, this works:

@:await function wrapper() {
    @:async function local() {
        return @:await something();
    }
    return whatever;
}

But, this doesn't:

@:await function wrapper() {
    @:await something();
    return whatever;
}

Because it cannot get transformed to something that makes sense.

@kevinresol
Copy link
Member Author

Ok, then great. And the Void case is very understandable. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants