chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] Regarding the hide declaration, #1376


From: Peter Bex
Subject: Re: [Chicken-hackers] Regarding the hide declaration, #1376
Date: Tue, 6 Jun 2017 11:07:56 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, Jun 06, 2017 at 11:01:30AM +0200, address@hidden wrote:
> > First, let me ramble some:
> > 
> > 1. If you hide an exported identifier the compiler is free to drop the
> > actual definition from the compiled object. This happens without any
> > warnings currently and you get a runtime error if you try to use the
> > identifier.
> > 
> > 2. If an identifier is not exported I think it's safe to declare it hidden.
> > 
> > 3. As you see from the tests, the patch I provided seems to work as it's
> > supposed to. That is, it unexports identifiers using the hide
> > declaration. None of my code broke when I recompiled all eggs I'm using.
> > Just FYI.
> > 
> > Second:
> > 
> > I think there should be a way to remove identifiers from the module export
> > list. I'm happy to try adding an unexport syntax form if that's a good
> > idea (that's why I started this thread).
> 
> I'm not oppossed to an unexport mechanism in general, but declarations
> are not the proper way to address this. Just like qualified symbols they
> are a leftover of the older, unit-related method of namespace management.
> The fact that "declare" is not available in evaluated code should also
> indicate that we should find something different. User code should avoid
> declarations, unless it is truly necessary. Modules do the hiding 
> automatically
> for unexported identifiers, and I think this is much cleaner and simpler.

+1.

That's the whole point of modules.  Not allowing the definition to be
dropped (or inlined) even if it's never used nor exported would be very
counter-intuitive, especially to people who don't use any declarations,
which would be most people.

It's an important within-module optimization to drop the identifier.  If
we made it official that identifiers aren't dropped, people will start
relying on internal implementation details like the module#identifier
syntax even more.  At some point we might decide to change that, and then
all your code will break if you rely on this.

If you want to "hide" some symbols from the export list but keep them
for internal use in an egg, just put them in a different module.  If you
don't install that "internal" module's import library, it won't be usable
by users.  Besides, you can still install it but just not document it :)

Cheers,
Peter

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]