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

LIST_APPEND SET_ADD DICT_ADD operators #190

Open
obriencj opened this issue May 5, 2018 · 2 comments
Open

LIST_APPEND SET_ADD DICT_ADD operators #190

obriencj opened this issue May 5, 2018 · 2 comments

Comments

@obriencj
Copy link
Owner

obriencj commented May 5, 2018

these operators are used by python to produce list-comprehensions and the like. Our list-each and set-each macros look up and call the append / add methods directly. It might be nice to mimic python more by providing these operators.

@obriencj
Copy link
Owner Author

obriencj commented May 6, 2018

maybe #set-add #list-append and #dict-add to help avoid namespace collisions and denote they're operators?

@obriencj
Copy link
Owner Author

obriencj commented May 6, 2018

Because of the nature of these operators, it may be best to implement list-each, set-each, dict-each as specials.

The change of heart is because of two features of these op codes:

  1. the opcode takes a variable offset for the list, set, or dict to add into, rather than popping it from the stack like a normal operation
  2. the opcode leaves the collection in place after consuming the new value. This is so that the collection can be reused in this manner over and over without having to re-load it, and so that at the end of the loop it can be the result.

If I create these specials, I no longer need to enter a new namespace or function, I just need to do a simple loop (not even one that can break).

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