Hey everyone,

On Sunday, October 28, 2012 2:13:07 AM UTC-7, Andrew Mathas wrote:
>
> Hi Nicolas,
>
> Not OK (this could break e.g. Symmetric Functions): 
>>
>>         sage: Partitions().options(cmp=dominance) 
>>
>
> In his patch Travis has an option for changing the default comparison 
> method and I think that this would be useful. Below you also mention that 
> be able to change the default ordering for enumerating the elements is also 
> desirable but I can think of situations where this would break code. These 
> two examples suggest to me that the "not changing the semantic policy" may 
> be too strict.
>
> Having said this, one of the motivations behind my proposal is precisely 
> to avoid issues like this: as each option is available as a method of the 
> class, if external code wants or requires a particular variant of an 
> optional method then it should call that method directly. In this instance, 
> if the symmetric functions require the lexicographic ordering then they 
> should explicitly call the corresponding methods, such as __le___lex__. I 
> admit that this would be slightly annoying in this case -- and also 
> decrease the readability of the code -- but if it was agreed that cmp 
> methods should be optionable then this is how such problems would be dealt 
> with using the framework that I am proposing.
>
> I would want to extend the framework to also allow for setting options 
>> for the parent itself. Things like Partitions(3, order=...) that would 
>> change the enumeration order. 
>>
>
> Currently I have the parents controlling the parents but I guess that 
> there is no reason not to make the elements responsible for their own 
> options and the parents responsible for theirs. Alternatively, with some 
> hacking the options method of the parent could be made to recognise whether 
> it was a parent or element_class option.
>

I believe we should allow individually created parents to set their options 
only via Partitions(3, order=...), that way we don't have to worry about 
changing something by surprise if something is a UniqueRepresentation. 
However by implementing this, we could then not break things by not 
necessarily having to call particular methods directly. So in 
SymmetricFunctions, if we need lex order, we call P = Partitions(3, 
order='lex') and then iterate over P. (Hopefully that makes sense...)
 

>
> - Element classes may be shared between different parents. One needs 
>>   to make sure that one does not affect by accident unrelated parents. 
>>
>
> Don't elements always have unique parents? Although I guess this issue 
> does arise because of inheritance with, for example, some methods for 
> StandardTableau being inherited from Tableau...there could be issues here. 
> Perhaps the factory framework for such classes that Florent is developing 
> would help here?
>

We have the following situation:

class ElementFoo(Element):

class Parent1(Parent):
   Element = ElementFoo

class Parent2(Parent):
   Element = ElementFoo
 

>  
>
>> - Assigning methods to the class won't work with Cython classes (as 
>>   far as I remember). 
>>
>
> I have no experience with cython yet but I wouldn't have thought this was 
> a big problem because all that I am really doing to using optionable 
> methods as aliases for the real methods. The idea is that a method like 
> _repr_ simply becomes an alias for _repr_with_option and that changing an 
> option for _repr_ just changes which function it is an alias for.
>

Couldn't we just do that with function pointers? 
http://docs.cython.org/src/reference/language_basics.html
 

> > A related question: should this framework be about Parents or 
> SageObjects ...
>
> Given your comments about parents above, perhaps this should be generally 
> about objects...however, I am not sure how well what I am proposing will 
> work with multiple inheritance. This could definitely be a problem.
>

>From looking at it, the only problem I see with (multiple) inheritance 
might be making sure the display_options is coherent.

Vincent, if I understand you correctly you're trying to avoid polluting the 
namespace of the element classes. This also makes me worry about the 
following situation. Suppose Elt is an element to 2 different parents Foo 
and Bar where the repr for Foo.Elt is (naturally) different from Bar.Elt. 
Thus Foo.Elt.options(repr=bar_repr) should throw an error.

Best,
Travis

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sage-combinat-devel/-/GquWXCpCGs4J.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to