Re: [Vala] Ellipsis syntax (Was: Ellipsis as an argument..)
- From: Yu Feng <rainwoodman gmail com>
- To: "Didier \"Ptitjes\"" <ptitjes free fr>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Ellipsis syntax (Was: Ellipsis as an argument..)
- Date: Fri, 27 Feb 2009 02:30:12 -0500
Hi,
On Tue, 2009-02-24 at 22:43 +0100, Didier "Ptitjes" wrote:
....
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 ?
What about picking up the old and dirty va_args?
Example:
public static void foo(string fmt, params va_args valist) {
vprintf(fmt, valist);
}
public static void foo2(string fmt, params va_args valist) {
int i = valist.next_int();
void* p = valist.next_pointer();
}
Compiled CCode:
void foo(const char * fmt, ...) {
va_list valist;
va_start(fmt, valist);
foo_valist(fmt, valist);
va_end(fmt);
}
void foo_valist (const char * fmt, va_list valist) {
vprintf(fmt, valist);
}
void foo2(const char * fmt, ...) {
va_list valist;
va_start(fmt, valist);
foo2_valist(fmt, valist);
va_end(fmt);
}
void foo2_valist (const char * fmt, va_list valist) {
int i = va_arg(valist, int);
void* p = va_arg(valist, void*);
}
This can give us the most C compatibility. But va_args has to be a
special type handled by the compiler.
Best,
Yu
Thanks
Shawn
Best regards, Didier.
_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]