[Vala] Ellipsis syntax (Was: Ellipsis as an argument..)



Hello Shawn!

[Mode Introduction on]
I take benefit of this first post to introduce myself. I did some little contributions these days to the Vala project, but never subscribed (ouuh shame!) to the vala-list. These days, I do mainly work on SHR's projects and in some tinier way to FSO. At SHR (and FSO), we are massively switching to Vala. For our own projects, I'm mostly interested in helping Vala for its compile-time and runtime-time integration of gobject-introspection, and dbus support (async, errors, ...).
[Mode Introduction off]

So.. You can probably guess my question. I have the need for a method to
take an arbitrary number of args. I know ellipsis' are the key, but
haven't a clue as to how to access them from there. I've looked through
the docs, examples and other's code to no avail. I have seen reference
to va_list, va_state and va_end from within c, but wondered if vala
didn't do some magic and auto cast them as an array object.

..or..
is it more practical/better to just pass those as a single array object?

In either case, I'd love to see the syntax for the ellipsis for my own
curiosity..

I asked the same to Jürg on the channel, and it appears there is only for now a syntax for typed ellipsis. The following is an example of the syntax :

public static void foo(params string[] args) {
        // ...
}

So if your arguments can be subclasses of GObject, you could use "params Object[] args".

It appears that there isn't yet any syntax to query about an untyped ellipsis content. I think this is the best occasion to make proposals.

I have none to propose as the only I know of is the one of Java, and it is typed as Java supports auto-boxing.

I would be glad to implement it and propose a patch if something gets consensus. Any ideas ?

Thanks
Shawn

Best regards, Didier.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]