Forums

private vs public

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

private vs public

Postby natter » Wed Feb 11, 2009 5:01 am

why is _foo accessed by _foo, while foo is accessed by .foo
why is not _foo accessed by ._foo

isnt this inconsistent?
natter
 
Posts: 20

Re: private vs public

Postby Charles » Wed Feb 11, 2009 9:18 am

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).
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 59 guests