Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Binding function calls #75

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

Comments

Projects
None yet
3 participants

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?

@olaf-k olaf-k added the enhancement label Feb 24, 2014

Member

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.

PK1A added a commit to PK1A/hashspace that referenced this issue Feb 24, 2014

@PK1A PK1A closed this in dbe3402 Feb 25, 2014

@PK1A PK1A reopened this Feb 25, 2014

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