On Sun, Jul 28, 2013 at 09:55:55AM +0000, Simon King wrote:
> When one uses ClasscallMetaclass for a class C and then defines a static 
> method
> C.__classcall__, then creation of instances of C is done by this 
> __classcall__.
> I just noticed that it is even possible that the resulting instances are
> not necessarily instances of C:
> ...
> 
> Do we want such a behaviour? Or should ClasscallMetaclass.__call__ do
> some assertion that makes sure that it can only return instances of the
> class in question?

I don't have a strong use case, but just in case I'd rather decouple
syntax and semantic. Namely the __classcall__ hook is just about
implementing the syntax C(...). At the same time, I am happy setting
as recommendation that, in Sage, C(...)  should return an instance of
C.

That's a bit like what happens for other special methods like __mul__:
the user usually expects a+b to be of the same type as a and b, but it
does not have to be so. Python provides this syntactic hook, but does
not enforce its semantic.

Cheers,
                                Nicolas
--
Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net>
http://Nicolas.Thiery.name/

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to