Re: feature req: passing sequences
- Posted by mattlewis (admin) Feb 14, 2015
- 1527 views
This illustrates the problem in as little code as possible:
object junk = get_position() position(junk[1],junk[2]) -- this works position(junk) -- this crashesThis bit me when trying to do a string execution unit too. Even though junk contains all the necessary parameters in the correct order, i cannot pass it to position(). And now it's biting at me when writing a console "gui" for my irc.e, altho in a simple way i can get around simply by typing twice as much code.
Can this situation please be changed?
I've often wanted this. Obviously, it's how we pass parameters for routine id calls or the variable arguments for printf. The way to do this, I think is some sort of built in operator, let's call it param_unroll for now (it's verbose and kind of ugly, but it's obvious, so good for this discussion).
So:
position( param_unroll( junk ))
Now, what about more complicated situations?
foo( bar, param_unroll( baz ), bat, param_unroll( blat), junk )
This doesn't sound...overly difficult to implement, though probably not exactly simple once we get into the weeds. We'll need to do some temp assignments and turn those into parameters. In the interpreter at least, some additional bounds checking.
I don't think it requires any changes for the backend or even the translator. This is probably a purely front-end change (so, 100% euphoria code). Not that the front end is super simple or anything.
Although...we'll either need to go ahead and use call_func/proc or add some way to add default parameters and parameter error checking into the back end. So...maybe.
Matt