Re: [Vala] enum access modifiers
- From: Luca Bruno <lethalman88 gmail com>
- To: Al Thomas <astavale yahoo co uk>
- Cc: vala-list <vala-list gnome org>
- Subject: Re: [Vala] enum access modifiers
- Date: Sat, 6 Dec 2014 15:27:14 +0100
Nested classes or whatelse type is always "static" from a Java view point.
So you access those enum values with test.a.TEST. There's no way those
types can be tied to a particular instance of the parent class.
I could not understand the rest of the mail, sorry.
On Sat, Dec 6, 2014 at 3:21 PM, Al Thomas <astavale yahoo co uk> wrote:
The Vala manual states that an enum takes an access modifier, from
https://wiki.gnome.org/Projects/Vala/Manual/Enumerated%20types%20%28Enums%29
:"enum-declaration:
[ access-modifier ] enum qualified-enum-name { [ enum-members ] }"
The following compiles and runs with Vala 0.26.0.33:
void main(){
var aa = new test();
print( aa.a.TEST.to_string ());
}
class test: Object {
private enum a {
TEST
}
}
and only gives a compilation warning about static
members:"private_enum.vala:3.9-3.12: warning: Access to static member
`test.a' with an instance reference
print( aa.a.TEST.to_string ());"
So it would appear the current implementation for enums is that they are
public and static. So is this an implementation bug because the access
modifier is ignored or a documentation bug because access modifiers for
enums aren't that useful?
What has brought this on is a patch adding the 'protected' access modifier
to the Genie parser - https://bugzilla.gnome.org/show_bug.cgi?id=690848
Generally I would say the 'public', 'private' and 'protected' access
modifiers allow a public interface for using and extending a class to be
defined a bit more clearly. So implementation details can be hidden with
'private', but also allowed to be extended with 'protected'. While 'public'
provides the accessible API. In that sense enum, as well as struct and
delegate, can be implementation details where access can be restricted.
Enum, struct and delegate are all type definitions so probably should not
be modifiable by a class sub-type, but readable so they can be accessed for
creating a variable of the right type. The patch has also highlighted that
'interface' has an access modifier. Surely an interface should always be
public? Although a method within an interface could possibly be protected
as a mixin for implementation only?
Any thoughts?
Al Thomas
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list
--
NixOS Linux <http://nixos.org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]