> I need Any for convenient use of different variable domains in a database
> prototype. This, however, causes problems, as equality semantics not
> transparent for me: Can anybody explain or/and give a way around. E.g.
> counting all occurencies "A" (of type String realized as Any) in a
> Table(Integer, Any) does not work, as the system considers each occurency "A"
>
> as a new object.
>
> Here some illustrations:
>
> aa : Any := "A" :: String
>
>
> (7) "A"
> Type: String
> domainOf aa
>
>
> (8) String()
> Type: OutputForm
> ba : Any := "A" :: String
>
>
> (9) "A"
> Type: String
> domainOf ba
>
>
> (10) String()
> Type: OutputForm
> (aa = ba)@Boolean
>
>
> (11) false
> Type: Boolean
You probably want something like this:
)abbrev package FOO Foo
Foo: with (cmp : (Any, Any) -> Boolean) == add
cmp(x, y) ==
dx := dom x
dy := dom y
dx ~= dy => false
Dx : BasicType := EVAL(dx)$Lisp
(obj x) pretend Dx = (obj y) pretend Dx
Remarks:
1) It is easy to produce bogus values of type Any (for example using
pretend). The above performs no error checking and assumes correct
input values.
2) Comparison will fail at runtime if the type stored has no equality
(in other words there is no checking that domain really is of
category BasicType). One could probably fix this declaring Dx
to be just type and performing test 'if Dx has BasicType ...'
3) The code assumes that simply passing dx to Lisp EVAL will work, but
it is possible to declare types for which it may fail. AFAICS
better version would quote all non-type arguments to types.
--
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
-~----------~----~----~----~------~----~------~--~---