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.

- 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?
 

> - 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.
 

> - One often need to change several methods (repr/latex/...) at once, 
>   so manual handling will be needed in many (most?) cases anyway. 
>

This is already catered for by my option_alias dictionary. For example, the 
option cmp changes __le__, __lt__, __ge__, and __gt__.
 

> Also a comment: the result output methods like repr is meant to be 
> eventually read by a human; if such a method is called zillions of 
> times, then probably something got wrong. Thus, one should not worry 
> about optimizing away callbacks to the parent in such methods: "always 
> ask dad/mom what you should do" :-). 
>
 
I agree, but if a generic solution is possible then it should be efficient 
because this will make a difference in some cases.

> 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.

Andrew
Andrew

-- 
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/-/E_I5zChV0OQJ.
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