#14260: Casting a standard tableau as a tableau
----------------------------------+-----------------------------------------
Reporter: chrisjamesberg | Owner: sage-combinat
Type: defect | Status: needs_review
Priority: major | Milestone:
sage-duplicate/invalid/wontfix
Component: combinatorics | Resolution:
Keywords: tableau | Work issues:
Report Upstream: N/A | Reviewers:
Authors: | Merged in:
Dependencies: | Stopgaps:
----------------------------------+-----------------------------------------
Comment (by tscrim):
You're not casting when you do that, you're creating a new object
altogether, including tuples/lists:
{{{
sage: T = tuple(1, 2, 3)
sage: L = list(T)
sage: L
[1, 2, 3]
sage: L.append(4); L
[1, 2, 3, 4]
sage: T
(1, 2, 3)
}}}
In python, I believe the copy is done lazily, so if it's an immutable
type, it is safe to just return the original object. Sage follows this
paradigm. With your example above, `Composition` and `Partition` are
different classes (with methods for `Composition` not in `Partition`), and
the above behavior is a reflection of this. Why isn't `Partition` a
subclass of `Composition`? I think that's more of a question for Nicolas.
(A guess might be because of some overhead, but I don't really know. The
explicit conversion has been sufficient for me.)
Casting is something which tells the program that the ''same'' object is a
different ''type''. For example in C++
{{{#!c++
class Foo {
};
class Bar : public Foo {
public:
B() { }
};
Foo *f = new Bar();
Bar *b = (Bar) f;
}}}
The last line is casting because a priori, the computer doesn't know `f`
is pointing to a type `Bar`, so it wouldn't know what to do. Also note
that both `f` and `b` point to the same object in memory.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14260#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.