------------------------------ t.spad -----------------------------
)abbrev package FOO Foo
Foo() : with
         f : () ->  SExpression
  ==
   add
      f() ==
           e1 := convert("ab" :: Symbol) $SExpression
           e2 := convert("cd" :: Symbol) $SExpression
           convert([e1, e2]) $SExpression
-------------------------------------------------------------------

Thank you. That's much easier to give an answer to (although (1) I don't see an error message for THIS program and (2) that program actually compiles and thus doesn't show the actual problem you have). Sorry, I am quite picky here, but you should think about the time that others spend in trying to help you. If it is too much, you might simply get no answer.

1. Why in the last line the comipler insists on  "()" ?

Without the parens, I get the error below.
Because, in fact, the compiler transforms the last line into something like

  (convert$SExpression) [e1, e2]

(you could even write this literally like this). If you remove the parens then it's equivalent to

    convert(  construct(e1,e2)$SExpression  )

and not the intended

    convert(construct(e1,e2))$SExpression

2. Is this natural that the first line of
                                        ("ab" :: Symbol) :: SExpression
    is not compiled?

What makes you believe that it is not compiled?

3. As there are `coerce' and `::',  why does Spad need `convert' ?

http://axiom-developer.org/axiom-website/hyperdoc/axbook/section-2.7.xhtml

In Aldor there even isn't "convert".
http://www.aldor.org/docs/HTML/chap11.html#7

4. I define  coerce(s : String) : SExpression ==
                                   convert(s :: Symbol) $SExpression
    and use  "ab" :: SExpression.
    Is this a good way out?

Read the axiom book above of what this means. In fact, if you do not export this coerce function, then it doesn't mean anything outside of your domain/package, i.e. you can do whatever you find appropriate.

3. Sometimes  `g :: OutputForm'  does not work in Spad, while
                                  coerce(g) :: OutputForm   does work.
    What is the difference?

Too few information. I don't want to guess. The only thing I can say here is that without context it is not clear where the explicitly written "coerce" comes from.

Before you pose your question again, learn about the difference of

  foo(..)$P
  foo(..)::T
  foo(..)@T

Perhaps then you can answer the question already yourself.

Hope that gives you a few hints.

Ralf

===================================================================

(1) -> )co foo.spad
   Compiling FriCAS source code from file
      /home/hemmecke/scratch/spad/foo.spad using old system compiler.
   FOO abbreviates package Foo
------------------------------------------------------------------------
   initializing NRLIB FOO for Foo
   compiling into NRLIB FOO
   compiling exported f : () -> SExpression
****** comp fails at level 5 with expression: ******
error in function f

(SEQ
 (LET |e1|
   ((|elt| (|SExpression|) |convert|) (|::| "ab" (|Symbol|))))
 (LET |e2|
   ((|elt| (|SExpression|) |convert|) (|::| "cd" (|Symbol|))))
 (|exit| 1 (|convert| ((|elt| (|SExpression|) |construct|) |e1| |e2|))))
****** level 5  ******
$x:= (construct e1 e2)
$m:= (SExpression)
$f:=
((((|e2| #) (|e1| #) (|$Information| #) (|f| #) ...)))

   >> Apparent user error:
   Cannot coerce (LIST e1 e2)
      of mode (List (SExpression))
      to mode (SExpression)

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to