[Maxima-commits] Maxima, A Computer Algebra System branch master updated. branch-5_27-base-72-g5287650
Subject: [Maxima-commits] Maxima, A Computer Algebra System branch master updated. branch-5_27-base-72-g5287650
From: Raymond Toy
Date: Sat, 26 May 2012 13:36:03 -0700
On 5/26/12 12:03 PM, Robert Dodier wrote:
> On 2012-05-24, Raymond Toy <toy.raymond at gmail.com> wrote:
>
>> I didn't check the diffs in detail, but were some variables defined by both
>> defvar and declare-top? I prefer defvar because you can add docstring.
>> Not so easy with declare-top. And aren't some of the same variables listed
>> in declare-top in multiple files? That sounds like a defvar to me in which
>> file is compiled/loaded first.
>
> Well, the distinction I have been making (not that this is entirely
> justified) is between declaring variables and defining them. I am
> thinking that there should be only one definition. Multiple declarations
> are OK, I figure.
>
> For what it's worth, I don't have any problem with replacing DECLARE-TOP
> with local DECLARE's. It would be tedious, that's all.
If you (declare (special *foo*)) (at top level), doesn't that make *foo*
special for all files compiled after this? I can't remember if this is
how it works, but if so, then that's the same as (defvar *foo*).
But if we remove unspecial option to declare-top, then declare-top is
fine.
>
>> Definitely agree with getting rid of the unspecial stuff. That should be
>> fairly straightforward since those are obviously intended to be special
>> only for that part of the file. The question is if you really want to put
>> a (declare (special foo)) everywhere it's needed.
>
> Well, the unspecial stuff indicates a local scope is intended. How about
> if stuff between special/unspecial is wrapped in a lexical block
> instead? E.g. replace
>
> (declare-top (special foo bar))
> (defun f ...)
> (defun g ...)
> (declare-top (unspecial foo bar))
>
> with
>
> (let (foo bar)
> (declare (special foo bar))
> (defun f ...)
> (defun g ...))
>
>
> What do you think?
>
Seems like that would work, but I think some blocks are a large fraction
of the file. That might make compilers complain. I hadn't thought of
this. I was just going to add (declare (special *foo*)) in all the
places that needed it, but that's definitely error prone.
Ray