how to stop the annotation of lists by filenames?



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