Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

feat(AstParser): Made the AST parser private to the scope (was: fix(parser/eval): fix for '"s" + ("m"|filter) + "e"') #758

Closed
wants to merge 13 commits into from

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Mar 18, 2014

closes #755

That's a 3-liner only but it really doesn't reflect the time spent in debugging !

@vicb
Copy link
Contributor Author

vicb commented Mar 18, 2014

@mhevery could you please check and merge so that I can rebase #753 which works well on top of that.

@vicb
Copy link
Contributor Author

vicb commented Mar 18, 2014

Seems like the Travis takes a long time, but it's ok on my repo https://travis-ci.org/vicb/angular.dart/builds/21039875

@chalin
Copy link
Contributor

chalin commented Mar 18, 2014

I believe that @pavelgj took out support for filter expressions not too long ago:

5bcea64, fix(parser): disallow filters in a chain and inside expressions

This was as a follow up to an issue that Günter Zöchbauer had raised, if I recall correctly (though I cannot find the original issue).

@vicb
Copy link
Contributor Author

vicb commented Mar 18, 2014

thanks for the ref @chalin.

@pavelgj I would appreciate your comments on this PR (it is needed for #753.)

@pavelgj
Copy link
Contributor

pavelgj commented Mar 18, 2014

Yes, this feature was removed as it was never meant to exist in the first place. This syntax IMHO is very unintuitive.

@chalin
Copy link
Contributor

chalin commented Mar 18, 2014

  • @pavelgj, the pipe syntax is used in other languages (see this post for some examples).
  • @vicb, given that filters are pure, are you sure that change detection works correctly with filters appearing as inner expressions (i.e. other than a top-level expression)? In particular with a list or map being passed as an argument to the filter (and the list or map being changed while its identity is preserved)?

@vicb
Copy link
Contributor Author

vicb commented Mar 18, 2014

@pavelgj I don't get what's unintuitive, could explain give some more details. This is what we have been discussing with @mhevery to make the AstParser private to the scope.

@chalin would you mind PR a test here ?

@pavelgj
Copy link
Contributor

pavelgj commented Mar 18, 2014

It's just my opinion, but @mhevery asked me to remove it to simplify things for change detection and deferred loading. If things changed I'm OK with bringing it back.

@vicb vicb added cla: yes and removed cla: no labels Mar 18, 2014
@pavelgj
Copy link
Contributor

pavelgj commented Mar 19, 2014

Why I find it unintuitive: when I read foo | bar the first thing that comes to mind is foo BITWISE_OR bar. Shell script is not my primary programming language. :)

@vicb
Copy link
Contributor Author

vicb commented Mar 19, 2014

Thanks for the explanation. Didn't get that as a lot of templating languages I know use |. One argument could be it's hard to find on an android keyboard :)

@vicb
Copy link
Contributor Author

vicb commented Mar 19, 2014

At least I noticed that CallReflective._eval and CallReflective._evaluateUncached do not accept filters as a parameter.

@kasperl I've handled to most trivial cases in the last commit. Would you mind handling other cases ? If yes, you can send a PR to my branch, I'll merge it.

I have not handled CallReflective nor assign(). I think the latest would need the filters as it eval.

Also it should not be possible to make the FilterMap a required param because of inheritence ?

@mhevery
Copy link
Contributor

mhevery commented Mar 19, 2014

Please revert 5bcea64 instead of this PR.

@vicb
Copy link
Contributor Author

vicb commented Mar 19, 2014

@mhevery 5bcea64 is two folds:

  1. disabling filters in expressions,
  2. disabling filters in chains.

The first point is already revert in this PR, is there a need to revert 2 ?

@vicb
Copy link
Contributor Author

vicb commented Mar 19, 2014

I'll merge "feat(AstParser): Made the AST parser private to the scope #753" here

@vicb vicb changed the title fix(parser/eval): fix for '"s" + ("m"|filter) + "e"' feat(AstParser): Made the AST parser private to the scope (was: fix(parser/eval): fix for '"s" + ("m"|filter) + "e"') Mar 19, 2014
@vicb
Copy link
Contributor Author

vicb commented Mar 19, 2014

@mhevery I question I forgot to ask is why filter are |filter:arg1:arg2 ?
I once again prefer Jinja style, ie |filter(arg1, arg2).

@chalin
Copy link
Contributor

chalin commented Mar 19, 2014

+1 for Jinja style (which also compatible with what is proposed for Dart).

@mhevery
Copy link
Contributor

mhevery commented Mar 19, 2014

We already have lots of People using the current style so unless there are technical reasons, I don't think we should be changing the syntax. The current syntax is from Django, historical reasons.

@chalin
Copy link
Contributor

chalin commented Mar 19, 2014

Support the Jinja style as an alternative syntax?

mhevery added a commit to mhevery/angular.dart that referenced this pull request Mar 20, 2014
@mhevery
Copy link
Contributor

mhevery commented Mar 20, 2014

I have tried to merge this in, but ran into issues. Could you look at my work and correct the remaining issues: https://github.com/mhevery/angular.dart/tree/pr-758

@zoechi
Copy link
Contributor

zoechi commented Mar 20, 2014

I find this |filter:arg1:arg2 very unintuitive.
Each time I didn't use filters for a while I have to look up the syntax.
Pre 1.0 would be a good time to drop 'for historical reasons'
Just my 0.1c

vicb and others added 7 commits March 20, 2014 12:38
This commit also:
- remove the previously registered watch,
- add an expression cache
closes dart-archive#739

This changes is a BC break:
- the "readOnly" parameter has been renamed to "canChangeModel",
- the semantic is inversed

Before:

    // Default to digest (readOnly = false by default)
    scope.watch(exp, fn);
	// Explicit flush
    scope.watch(exp, fn, readOnly: true);

After

    // Default to digest (canChangeModel = true by default)
    scope.watch(exp, fn);
	// Explicit flush
    scope.watch(exp, fn, canChangeModel: false);
@vicb
Copy link
Contributor Author

vicb commented Mar 20, 2014

@mhevery I think this PR is now OK:

  • I cherry picked your commit which make filters a required arg,
  • I have tried to remove my "optimization" that removes empty strings from expression (please check the penultimate commit),
  • I have added the last commit to rename scope.watch(readOnly) to scope.watch(canChangeModel)

Should be ready to be merged !

@vicb vicb mentioned this pull request Mar 20, 2014
2 tasks
@chalin
Copy link
Contributor

chalin commented Mar 20, 2014

@zoechi, #772 could use your 👍 if you agree with it.

@zoechi
Copy link
Contributor

zoechi commented Mar 20, 2014

of course, as many as you want 👍 👍 👍 👍 👍 (never saw how easy they are to insert).

I'm never sure if I annoy anybody if I add to many comments here.
It seemed to go in the right direction without repeating my opinion anyway 😉
Great work, anybody!

@chalin Is there any reason you referenced #722 ?

@chalin
Copy link
Contributor

chalin commented Mar 20, 2014

(Oups, mistyped: meant #772 ... )

@vicb
Copy link
Contributor Author

vicb commented Mar 20, 2014

hum... I have this strange bug

Chrome 33.0.1750 (Linux) ERROR
  Some of your tests did a full page reload!

Thanks I currently fail to narrow down :(

@vicb
Copy link
Contributor Author

vicb commented Mar 22, 2014

Closing, I'll open an other one, cleaned and rebased

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

Issue with the parser and filters
5 participants