I don't like Union(SomeDomain, "failed") very much.
1) Since Union actually requires domains as arguments, there must be
some special compiler code dealing with that.
Yes, there is special case code, but it is probably more general
than you think: each string is regarded as being a type having
itself as unique value. If context requires String as a type,
then this unique type is silently coerced to String. Consider:
(2) -> "ralf"::"ralf"
(2) ralf
Type: ralf
Interesting...
I first thought that this is bad (actually it is bad), but after a while
it reminded me of the enumeration type in Aldor.
%1 >> #include "aldor"
%2 >> #include "aldorinterp"
%3 >> E == 'ralf'
Defined E @ ? == Enumeration(ralf: Type)
%5 >> import from E
%6 >> ralf
ralf @ Enumeration(ralf: Type)
%7 >> 'ralf'
@ Join(
with
== add ()
,
Join(PrimitiveType, OutputType) with
== add ()
)
And the listing of the type comes from the implementation
extend Enumeration(T: Tuple Type): Join(PrimitiveType, OutputType) == add {
-- this is due to the compiler's internal handling of Enumeration
local TT(): Tuple Pointer == T pretend Tuple Pointer;
Rep == MachineInteger;
import from Rep;
(a: %) = (b: %): Boolean == rep a = rep b;
(outp: TextWriter) << (a: %): TextWriter == {
import from String, Tuple Pointer;
outp << string element(TT(), next rep a);
}
}
which can be found here...
https://svn.origo.ethz.ch/algebraist/trunk/aldor/lib/aldor/src/datastruc/sal_string.as
i.e., the output is library defined.
In some sense I like the Aldor way more, since the meaning of the double
quotes is not overloaded too much to mean type as well as element.
On the other hand, I don't really care much about Enumeration. I didn't
yet have a big need for it.
So I would be rather in favour the remove the option that "blah" can
mean a type, but I know that Union(X,"failed") is too often used in the
Algebra code.
Ralf
--
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.