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

Binding function calls #75

Open
olaf-k opened this issue Feb 24, 2014 · 1 comment
Open

Binding function calls #75

olaf-k opened this issue Feb 24, 2014 · 1 comment

Comments

@olaf-k
Copy link

olaf-k commented Feb 24, 2014

I'm opening this issue to discuss the possibility to extend the binding mechanism to function calls.

Background:

Yes indeed - function calls should be supported, like in any expression. Having said that, the current function call binding should be improved so that function are automatically re-called when a bound element changes (and the function bound elements should be the function arguments + the function context (i.e. this) - in other words, when a direct property of a function context changes, the function should be called again to determine if the function result has changed (which is not the case today) - e.g.

  // x should be reprocessed if arg1 or arg2 or c changes, 
  // or if a direct property of c changes - e.g. c.foo++;
  {let x=c.getRating(arg1,arg2)} 

I obviously believe this would be a great feature to have. Now I imagine it less restrictive than that. The current proposal implicitly gets the elements to watch (the function arguments and its context) while I'd be more in favor to let the developer explicitly state that, so that a function could be re-evaluated based on external factors that are neither arguments nor the context.

When discussing this, @benouat suggested a way to do that based on modifiers which I find kinda neat, something like this:
<div class={watch(indicator)|classGenerator(arg)}>
Don't mind the syntax, the idea is essentially to tell Hashspace which function to be called and what to watch as target for re-evaluation.

What do you think?

@ymeine
Copy link
Contributor

ymeine commented Feb 24, 2014

+1 for the general idea, which requires more code from the developer but is more exact: this way you simply express dependencies of the result of a function.

Considering that this result depends only on its input arguments and its context is pragmatic, and this would avoid to the developer to have to explicitly add them every time. However, this is not exact in this case. Imagine for instance a function that computes its return value from the result of another function. With this proposal, we would just tell that the function depends on the other one if the latter's dependencies have been specified too (dependencies are transitive), otherwise just manually determine the actual list of dependencies.

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

No branches or pull requests

3 participants