在 2011-04-05二的 15:06 +0800,Nor Jaidi Tuah写道:
> On Tue, 2011-04-05 at 14:14 +0800, Xu Ming wrote:
> > Parameters passed to method by 'out' should be assigned inside the
> > callee before it returns. But this compiles successfully:
> >
>
> > void method(ref int a,out int b)
> > {
> > a++;
> > }
> >
>
> Furthermore, the compiler will accept something like this:
> void method(ref int a,out int b)
> {
> a = b; // b not initialized yet!
> a++;
> }
>
> Perhaps vala is putting some default value for out parameters.
>
Yes, it is. Review the c code generated by valac and you can find that
int value is initialized to 0 by default if not assigned explicitly,
which has nothing to do with 'out'.
Compiler did nothing special for 'out' parameters. This is not in
accordance with the language specification because they should be
explicitly given a value.
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list