[CM] s7: warning if symbol is redefined and namespaces

Kjetil Matheussen k.s.matheussen at gmail.com
Wed Dec 7 04:35:48 PST 2016


On Wed, Dec 7, 2016 at 1:25 PM, <bil at ccrma.stanford.edu> wrote:

> load has a second argument, the environment to load into,
> which defaults to the root environment, so
>
> (let ()
>   (load "file.scm" (curlet))
>
> will place the top-level defines in file.scm into
> the local environment.  Similarly eval has an
> environment argument.
>
>
Excellent!



> I think that s7 currently doesn't warn about shadowing or
> redefining built-in names, though it does complain about
> (set! if 3) and the like.  lint.scm is equally
> lackadaisical.  I'll add optional checks in both places.
>
> It's surprisingly common in current scheme practice
> to use (say) 'list or 'string as a variable name --
> I wonder if this is actually a common-lisp trope
> that schemers are careless about?  It does lead to
> errors.
>
>
Shadowing a variable can be practical though.
What I'm especially worried about is writing two different functions
with the same name doing different things loaded from
two different files. Especially if loading 3rd party
scheme files. I did look quickly at s7.c if I could
add a hook, but I gave up quickly. If it's not much
work it would be great to be able to add a hook
which is called every time a global symbol is redefined.
Then I could show a warning window if the hook is called
during the first time a scheme file is loaded.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/mailman/private/cmdist/attachments/20161207/e87c14f2/attachment.html>


More information about the Cmdist mailing list