Arthur Ralfs <art...@mathbrane.ca> writes:

[...]

| Hi Gaby,
| 
| I tried out your suggestions both ways, with Lisp variables and with
| Spad variables, but still didn't get it to compile properly.

Hi Arthur,

Many thanks for your patience in isolating simple testcases we can work
on.  This is very much appreciated.  See explanations below.  Your input
is very much appreciated.

| 
| I have no idea what the problem is so I started stripping things out
| to try and isolate the problem.  I discovered that the first version
| below compiles but the second doesn't:
| 
| )abbrev package SOCKLIB SockLib
| 
| SockLib(): Public == Private where
| 
|     Public == Type with
| 
|         handleInsert: () -> Integer
|         sendInsertFile: () -> String
| 
| 
|     Private == add
| 
|         handleInsert() ==
|             retval:Integer := 0
|             SETQ(_$FILEINSERT,"test")
|             retval

Here, the Lisp-level special variable $FILEINSERT is locally `defined'
before it is used (if it is ever used), so the Lisp compiler is happy
with it.  Indeed, the corresponding Lisp code:

   (DEFUN |SOCKLIB;handleInsert;I;1| ($)
     (LET ((|retval| 0) ($FILEINSERT "test"))
       |retval|)) 

Note that there is no SPECIAL declaration for $FILEINSERT because you
used the Lisp instruction SETQ.  If you used the Spad-level assignment
instruction (:=), then we would have had a SPECIAL declaration.  All of
that is fine.

|         sendInsertFile() ==
|             retval:String := "test"
|             fileInsert:String := _$FILEINSERT$Lisp

Here, we are reading from the Lisp-level special variable $FILEINSERT
(at least it is assumed so because of the leading dollar.)  So, it is
again fine.  The corresponding Lisp code is

   (DEFUN |SOCKLIB;sendInsertFile;S;2| ($)
     (PROG (|fileInsert|)
       (DECLARE (SPECIAL $FILEINSERT))
       (RETURN
        (LET ((|retval| "test"))
          (LETT |fileInsert| $FILEINSERT |SOCKLIB;sendInsertFile;S;2|))))) 

| )abbrev package SOCKLIB SockLib
| 
| SockLib(): Public == Private where
| 
|     Public == Type with
| 
|         handleInsert: () -> Integer
|         sendInsertFile: () -> String
| 
| 
|     Private == add
| 
|         handleInsert() ==
|             retval:Integer := 0
|             SETQ(_$FILEINSERT,"test")
|             retval

Here there seems to be a bug in the generated code:

   (DEFUN |SOCKLIB;handleInsert;I;1| ($)
     (LET ((|retval| 0) ($FILEINSERT "test"))
       |retval|)) 

but that is not the cause of the error.  We should not be binding
$FILEINSERT; rather, we should be just assigning to it.

|         sendInsertFile() ==
|             retval:String := "test"
|             fileInsert:String := _$FILEINSERT$Lisp
|             retval

The real problem seems to come from the code generated from this one:

   (DEFUN |SOCKLIB;sendInsertFile;S;2| ($)
     (LET ((|retval| "test") (|fileInsert| $FILEINSERT))
       (DECLARE (SPECIAL $FILEINSERT))
       |retval|)) 

where we are reading from the variable $FILEINSERT without declaring
first that it is special.  I think this is bogus, we should have
something like 

   (DEFUN |SOCKLIB;sendInsertFile;S;2| ($)
     (DECLARE (SPECIAL $FILEINSERT))
     (LET ((|retval| "test")
           (|fileInsert| $FILEINSERT))
         |retval|))


I'm working on a fix.

| However if I replace 'sendInsertFile' with
| 
|         sendInsertFile() ==
|             retval:String := "test"
|             fileInsert:String := _$FILEINSERT$Lisp
|           retval
| 
| then it  does compile.

oh, this is one is just plain confusion :-/

-- Gaby

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
open-axiom-devel mailing list
open-axiom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to