Subject: how to pass the name of a variable as argument?
From: Richard Fateman
Date: Sat, 3 May 2008 07:30:55 -0700
Actually, common lisps must also support dynamic scope, but you have to
declare those
names to be "special". I suppose Maxima could do the same.
> -----Original Message-----
> From: Oliver Kullmann [mailto:O.Kullmann at swansea.ac.uk]
> Sent: Saturday, May 03, 2008 12:36 AM
> To: R Fateman
> Cc: maxima at math.utexas.edu
> Subject: Re: [Maxima] how to pass the name of a variable as argument?
>
> Ha, in my library I use quite a bit of dynamic scoping!
> And since this is the only means in Maxima/Lisp, as
> far as I see, to got some form of polymorphic behaviour,
> it seems also necessary to me.
>
> Only due to dynamic scoping you can make good use of "global"
> variables, since when calling a function you can make
> it act similar to some form of inheritance.
>
> So dynamic scoping seems *essential* to me:
> Back in the old days polymorphism wasn't much
> of an issue, and structured programming was
> the king, so I don't think those "good old
> arguments" have such much relevance anymore.
> Maxima without dynamic binding looks crippled to me.
>
> Oliver
>
>
> On Fri, May 02, 2008 at 01:44:23PM -0700, R Fateman wrote:
> > Robert Dodier wrote:
> > > On Thu, May 1, 2008 at 6:14 PM, Oliver Kullmann
> > > <O.Kullmann at swansea.ac.uk> wrote:
> > >
> > >
> > >> Since global variables should be avoided,
> > >>
> > >
> > > Bear in mind that, in Maxima, effectively ALL variables
> are global variables,
> > > or, more precisely, global variables and local variables
> act the same.
> > > All variables have dynamic scope, not lexical scope.
> > >
> > > As you doubtless know, dynamic scope can lead to subtle
> misbehavior.
> > > A lexically-scoped user language could be very useful.
> > > Instead of revising the existing Maxima language, at this
> point I think
> > > the easiest way to get lexical scope is to run a
> different language
> > > on top of Lisp. One possibility is Python; there is a CL
> implementation
> > > of Python name CLPython. The developer is talking about porting it
> > > to SBCL.
> > >
> > <snip>
> > The Macsyma/ Maxima language is modelled on Algol 60, a
> language which
> > was sort of misunderstood when implemented at MIT.
> > The mistake was to adopt the dynamic scope of Maclisp in
> the Macsyma
> > language. The use of dynamic scope in lisp 1.5, according to John
> > McCarthy, was a mistake. Subsequent experiments at MIT in
> lisp-like
> > languages got the Algol 60 lexical scope "right". It
> resulted in Scheme.
> >
> > Now if you want to adopt lexical scope in Maxima, I think
> it is not
> > necessary to change the syntax or language at all, just the
> implementation.
> > (I am assuming that definition of procedures within
> procedures would be
> > handled properly...)
> > That is, the surface syntax would look identical. There is
> no need to
> > adopt python, or java or C# or ....
> >
> > Would this break existing programs? Maybe some. It is my
> understanding
> > that Maple, between versions 9 and 10 (I think) changed the
> language
> > implementation from dynamic to lexical scope. And there is
> way way more
> > code in the Maple language than in Maxima top-level syntax.
> >
> > Most programmers probably don't understand the scoping
> issues and use
> > only global variables or local variables, and do not nest
> procedures.
> > So it will not make any difference in their code.
> >
> > There is another issue which has to do with 2-lisp vs
> 1-lisp semantics,
> > and whether you can have two bindings for the same name, a
> function and
> > a variable, or just one.
> > That is, can you do f(x):=.....
> > and also f:3.
> > or will the second assignment over-write the first.
> >
> > Common Lisp, and Maxima, is a 2-language. Scheme is a 1-lisp.
> >
> > Now it may be appropriate to build another front end,
> interpreter, etc,
> > for Maxima, based on python. Probably not too hard. There
> is, for example,
> > another front end for Macsyma that used Matlab syntax. It
> could entirely
> > co-exist with the existing one..
> >
> > Or the alternative could be a front end for the lexically scoped
> > language that looks just the same, but is subtlely different.
> >
> > My 2 cents..
> >
> > RJF
> >
> >
> > _______________________________________________
> > Maxima mailing list
> > Maxima at math.utexas.edu
> > http://www.math.utexas.edu/mailman/listinfo/maxima
>
>