Robert Bradshaw <[EMAIL PROTECTED]> writes:

> On Oct 14, 2008, at 1:33 PM, Martin Rubey wrote:
> 
> >
> > I believe I understood now:
> >
> > sage: ?parent
> > Type:           function
> > <snip>
> >         Return x.parent() if defined, or type(x) if not.
> >
> > I wonder why this is a function, and not a method of Parent?
> 
> Typically one uses the parent() function when one has an element  
> (such as an integer) and wants it's Parent. This is why it's not an  
> element of the Parent.

Hm, I do not understand that.  Why wouldn't one want to use 5.parent(), for
example?  (The method notation together with tab completion is really nice...)
Well, I suppose that some people prefer usual functional notation.

> The docstring should have some better examples, e.g.
> 
> sage: parent(5)
> Integer Ring
> sage: parent(1/2)
> Rational Field
> sage: parent(1.5)
> Real Field with 53 bits of precision

Well, actually, I find the current docstring OK, it answered my question, at
least partially.  OK, maybe some more examples wouldn't hurt.

But what I really do not understand is why Parent doesn't implement a parent
method...

> > (Am I right that all Sage parents inherit from Parent?  Would be great to
> > know this)
> 
> Yes, that is correct.

OK, great.

> > Set_object inherits from Set_generic, and does not define a parent method,
> > for whatever reason, maybe because the elements of the set need not have a
> > common type.
> >
> > I just saw on
> > http://trac.sagemath.org/sage_trac/attachment/ticket/2314/ 
> > coerce_2_sets.patch
> >
> > a patch to primes.py, which, in particular, makes Primes inherit from a new
> > class Subset instead of Set_generic.  I guess this adresses the issue.
> >
> > It would be wonderful to hear either of "yes, correct", or "no, you are
> > mistaken".

> I'm not sure exactly what your question is, 

The question was, why does

parent(Primes()) give an answer, while Primes().parent() yields an error.

> but sets don't really have a parent, 

well, they do: 

sage: parent(Set([1,2,3])) <class
'sage.sets.set.Set_object_enumerated'>

;-)

I think it's ok to have things without parent, but I do not understand yet, why
x.f() and f(x) are designed differently in some cases.  One case I stepped into
was parent, the other was Mod.

> as the set of all sets is not a category.

Äh?  You don't mean category in the mathematical sense here, do you?
http://en.wikipedia.org/wiki/Category_of_sets

Does Sage have it's own notion of category, just as FriCAS?

(since "set of all sets" doesn't make sense, I guess you mean "class of all
sets")

Martin


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to