chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] [PATCH] Add unexport form for modules


From: megane
Subject: Re: [Chicken-hackers] [PATCH] Add unexport form for modules
Date: Tue, 04 Jul 2017 19:49:37 +0300
User-agent: mu4e 0.9.18; emacs 24.4.1

John Cowan <address@hidden> writes:

> On Tue, Jul 4, 2017 at 10:11 AM, megane <address@hidden> wrote:
>
> Working with the export list is painful without some syntax support. You
>> end up repeating every identifier name otherwise.
>>
>
> I consider the repetition to be a virtue rather than a vice.
>
> The whole purpose of modules is to control what identifiers are exposed to
> the outside world and what identifiers are private.  If you want to expose
> everything, why bother with a module at all?  Just have a plain file that
> is included rather than imported.

I, too, want to precisely control what a module exports and what it
doesn't.

I think keeping the * export would be nice for beginners coming from
languages where export control is less manual work. I myself don't care
anymore.

>
> Having an explicit export whitelist separates implementation from
> interface: the interface is whatever is exported, whereas the
> implementation can change freely, adding or removing non-exported
> procedures with no risk of affecting clients of the module in any way.

Identifier names are a good start. You also need to be careful about the
type signatures, and maintained state.

>
> How about a pair of syntax called export-all and export-none (or
>> similar). Every definition lexically after export-all up to a export-none
>> is exported and vice-versa.
>>
>
> That's the C++ style, and it works in that language because typically
> classes contain only declarations, not definitions.  It would be very
> error-prone in the Scheme context; for example, if you wanted to refactor
> an exported procedure with a helper, you'd have to remember to bracket the
> helper with (export-none) and (export-all).  Also, it is not Scheme style
> to have such hidden scope: if you wanted to do it so, you'd want
> (export-all <definition> ...) and (export-none <definition> ....).

Those are good suggestions.

>
> But if you want syntactic sugar, consider having exported-define,
> exported-define-syntax, etc. in Java style.

Yes I've been using clojure style function definitions (defn for normal
exported definition and defn- for hidden) for n years. It helps a lot.



reply via email to

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