Page 1 of 1

private vs public

PostPosted: Wed Feb 11, 2009 5:01 am
by natter
why is _foo accessed by _foo, while foo is accessed by .foo
why is not _foo accessed by ._foo

isnt this inconsistent?

Re: private vs public

PostPosted: Wed Feb 11, 2009 9:18 am
by Charles
Perfectly consistent syntax isn't necessarily enjoyable in practice (think LISP).

Note that _foo is not allowed for arguments, locals or type declarations. So it already indicates a member.

Visually, _foo is very distinguishable from locals and types. Also, in an environment with intellisense/autocompletion the underscore will immediately limit the choices down to underscored members (similar to how . would limit choices down to members).

Finally, in practice, I found ._foo to be redundant (Cobra use to allow that).