[Grace-core] inconsistent defaults with modules

Kim Bruce KIM at cs.pomona.edu
Fri May 30 10:26:41 PDT 2014


It just occurred to me that I believe we never discussed the default visibility of class declarations.  I believe that like methods and types, they should be public, but could understand arguments the other way.  For the most part it wouldn't matter as most classes are defined at the top level, but it would make a difference when importing libraries as I believe most top level classes being imported would be desired to be public.  (Of course it would also cause the least disruption for existing code if class definitions were by default public.)

The main thing is we should make a decision.

Kim

On May 30, 2014, at 8:37 AM, Andrew P. Black wrote:

> 
> On 30 May 2014, at 0:12, Kim Bruce <KIM at cs.pomona.edu> wrote:
> 
>> However, the default for modules is that everything is public, and in fact attempts to annotate definitions and variable declarations to be confidential are accepted by the compiler, but ignored.  I.e., they are always visible to importing modules no matter what annotation is attached.  Interestingly, annotating a method to be confidential is effective.  It makes it invisible in the importing module.
> 
> I think that this is a compiler bug.
> 
>> While it would be a bit of a pain to annotate definitions (and variables if needed) to be public, I believe this is much more consistent with the rest of the language design.  
> 
> I agree.
> 
>> I've always been puzzled why the compiler does not implicitly wrap the code in a module/program as an object and treat it like all the other objects in the program.  A relatively easy fix may be to fix the compiler to do this, treating an imported module exactly like the other objects.  Is there a resin this should not be done?
> 
> 
> Me too.  The compiler treats “top level” definitions completely differently from those inside objects.   If I recall, when we asked Michael about his, the reply was that this was for historical reasons.  That is, objects were introduced later, and the top level stuff was never reworked. 
> 
> My feeling is that the special treatment of “top level” should be removed, and all programs should be compiled as objects, in other words, that the implementation should be changed to conform to our current story about modules.   Bit this always seems like a fair bit of work, which was never urgent … until now, perhaps.
> 
> 	Andrew
> 




More information about the Grace-core mailing list