-
Notifications
You must be signed in to change notification settings - Fork 0
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
Passing multiple args to a function #4
Comments
I think I'll drop the current way tuples work and replace it by just using a tuple tag consisting of a type tag ( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my rewrite I'm using a
Stack
(similar to the Lua one) to store values of different types in a plainVec
. This allows me to save unnecessary allocations.Every time you call a dynamic function, you push the arguments to the stack, the function pops them off again and pushes the return value.
In my current experimentations (PR will follow soon), I've used tuples with the intention to always expect a tuple for function args.
This, however has two disadvantages:
vnodes_push_*
functions for tuples to C seems to be rather complicatedWhy is that a problem? Each segment of a path is basically a
u64
. So let's say we search for a node/foo/bar/other/meaning/ful/words
. The first segment we can pop (that's at the top of the stack) is"foo"
. So the root node knows it needs to go to thefoo
node. That's enough, we don't need to know any more. But if we need to pop the whole tuple, we can't pop just a single path segment. We'd need to pop the whole path, provide a rather large buffer for it or even allocate for it. That's not what we want.Thus, I think we should simply allow to push and pop multiple values to the stack for the function parameters. However, this has a drawback. We can't check if we have all the right types upfront and a node might pop too many elements from the stack. How should we deal with that? Pass an integer indicating the number of arguments?
The text was updated successfully, but these errors were encountered: