Subject: how to stop the annotation of lists by filenames?
From: Oliver Kullmann
Date: Sat, 31 May 2008 20:17:40 +0100
Hi Stavros,
thanks a lot!
Actually, meanwhile due to the help of Andrej Vodopivec a very
similar solution is implemented, and works fine!
(Instead of the switch dontaddloadinfo, an optional
boolean argument for function "load" is introduced.)
But thanks for your example: It shows me another technique.
I was aware of dynamic binding (I actually use it a lot),
but I'm insecure about the combination of Lisp and Maxima,
and the design implications the different implementation options have.
I was thinking about rebuilding the system, because on the one
hand it's easy for me, and I wanted to avoid the warning
message arising from the redefinition.
But I guess that warning message is alright.
My special usage point-of-view is, that all what I'm doing
is part of the OKlibrary, this active multi-language open-source
platform for generalised SAT solving, so I always have to
think about how to obtain a reliable and maintainable solution, and
this for all users.
And from that point of view just building the system in a
different way is quite attractive. It's the design decision
between build-time and run-time. So well, now we have it
at run-time.
This brings me to the next question, and I will open a new
e-mail thread for that:
How can I incorporate code like your code below into my
open-source library (which redistributes it)?
Thanks for your help!
Oliver
On Sat, May 31, 2008 at 02:37:45PM -0400, Stavros Macrakis wrote:
> On Fri, May 30, 2008 at 3:06 PM, Oliver Kullmann
> <O.Kullmann at swansea.ac.uk> wrote:
> > 2) So I need an alternative load-function, which calls an alternative
> > mread which uses the trivialised add-lineinfo....
>
> Very easy.
>
> > a) One could introduce a switch, but apparently this would need a bigger surgery?
>
> No, zero surgery is necessary.
>
> > b) Perhaps easiest is to to create a new file, say, "NEW_mload.lisp",
> > which contains the definition of new_mload, just copied from the
> > existing sources, but using new_add-lineinfo (which is trivial).
>
> You don't need to modify mload.lisp, just redefine the add-lineinfo function:
>
> (setq $dontaddloadinfo nil) ; default is to add info
> (defun add-lineinfo (lis)
> (if $dontaddloadinfo lis ;;; <<< the main change
> (if (or (atom lis) (and (eq *parse-window* *standard-input*)
> (not (find-stream *parse-stream*))))
> lis
> (let* ((st (get-instream *parse-stream*))
> (n (instream-line st))
> (nam (instream-name st)))
> (or nam (return-from add-lineinfo lis))
> (setq *current-line-info*
> (cond ((eq (cadr *current-line-info*) nam)
> (cond ((eql (car *current-line-info*) n)
> *current-line-info*)
> (t (cons n (cdr *current-line-info*)))))
> (t (list n nam 'src))))
> (cond ((null (cdr lis))
> (list (car lis) *current-line-info*))
> (t (append lis (list *current-line-info*)))))))
> ) ; one extra parenthesis to match
>
>
> > This file would be injected into the src-directory at build-time,
> > hopefully compiled with the rest, and then I can choose between
> > these two load-versions, with or without annotations.
>
> You are thinking in terms of a statically compiled system. Things are
> much easier with Lisp. You don't need to deal with rebuilding the
> system and other messes!
>
> Just put the above code in a file, load it when you want, and set
> dontaddloadinfo as necessary at the Maxima level, e.g.
>
> dontaddloadinfo: true$
> load...
>
> or if you want it to only have local effect
>
> block( [dontaddloadinfo: true], ... load ...)
>
> This is a typical case, by the way, where Maxima's dynamic scope rule
> actually makes life much simpler. Of course in other cases it makes
> life much worse....
>
> -s