Serge D. Mechveliani wrote:
>
> In docs it is written that Product and Record need SetCategory for=
> =20
> each component. And I thought that Any has not SetCategory, I thought
> that Any is more generic than Set.
> But now, I try in the interpreter:
>
> -> has(Any, SetCategory)
> true : Boolean
>
> Really, is Any of SetCategory ?
Yes.
> Now, assuming "yes", I try the code (which is close to what I need):
>
> -----------------------------------------
> ANY1 ==> AnyFunctions1
> SetAnyLexList ==>
> Record(dom : SetCategory, val : Any, remList : List String)
>
> )abbrev package FOO Foo
> Foo() : with p : List String -> SetAnyLexList ==
> add
> p(lexs : List String) : SetAnyLexList ==
> [Integer, coerce(1) $ANY1(Integer), rest lexs]
> -----------------------------------------
>
> Is this all right?
> After compilation, I run it under the interpeter:
>
> --------------------------------------------------------------
> ...
> |$ConstructorCache|
> 0 errors, 4 warnings
> ------------------------------------------------------
> Foo is already explicitly exposed in frame initial=20
> Foo will be automatically loaded when needed from=20
> /home/mechvel/ghc/axiomInterface/fromA-aim/FOO.NRLIB/FOO
>
> (5) -> p ["a"]
>
> >> System error: =20
> FUNCALL: ((|latex| ((|String|) $)) T (ELT $ 8)) is not a function name;=20
> try using a symbol instead
> -------------------------------------------------
>
> If I change `SetCategory' to `Type', then the compiler again compiles this.
> But has(Type, SetCategory) =3D false. =20
> So, should not it report an error?
In fact both using Type and SetCategory violates assumptions
of 'Record' because 'SetCategory has SetCategory' in iterpreter
is a lie. Namely 'x has y' depends on _category_ of x.
In interpreter you can get category by using 'typeOf' and
'typeOf(SetCategory)' is the same as 'typeOf(Type)'.
I will investigate datails, but it seems that got confused by
SetCategory treating it as ordinary type while categories have
different representation.
BTW: the failure is when interpreter tries to print result.
Call to p ["a"] works OK.
> Then, in the interpreter, it shows in the result NIL intstead of Integer
> in the first component of the record.
To print something interpreter first converts it to OutputForm.
If domain is of SetCategory then it should contain apropriate
function for the convertion. But Type is really not of
SetCategory so it misses this function. Again, I did not
check details, but given wrong declaration no wonder that
printing works incorrectly
> I hope that the whole my parsing program will still work with=20
> Record(dom: SetCategory, ...), because the function of this kind is used
> by Spad functions.
> But 1) it needs trying,
> 2) anyway it will be nice to see the explanation for this above code
> with Record.
>
As long as you are _not_ using functions from SetCategory, such
Record-s should work. But if you attempt to use missing
functionality then you may expect errors. In ideal world
Recod should export equality and coercion to QutputForm
only if arguments are of SetCategory and otherwise export
only other operations. However, currently Spad compiler
(and interpter too) lack code to perform appropriate checks.
--
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.