renaming files from within maxima



I am attaching the outputs of the 'renaming' problems for gcl, sbcl,
and cmucl.

Please let me know if you want to suggest other experiments.

-sen


>
>
> On Tue, 10 Jul 2007, Raymond Toy wrote:
>
>> Robert Dodier wrote:
>>> On 7/8/07, sen1 at math.msu.edu <sen1 at math.msu.edu> wrote:
>>>
>>>>> (defun $openw (file)
>>>>>  (open
>>>>>     (l-string file)
>>>>>     :direction :output
>>>>>     :if-exists :supersede
>>>>>     :if-does-not-exist :create))
>>>
>>>> %i3) build_info();
>>>>
>>>> Maxima version: 5.12.0
>>>> Maxima build date: 23:16 5/28/2007
>>>> host type: i686-pc-linux-gnu
>>>> lisp-implementation-type: CMU Common Lisp
>>>> lisp-implementation-version: 19c Fedora Extras release 7.fc6 (19C)
>>>
>>> Hmm. I can't tell what's going on here. You might have to
>>> take it up with the CMUCL developers. It seems strange that
>>> (open foo :direction :output :if-exists :supersede :if-does-not-exist :create)
>>> should cause CMUCL to complain. Maybe you can try it with
>>> another Lisp implementation.
>>
>> I checked version 19c (on Solaris), and (open "foo" ...) works just fine
>> even when "foo" already exists.
>>
>> Something else is going on.  Can you run "maxima -g" and when the error
>> is encountered, you should be in the debugger.  Then type "back" to get
>> a backtrace so I can see what's happening.
>>
>> Also note that cmucl supports a type of versioning for files, using
>> Emacs-style file versions like foo~1~, foo~2~ and so on.  I've forgotten
>> how to enable that, though.  You might have to modify openw to to make
>> this work.  Perhaps (open "foo" :if-exists :new-version)?
>>
>> Ray
>> _______________________________________________
>> Maxima mailing list
>> Maxima at math.utexas.edu
>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>
>
>

-- 
  ---------------------------------------------------------------------------
  | Sheldon E. Newhouse            |    e-mail: sen1 at math.msu.edu           |
  | Mathematics Department         |       				   |
  | Michigan State University      | telephone: 517-355-9684                |
  | E. Lansing, MI 48824-1027 USA  |       FAX: 517-432-1562                |
  ---------------------------------------------------------------------------
-------------- next part --------------
/*****************************************************
  renaming files with gcl
*/

(%i1) build_info();

Maxima version: 5.12.0
Maxima build date: 22:53 5/28/2007
host type: i686-pc-linux-gnu
lisp-implementation-type: GNU Common Lisp (GCL)
lisp-implementation-version: GCL 2.6.7

(%o1)
(%i2) system("ls -l file");
ls: file: No such file or directory
(%o2)                                  2
(%i3) s: openw("file");
(%o3)                        #<output stream file>
(%i4) printf(s,"Hello");
(%o4)                                false
(%i5) close(s);
(%o5)                                true
(%i6) system("ls -l file");
-rw-r--r-- 1 sen users 5 Jul 10  2007 file
(%o6)                                  0
(%i7) s: openw("file");
(%o7)                        #<output stream file>
(%i8) printf(s,"Hello");              

/*****************************************************
  renaming files with sbcl
*/

(%i1) build_info();

Maxima version: 5.12.0
Maxima build date: 23:28 5/28/2007
host type: i686-pc-linux-gnu
lisp-implementation-type: SBCL
lisp-implementation-version: 1.0.1

(%o1)
(%i2) system("ls -l file");
ls: file: No such file or directory
(%o2)                        #<PROCESS :EXITED 2>
(%i3) s: openw("file");
(%o3) #<FD-STREAM for "file /home/maxie/sen/COSY/Makino/file" {99EBAE1}>
(%i4) printf(s,"Hello");
(%o4)                                false
(%i5) close(s);
(%o5)                                true
(%i6) system("ls -l file");
-rw-r--r-- 1 sen users 5 Jul 10  2007 file
(%o6)                        #<PROCESS :EXITED 0>
(%i7) s: openw("file");

