@:access query

43 views
Skip to first unread message

Laurence Taylor

unread,
Sep 16, 2016, 10:11:02 AM9/16/16
to Haxe
Can anyone tell me where you can use @:access?

More specifically, can you add it inline in an expression, or only on a class / member function?

How broad can you set the terms? Is a package level declaration recursive?

regards,
Laurence

Domagoj Štrekelj

unread,
Sep 17, 2016, 1:34:00 AM9/17/16
to Haxe
Hello,

The @:access metadata can be used on a class / field to forcefully allow the class / field access to the package / class / field specified as the metadata value.

To put it bluntly, if encapsulation is preventing you from accessing, say, a field you really need to access but don't want to expose, you can use @:access(package.Class.field) to forcefully allow access to that private field from within to accessing class.

The @:access metadata can be added to classes, static functions, or member functions.

If a package is specified for @:access, the definition is recursive. If a class is specified, all of its private fields are exposed.

There's more information in the Haxe manual.

I hope that cleared things up!


Domagoj
Reply all
Reply to author
Forward
0 new messages