Serge D. Mechveliani wrote:
> 
> >     show(xs : List INT) : String ==
> >                                  unparse(convert(xs)@InputForm)
> 
> 
> Yes. Thank you.
> 
> 1. What is  `@',  please?

'@' request evaluation with specific result type.  Main use is
to resolve overloading on function return type: frequently
there are several 'convert' function which differ only in
their return type. 'convert(xs)@InputForm' request 'convert'
producing value of type 'InputForm'.  It is differnet from
'::' -- '@' reports error if compiler can not select
overloaded function in a way giving requested result type.
'::' calls the 'coerce' function which may do some computation
to convert value form one type to another.

> 
> 2. I also tried  show(xs : List String) ...
> in
> 
> )abbrev package FOO Foo
> Foo() : with        f : List String -> List String ==
>   add
>      show(xs : List String) : String ==  unparse(convert(xs)@InputForm)
> 
>      f(xs : List String) : List String ==
>             empty? xs => [] :: List String
>             lx := first xs
>             lx = "]" => error concat["f ", show xs, " :  first(arg) = ]"]
>             [lx, lx]
> 
> And     -> f ["]", "cd"]
> reports
> Function:  convert : % -> InputForm is missing from domain: String
>    Internal Error
>    The function convert with signature (InputForm)$ is missing from 
>       domain String 
> 
> It is desirable to use an universal  show,  may be
> 
>    show(x : SomeAppropriateCategory) : String == 
>                                      unparse(convert(xs)@InputForm)  ?
> What might it be?

In your case the message says that 'convert' function in String is
supposed to exist, but actually is unimplemented.  For String the
solution is to use newest version (I added implementation on
January 9).

In general you have to problems:
- Axiom/FriCAS is an open-ended system, new domains get added
  and they may be of arbitrary type, so there is no warranty
  that domain will satify any specific category.
- even if domain satisfy some category, specific function
  exported by the category may be unimplemented

Concerning debugging messages: the official way to create
output is first coerce what you have in hand to OutputForm
and then use print.  Unfortunately, while you can print
OutputForm, there is no provision to get a string.  This
is because OutputForm was designed for rich 2-dimensional
output and making decent formatter requires not so trivial
work.  Actually, there are ways of getting string version
from OutputForm: TexFormat allows you to get TeX version
as a string and similarlt MathMLFormat.  However, I am
not sure how useful it is for debugging.

BTW: FriCAS contains tracing facility, for example:

)trace String )math

will print arguments and results of all calls to
exported functions in String.

BTW2: When I wanted to provide more information in
error message I used construct like:

    bad?(val) =>
        print(val::OutputForm)$OutputForm
        error "foo_routine: got bad val"

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