[PD] Re: [PD-announce] k_guile v0.0.1

Kjetil Svalastog Matheussen k.s.matheussen at notam02.no
Thu Jan 15 11:14:33 CET 2004


On Wed, 14 Jan 2004, Larry Troxler wrote:

> On Wednesday 14 January 2004 10:22, Kjetil Svalastog Matheussen wrote:
> >
> > Not exactly, all code is run in the same interpreter. But the (define)
> > thing is to let each instance run in its own namespace.
> >
>
> Is what you refer to as a "namespace", the same as what Common Lisp would
> refer to as a "closure"? In common lisp, such a function definition would
> create a "closure", which is I think a persistent "environment", and
> "environment" being a set of symbol bindings more or less.
>
I don't know what a closure is actually. But you can think of an
environment (which defines the nearest namespace) as a stack only
that it doesn't dissapear unless not referenced to anymore. Its not
complicated, I just dont know how to explain properly.


> > Say you have the following script called setnum.scm:
> >
> > (define number 0)
> > (pd-inlet 0 'setnum (lambda (n) (set! number n))
> >
> > If you have two [k_guile setnum.scm] objects in a pd patch and the
> > scripts are loaded into the global environment, "number" will
> > be written from both objects, because they both use the same "number"
> > variable.
>
> Ok, I'll try that - should be an interesting experiment.
>
> But still, the problem is, if I want to load Common Music for example, where
> would I do that?

In the CVS I added (load-if-exists "/etc/k_guile.scm")(load-if-exists
"$HOME/.k_guile.scm") into global.scm.

So if you put something like the following code:

"
(define common-music-loaded #f)
(define (load-common-music)
  (if (not common-music-loaded)
    (load "path-to-common-music/cm.scm"))
  (set! common-music-loaded #t))
"

into /etc/k_guile.scm, you can safely call (load-common-music) in your
scheme programs used for k_guile.


> Certainly I don't think it would work to re-load it upon
> every PD object instantiation,

Yest, that would not be a good thing.


> because who knows what when it first gets
> loaded. And certianly, the global symbols in Common Music should remane truly
> global.

(load file) always puts the file into the global environment, not matter
if you are in another environment.

-- 




More information about the Pd-list mailing list