Closed swoolcock closed 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
- M modules/trans/decl.monkey https://github.com/blitz-research/monkey/pull/74/files#diff-0 (62)
- M modules/trans/parser.monkey https://github.com/blitz-research/monkey/pull/74/files#diff-1 (20)
- M modules/trans/preprocessor.monkey https://github.com/blitz-research/monkey/pull/74/files#diff-2 (4)
- M modules/trans/toker.monkey https://github.com/blitz-research/monkey/pull/74/files#diff-3 (2)
Patch Links:
- https://github.com/blitz-research/monkey/pull/74.patch
- https://github.com/blitz-research/monkey/pull/74.diff
— Reply to this email directly or view it on GitHub https://github.com/blitz-research/monkey/pull/74.
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.
Recreated pull request as a feature branch: https://github.com/blitz-research/monkey/pull/75
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