-
Notifications
You must be signed in to change notification settings - Fork 20
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
Builtin for push() #108
Comments
I am not keen on mixing push() for lists and dicts. Moving npush() to a compiler built-in would be nice I suppose but the separate names are helpful for understanding the type being manipulated. |
|
From what I can see, the Pan push() function works the same way as described here. Also, if the list being pushed to doesn't exist, an empty one will be created before being added to. If one of the arguments is a list itself, it will be appended as a list within the list being pushed to. E.g
would result in
For now, I will be trying to reproduce the behaviour of the Pan function into Java, without making any changes to behaviour. |
can we also clarify the behviour in dml blocks, so we are certain quattor/template-library-core#104 is not "a feature" |
@DChambersSTFC i'm not sure that mixing types in a list is a feature we want. |
@stdweird as discussed at the workshop, I'm pretty sure that quattor/template-library-core#104 isn't a feature, so it would be good to guard against it. |
Would it be appropriate to restrict all arguments to be the same type then? |
yes, i think so. |
I'm working on adding them currently as I'm also new to pan and using this issue to learn my way around. |
I would be good for @DChambersSTFC and your student to collaborate then! |
My main obstacle currently is referencing the object that called the function. Is anyone familiar on the use of the SetSelf function or knows of what I should be using? |
@jrha @DChambersSTFC are you keeping notes how to add this (incl docs and unittests)? it's was basically the first thing we were going to ask our student: document how and were to add code and docs and tests for a new builtin. maybe they can meet during q4b? |
@loomis Do you know how I can reference the object calling the function? |
@DChambersSTFC The "Context" object passed into the functions contains the full context of the compilation, including the current state of the object being built and the reference to "self". See the "Context" interface for the full list of available methods. Be very careful about mutating data structures that you access directly. They are often shared between object templates and direct mutation can cause concurrency issues or serialization of incorrect values. |
We decided at today's workshop in LAL that adding a built-in for push() would break all existing PAN code that uses the function from template-core. While cleaning up code might be possible, any change in behaviour between the current function and the built-in would lead to more subtle bugs so this is not worth the effort. |
😞 |
As mentioned in #53 and #103 it would be good to have a push-like function as a compiler built-in.
If the left hand side of the assignment is a list, it should
append
each of the passed arguments to that list.i.e.
Should result in:
If the left hand side of the assignment is a dictionary, it should
merge
the passed arguments.i.e.
Should result in:
The text was updated successfully, but these errors were encountered: