Serge D. Mechveliani wrote:
> 
> On Mon, Mar 12, 2012 at 10:48:51AM +0100, Ralf Hemmecke wrote:
> > http://groups.google.com/group/fricas-devel/msg/d109ed12f6cc13d6
> 
> ------------------------------ 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
> -------------------------------------------------------------------
> 
> 1. Why in the last line the comipler insists on  "()" ?
> 
> 2. Is this natural that the first line of
>                                        ("ab" :: Symbol) :: SExpression
>    is not compiled?
>

Yes.  AFAICS there is no 'coerce' producing SExpression from
a Symbol.

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

'coerce' is assumed to be nice mapping, typically homomorphism.
'convert' may behave much worse.  In particular, if you form
chain of coercions from A to B the result should be depend
only on A and B, and be independent from particular chain.
There is no such requirement on 'convert'.  It is not
hard to give reasonably natural convertions which
do not commute, so it is not possible to put all
"natural" convertion into one big "commuting" scheme, and
not all convertions can be done by nice coerce.  So
we make distinction between 'coerce' and 'convert'.
Of course alternative would be to have single class
of convertions and drop the niceness requirement.

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

You are fighting with current design, does not look like
good idea.

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

The first is more or less 'coerce(g)@OutputForm', the second
one 'coerce(coerce(g))@OutputForm', so the difference seem
to be between coercing in one step versus coercing in two
steps.  Which one works depends on available coercions...


-- 
                              Waldek Hebisch
[email protected] 

-- 
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