blitz-research / monkey

Blitz Research Monkey Source
225 stars 59 forks source link

Added Protected and Internal keywords #74

Closed swoolcock closed 9 years ago

swoolcock commented 9 years ago

Added Protected and Internal keywords to improve Monkey's encapsulation abilities. These are mutually exclusive with Public and Private.

Protected = Only visible to the current module and subclasses in any other module. Internal = Only visible to the current module and other modules in the same directory.

Internal could be improved if Monkey had better namespace support, so it's handy that Module is a reserved word!

Related forum topic: http://www.monkey-x.com/Community/posts.php?topic=9581

blitz-research commented 9 years ago

I like 'protected', will need to give it a good thrashing before adding to repos though.

I'm less keen on 'internal' though, esp. the implicit importance of file path. I think I'd prefer something like 'Friend mojo.graphics', ie: something a bit more selective and less 'magic'.

On Tue, Mar 17, 2015 at 10:52 AM, swoolcock notifications@github.com wrote:

Added Protected and Internal keywords to improve Monkey's encapsulation abilities. These are mutually exclusive with Public and Private.

Protected = Only visible to the current module and subclasses in any other module. Internal = Only visible to the current module and other modules in the same directory.

Internal could be improved if Monkey had better namespace support, so it's

handy that Module is a reserved word!

You can view, comment on, or merge this pull request online at:

https://github.com/blitz-research/monkey/pull/74 Commit Summary

  • Added support for "Internal" visibility modifier keyword that restricts member access to source files within the same directory.
  • Added support for protected keyword which restricts visibility to subclasses. It can be used alongside or instead of internal.
  • Changed Protected and Internal to be mutually exclusive and brought in a third keyword ProtectedInternal to apply both.
  • Removed ProtectedInternal keyword and left Protected and Internal as mutually exclusive.

File Changes

Patch Links:

— Reply to this email directly or view it on GitHub https://github.com/blitz-research/monkey/pull/74.

swoolcock commented 9 years ago

I understand your hesitance with the Internal keyword, but again we really need proper namespaces. If you'd like I can have a go at implementing Friend instead, drop Internal, and make another pull request. Edit: Internal could be reintroduced in the future with proper namespace support. Edit 2: I'll strip out Internal and just leave Protected, then redo the pull request so that you have the option of taking that by itself.

swoolcock commented 9 years ago

Recreated pull request as a feature branch: https://github.com/blitz-research/monkey/pull/75