On Sat, Sep 13, 2008 at 8:40 AM, Ralf Hemmecke wrote:
>
>>> And if you just have CatD instead of Cat(D), you can achieve
>>> the same thing.
>
>> When does one have CatD?
>
> Actually always. If you write D in your source file then you must
> know it's type. Either you define D in that file or it comes from a
> library or it appears as a parameter in the function (or constructor)
> in whose body D occurs. In each case you know CatD.
>
We seem to be talking but completely misunderstanding each other :-(
Suppose I say D represents some domain but I do not tell you yet which
domain. How can I programmatically refer to the category or categories
to which D belongs?
Supoose I say: please consider the domain RomainNumeral. You can use
)show RomanNumeral
and discover what it exports. Maybe I would like to "extend" this list
of exports to include new functions such as 'five', 'ten', 'fifty',
'hundred' etc. It seems to me that I should be able to do this without
looking at the source code for RomanNumeral. This is exactly what you
*can* do with Aldor's extend. The only reason you cannot do it some
other way is because you cannot determine exactly the category to
which RomanNumeral belongs.
> You might argue that as an argument the type is not completely
> clear, but if, for example, you define
>
> A(D: Ring): with ... == add E
>
> then all you know about D inside E is that its type is Ring even if it
> can be something more specific like Field. But the compiler will not
> let you access any Field operations unless you wrap it by
>
> if D has Field than {
> -- code here ---
> }
>
No, as far as I can see this has nothing to do with the issue I am
trying to address.
> > Do you mean that I must find and copy this
>> from the source code? For example, how can I find the specific
>> category (-ies) to which the domain 'Integer' belongs? Isn't this
>> problematic if there are anonymous 'with' clauses present in the
>> definition of Integer?
>
> Before we go deeper here, can you give a concrete use case where
> this "Cat" operation you mentioned is a good idea?
If this "Cat" operation existed, I would not need to implement any new
functionality in the SPAD language to have the ability to extend
domains in essentially the same way as one can using Aldor.
> Unfortunately, I cannot remember the occasion when Stephen Watt
> said something about it.
>
The context of the discussion with Stephen was his presentation on
"Domain, SubDomain, and categories". Stephen defined Domain as the set
of all domains and Category as the power set of Domain (set of all
subsets of Domain). In other words a category is a subset of Domain.
In order not to get confused notice that when I write Domain with a
capital letter it means the set of all domains. But when I write
domain with a lower case letter it means one specific domain.
Similarly for Category and category.
There is one category in Category that corresponds to Domain. In Axiom
we call this category Type. But in Category we will also find the
*empty* category (not the same as Type!) which consists of the empty
set of domains, and we will also find for each domain in Domain a
corresponding singleton set containing just that domain in Category.
>
> It seems you are very much interpreter focused. That in the
> interpreter I might have problems to figure out the type of a domain
> it natural since everything is interactive an thus dynamic. But I am
> currently not interested in such things. With a bit of reflection built
> into Aldor, one could write an interpreter in Aldor. But I don't think
> it is generally desireable to make reflection available to the general
> user.
>
I agree with your general philosophy about the use of reflection. I
think it was a specific design decision in Aldor and probably asl
Axiom that if one wants reflection for a particular application then
this should be built-in to the types that you define but not built-in
to the language per se.
On the other hand I do not agree that I am focused on the interpreter.
Rather I am focused on the library. When I write something like
Cat(Integer)
and expect that this refers to some category, it is always in the
context of some library where the domain Integer is defined.
>
>>> So what did you have in mind with the above?
>
>> The whole point is to be able to define specifically the category to
>> which a domain belongs, i.e. the actual type of a domain constructor.
>> And then to be able to use that type in the definition of another
>> domain.
>
> OK. But suppose you are writing a library (no interpreter) and you
> have the above.
>
Ok. That is exactly the situation in which I am interested.
> Somewhere in your library a domain D is defined. You define
>
> NewD: Cat(D) with
> foo: %->%
> == D add
> foo(x: %): % == x
>
> bar(X: MyCat): () == ...
>
> How do you know that you can write bar(D)?
That is nothing new. I can write 'bar(D)' if 'D has MyCat' is true.
> How do you know that you can write bar(NewD)?
>
Because by definition 'Cat(D)' will be evaluated to *exactly* the
singleton category to which D belongs then I know that:
'NewD has MyCat' will be true if and only if 'D has MyCat' is true.
> I don't currently see a case where I would want such a NewD.
> Do you have a real example?
>
Pick any reason for which you might want to use extend in Spad.
Regards,
Bill Page.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---