On Fri, Dec 03, 2010 at 15:38:38 -0800, Anatol Pomozov wrote: > I have a class that contains a field and method with the same name, > and Valac does not like it. What is the reason? Other languages > (C#/Java) allow it.
Pardon me. C# does NOT allow that: test.cs(3,17): error CS0102: The type `Foo' already contains a definition for `stop' Java allows it, but Java is one of very few languages where method isn't an object (it is an object -- function pointer -- even in C and C++). > You have to use () for method so you know whether > you access method or field. No, you don't. If there was just the method, this.stop would return a delegate calling it, so when there's also field stop, the statement would not be defined. > public class Foo { > public boolean stop = true; > > public boolean stop() { > return true; > } > } -- Jan 'Bulb' Hudec <b...@ucw.cz> _______________________________________________ vala-list mailing list vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list