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

multiple productions on same symbol: object order not preserved #18

Open
nylki opened this issue Jan 22, 2017 · 0 comments
Open

multiple productions on same symbol: object order not preserved #18

nylki opened this issue Jan 22, 2017 · 0 comments

Comments

@nylki
Copy link
Owner

nylki commented Jan 22, 2017

lets say you have:

axiom: 'ABC'
productions: {
  'B>C': 'X',
  'A<B': 'Y',
  'B': 'Z'
}

This is currently allowed. (Internally a successors: [] is created).

All three productions on 'B' meet the context sensitive condition.
You would expect to have 'X' returned, because it is the first in the list.
This is however not guaranteed to be the case, because object property order is not guaranteed to be preserved! See eg: http://stackoverflow.com/questions/5525795/does-javascript-guarantee-object-property-order/38218582#38218582

This is an edge-gase and generally no problem for most L-Systems, but could still cause problems.

Solution

  • Recommended: use object-based productions like: successors: [{leftCtx: ...}, {leftCtx: ....}], because in that case, the order is preserved by the successors array.

  • setting productions via setProduction() in your prefered order

  • alternatively: change library. switch/allow to tuple-arrays in productions

@nylki nylki changed the title multiple productions on same symbol: object order issues multiple productions on same symbol: object order not preserved Jan 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant