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

| Hi Gaby,
| 
| I've got panserver.spad to compile now under 1.4

This is fantastic news!  Would you mind committing what you currently have?

| but now I get a run  time error when I run
| 
| ans:String := string parseAndEvalToStringEqNum$Lisp command
| 
| If I compile this test spad
| 
| )abbrev package SOCKLIB SockLib
| 
| SockLib(): Public == Private where
| 
|      Public == Type with
| 
|          sendCommand: String -> String
| 
|      Private == add
| 
|          sendCommand(command) ==
|           ans:String := string parseAndEvalToStringEqNum$Lisp command
|           "test"
| 
| 
| I get this
| 
| 
| (2) -> sendCommand("x")
| 
|     >> System error:
|     The value
|    ("   (2)  x"
|     "                                                             Type: 
| Variable x")
| is not of type
|    DOUBLE-FLOAT.

The problem is with your use of parseAndEvalToStringEqNum$Lisp.
That internal function returns a list of strings.  However there is no
library function named `string' that would turn a list of strings into a
string.  The compiler is unable to catch that because you use the
function in a way that ask the compiler to trust you, so it picks
the `string' function that takes an integer :-)

My recommendation is to first make the type explicit to the compiler at
the capsule level:

    import parseAndEvalToStringEqNum: String -> List String
      from Foreign Builtin

then drop the explicit package call (so the compiler can use the
function you just brought into scope.)  The function returns the list of
lines, as List String.  So, you can `concat' the whole thing with
appropriate insertion of newlines in between the elements of the list in
order to reproduce the output that you would have been on the screen.


In general, I would recommend against direct package call to entities in
the Lisp package.  Instead, first bring in the function with the type
you want, then call it as a normal OpenAxiom function.  The compiler
will use the type information as appropriate for overload resolution.


Note: after correction, if you compile the code, and try 

    sendCommand("x")

at the interpreter level, the system "appears" to hang, but that is only
because the input stream has been bound to something else.

Hope that helps,

-- Gaby

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
open-axiom-devel mailing list
open-axiom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to