debugger invoked on a SIMPLE-ERROR:
  Error during processing of --eval option "(cl-user::run)":

  error opening #P"/home/maxie/sen/COSY/Makino/file": File exists

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [MACSYMA-QUIT] Maxima top-level
  1: [CONTINUE    ] Ignore and continue with next --eval option.
  2: [ABORT       ] Skip rest of --eval options.
  3:                Skip to toplevel READ/EVAL/PRINT loop.
  4: [QUIT        ] Quit SBCL (calling #'QUIT, killing the process).

((LAMBDA (SB-IMPL::E)) #<SB-INT:SIMPLE-FILE-ERROR {9A35C39}>)
0] back
0: ((LAMBDA (SB-IMPL::E)) #<SB-INT:SIMPLE-FILE-ERROR {9A35C39}>)
1: ((LAMBDA (SB-IMPL::E)) #<SB-INT:SIMPLE-FILE-ERROR {9A35C39}>)
2: (SIGNAL #<SB-INT:SIMPLE-FILE-ERROR {9A35C39}>)
3: (ERROR SB-INT:SIMPLE-FILE-ERROR)
4: (SB-IMPL::SIMPLE-FILE-PERROR
    "error opening ~S"
    #P"/home/maxie/sen/COSY/Makino/file"
    17)
5: (OPEN "file")
6: (MEVAL1 #<unavailable argument>)
7: (MEVAL (($OPENW) &FILE))
8: ((LAMBDA (L)) ((MSETQ) $S (($OPENW) &FILE)))
9: (MEVAL1 #<unavailable argument>)
10: (MEVAL ((MSETQ) $S (($OPENW) &FILE)))
11: (MEVAL* ((MSETQ) $S (($OPENW) &FILE)))
12: (TOPLEVEL-MACSYMA-EVAL ((MSETQ) $S (($OPENW) &FILE)))
13: (CONTINUE #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {5023A39}> NIL)
14: (MACSYMA-TOP-LEVEL #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {5023A39}> NIL)
15: (RUN)
16: (SB-INT:SIMPLE-EVAL-IN-LEXENV (RUN) #<NULL-LEXENV>)
17: (SB-IMPL::PROCESS-EVAL-OPTIONS ("(cl-user::run)"))
18: (SB-IMPL::TOPLEVEL-INIT)                   
19: ((LABELS SB-IMPL::RESTART-LISP))

0] 

/*****************************************************
  renaming files with cmucl
*/

(%i1) build_info();

Maxima version: 5.12.0
Maxima build date: 23:16 5/28/2007
host type: i686-pc-linux-gnu
lisp-implementation-type: CMU Common Lisp
lisp-implementation-version: 19c Fedora Extras release 7.fc6 (19C)

(%o1)
(%i2) s: openw("file");
(%o2)                      #<Stream for file "file">
(%i3) system("ls -l file");
-rw-r--r-- 1 sen users 0 Jul 10  2007 file

(%o3)                      #<process 17582 :EXITED>
(%i4) printf(s,"Hello");
;

; Warning: This function is undefined:
;   MLISTP
(%o4)                                false
(%i5) close(s);
(%o5)                                true
(%i6) system("ls -l file");
-rw-r--r-- 1 sen users 5 Jul 10  2007 file
(%o6)                      #<process 17584 :EXITED>
(%i7) s: openw("file");


File-error in function LISP::FD-OPEN:  Error opening #P"file", File exists.
   [Condition of type KERNEL:SIMPLE-FILE-ERROR]

Restarts:
  0: [CONTINUE    ] Return NIL.
  1: [MACSYMA-QUIT] Maxima top-level
  2: [ABORT       ] Skip remaining initializations.

Debug  (type H for help)

(LISP::FD-OPEN #P"file" :OUTPUT :ERROR NIL ...)
Source: Error finding source:
Error in function DEBUG::GET-FILE-TOP-LEVEL-FORM:  Source file no longer exists:
  target:code/fd-stream.lisp.
0] back

0: (LISP::FD-OPEN #P"file" :OUTPUT :ERROR NIL ...)
1: (LISP::OPEN-FD-STREAM #P"file" :DIRECTION :OUTPUT :ELEMENT-TYPE ...)
2: (MEVAL1 (($OPENW) &FILE))
3: (MEVAL (($OPENW) &FILE))
4: ("DEFMSPEC MSETQ" ((MSETQ) $S (# &FILE)))
5: (MEVAL1 ((MSETQ) $S (# &FILE)))
6: (MEVAL ((MSETQ) $S (# &FILE)))
7: (MEVAL* ((MSETQ) $S (# &FILE)))
8: (CONTINUE
    #<Two-Way Stream, Input = #<Synonym Stream to SYSTEM:*STDIN*>, Output = #<Synonym Stream to SYSTEM:*STDOUT*>>
    NIL)
9: (MACSYMA-TOP-LEVEL
    #<Two-Way Stream, Input = #<Synonym Stream to SYSTEM:*STDIN*>, Output = #<Synonym Stream to SYSTEM:*STDOUT*>>
    NIL)
10: (RUN)
11: (RUN)                   
12: (RUN)
13: (EXTENSIONS::EVAL-SWITCH-DEMON
     #<Command Line Switch "eval" -- ("(cl-user::run)")>)
14: (EXTENSIONS::INVOKE-SWITCH-DEMONS
     (#<Command Line Switch "quiet">
      #<Command Line Switch "core" -- ("/usr/local/lib/maxima/5.12.0/binary-cmucl/maxima.core")>
      #<Command Line Switch "eval" -- ("(cl-user::run)")>
      #<Command Line Switch "-"> #<Command Line Switch "-disable-readline">
      ...)
     (("load" . #) ("eval" . #)))
15: ((LABELS LISP::%RESTART-LISP
       EXTENSIONS:SAVE-LISP))
16: ((LABELS LISP::RESTART-LISP
       EXTENSIONS:SAVE-LISP))

0]