unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Lynn Winebarger <owinebar@free-expression.org>
Subject: comments on new-model.txt
Date: Wed, 4 Sep 2002 20:22:25 -0500	[thread overview]
Message-ID: <02090420222526.19624@locke.free-expression.org> (raw)


   Marius has written a detailed proposal for a new model, most of
which is dedicated to the nature of modules and scoping rules.
I'm glad he did, because Guile needs some clear direction on
this front.  That said, I'm a little distressed by the proposed
module/variable semantics.
    Before directly commenting, I would like to point out that there
are at least 3(*) orthogonal choices to be made in defining a type of 
environment:

(1)  Is the environment lexically closed or open?  That is, can
      new bindings be added to it, or is the set of
      bindings immutable once initialized?
(2)  Is it a black box to code defined externally?  In other words,
      can values be exported or not?
(3)  Is the code that uses the environment a body or interactive?
      In a (lambda) body, there is a well-defined lexographic 
      boundary between definitions (both variable and syntax)
      and other code (both before and after macro expansion).  
      In an interactive environment, executing
      a lambda at one point in time can result in a "variable not bound"
      error, when at other times it might not.

  Environments that are open in sense (1) are usually referred to as
top-level, though there is no absolute reason such an environment
must in fact be at the top-level. 
   The properties described by (2) could also be called closed and
open.  Indeed, compiler writers refer to exported values as ones
that have escaped (from the optimizer, perhaps).  Unfortunately,
that nomenclature is easily confused with (1).
    Marius' proposed system makes choices <open,open,interactive>.
If by a module we mean a set of code that is meant as a unit for
separate compilation, I believe the right choices are <closed,open,body>
It may be desirable to have other types of environments readily available
as well (perhaps "top-level" environments for each thread that inherit
from a global "top-level" environment?), but I don't believe they should
be considered part of the module system.
    There is no reason to require macros to always be macros.  R5RS does
not have any such requirement and there are plenty of compilers for it.
     I do not agree with the stated use of the word "variable".  That term
has such a standard definition that I believe it is only confusing to
recast it to mean "generic box" (in the "smart variable" case).  A
(global/top-level) variable is precisely its name in a program.  If you
want to make a special generic kind of box that, when bound to
a variable is, let's call it "transparently generic", go for it, but don't
say variables don't have names.
    Rather than tying imported variables to solely to modules, I believe
GUILE should adopt 2 new types of variables, extloc and extvar (or
whatever) corresponding to ilocs and variables, but carrying a reference
to their environment with them.  Space might be conserved by
pointing into a table of environments rather than using a whole
pointer.  In this way we can untie option 2 from options 1 and 3.
    To handle optimization, I believe we could adopt special forms
that import values and bind them to local (possibly immutable) variables.
So (import <module> <variable> ...) would give you a variable such
that side-effects on it are seen by <module>'s code. 
import->local would bind the variable locally to its value in <module>,
                     preserving (im)mutability
import->local/mutable would bind a locally mutable copy.
import->local/immutable would bind a locally immutable copy.
    I believe these would be sufficient for compiler optimizations.  
A "core" module would contain all the basic scheme forms (immutable)
and these could be imported/localized into the top-level interaction
environment, while most modules would just import them directly.

Lynn


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


             reply	other threads:[~2002-09-05  1:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-05  1:22 Lynn Winebarger [this message]
2002-09-05 19:06 ` comments on new-model.txt Marius Vollmer
2002-09-08 23:47   ` Lynn Winebarger
2002-09-09 22:55     ` Marius Vollmer
2002-09-10  0:30       ` Lynn Winebarger
2002-09-10  0:32         ` Lynn Winebarger
2002-09-10 19:56         ` Marius Vollmer
2002-09-10 23:15           ` Tom Lord
2002-09-11 17:38             ` Marius Vollmer
2002-09-11  7:28       ` Lynn Winebarger
2002-09-11 18:11         ` Marius Vollmer
2002-09-14  3:18   ` comments on new-model.txt [long] Lynn Winebarger
2002-09-22 22:13     ` Marius Vollmer
2002-09-24 20:03     ` Marius Vollmer
2002-09-28 23:01       ` Lynn Winebarger
2002-10-12 13:35         ` Marius Vollmer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=02090420222526.19624@locke.free-expression.org \
    --to=owinebar@free-expression.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).