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

In the parser, Assign should not be an Expression #870

Closed
jbdeboer opened this issue Apr 7, 2014 · 3 comments
Closed

In the parser, Assign should not be an Expression #870

jbdeboer opened this issue Apr 7, 2014 · 3 comments
Milestone

Comments

@jbdeboer
Copy link
Contributor

jbdeboer commented Apr 7, 2014

Currently, assignments (the Assign class) is a subclass of Expression. But this implies that you can watch assignments, but you can't.

Assignments should not be allows in watches (e.g. only in places where we pass them to Scope.apply()).

@IgorMinar
Copy link
Contributor

Allowing assignments makes many things, including dirty checking much harder because an expression that was expected to be idempotent would now have side-effects which we are not ready to handle.

@chalin
Copy link
Contributor

chalin commented Apr 8, 2014

From looking at the code, a little while back, I came up with a grammar; here is an excerpt from here that is relevant to this issue:

expressions:  expression (';' expression)?
expression: 
    literal
  | id args?                        # variable or function
  | expression '.' id args?         # member
  | expression '|' id filterArg*    # filter
  | expression '[' expression ']'
  | preOp expression
  | expression binOp expression
  | expression '?' expression ':' expression
  | expression '=' expression           # assignment

In the source code, the expressions non-terminal was referred to as "expression chain". Maybe "expression chain" should be renamed to "statements" so that the grammar might look like this:

statements:  statement (';' statements)?
statement: 
    expression                          # expression statement
  | expression '=' expression           # assignment
expression: ... same as above but without "assignment" 

Is this what you have in mind?

@mhevery
Copy link
Contributor

mhevery commented Apr 10, 2014

Sounds reasonable. I am a little concerned that such a change will complicate the parser.

It is true that you can't watch assignments, but you will get an error about that during AST conversion.

@mhevery mhevery modified the milestones: 0.10.0, 0.12.0 Apr 16, 2014
@vicb vicb modified the milestones: 0.12.0, 0.11.0 May 8, 2014
@chirayuk chirayuk modified the milestones: 0.13.0, 0.12.0 Jun 3, 2014
@vsavkin vsavkin modified the milestones: 0.14.0, 0.13.0 Jul 24, 2014
@rkirov rkirov modified the milestones: 0.14.0, 0.15.0 Aug 22, 2014
@rkirov rkirov closed this as completed Oct 10, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

8 participants