Varlists, again

It seems a bit ad-hoc, but for variable arglists I might just have them consume all the arglists that are the right shape. And if there’s a vararg inside it, then that will be all of them, of course.

Also, this is different from single varargs, but a varlist has to have at least one list.

var three_args = fun `(a, b, c) (...)
var two_args = fun `(a, b) (three_args) # returning a function
var any_args = fun `(`args) (two_args)

# two_args gets first two lists, three_args gets last
two_args(1, 2)(3, 4)(5, 6, 7)

# two_args gets all the arglists, three_args gets none
two_args(1, 2)(3, 4)(5, 6)

# again, any_args gets all the lists
any_args(1)(2, 3)(4, 5, 6)(7, 8) 

Perhaps returning another function from a `(`args)-type function should issue a warning.

Another variation on this, based on the awkwardness of typing that example just now: perhaps there should be some special syntax for collapsing arglists. Perhaps something like:

# same as two_args(1, 2)(3, 4)(5, 6)
two_args(1, 2; 3, 4; 5, 6)

Maybe the semicolon and comma aren’t distinct enough for this. I’m unsure what else to use though, if anything.

With this decision made, at least, I suppose I can start finally working on the parser! Hooray! :D

Leave a Reply

You must be logged in to post a comment.