#15820: Implement sequences of bounded integers
--------------------------------------------+------------------------
Reporter: SimonKing | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.3
Component: algebra | Resolution:
Keywords: sequence bounded integer | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
--------------------------------------------+------------------------
Comment (by SimonKing):
Hmmm. Meanwhile I am a bit less positive about fused types. Let `seq_t` be
a fused type for different implementations.
- Fused types can not be used in iterators. I.e., the following is
refused:
{{{
def iter_seq(seq_t S):
for <bla>:
<do something>
yield x
}}}
- Fused types can not be used as attributes of cdef classes. I.e., the
following is refused:
{{{
cdef class BoundedIntSeq:
cdef seq_t seq
def __mul__(self, other):
<do type check>
cdef seq_t out = concat_seq(self.seq, other.seq)
<create and return new instance of BoundedIntSeq using "out">
}}}
Hence, it seems that one needs to create two separate iterators, and it
also seems that one needs code duplication. I.e., when `impl1` and `impl2`
are two specialisations of the fused type `seq_t`, then one has to have
{{{
cdef class BoundedIntSeq_impl1:
cdef impl1 seq
def __mul__(self, other):
...
cdef impl1 out = concat_seq(self.seq, other.seq)
cdef class BoundedIntSeq_impl2:
cdef impl2 seq
def __mul__(self, other):
...
cdef impl2 out = concat_seq(self.seq, other.seq)
}}}
This mainly amounts to cut-and-paste, but is ugly!
I think I'll ask on cython-users if there are known ideas to solve this
more elegantly.
--
Ticket URL: <http://trac.sagemath.org/ticket/15820#comment:45>
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.
For more options, visit https://groups.google.com/d/optout.