#10743: Add iterator protocol to EclObject
-----------------------------------+----------------------------------------
   Reporter:  nbruin               |       Owner:  nbruin         
       Type:  enhancement          |      Status:  positive_review
   Priority:  major                |   Milestone:  sage-4.7       
  Component:  interfaces           |    Keywords:  ECL lisp ecllib
     Author:  Nils Bruin           |    Upstream:  N/A            
   Reviewer:  Karl-Dieter Crisman  |      Merged:                 
Work_issues:                       |  
-----------------------------------+----------------------------------------

Old description:

> Experience teaches that EclObjects wrapping LISP lists would often be
> convenient to iterate over in list comprehensions and for loops.
> Pythonizing the EclObject would work recursively, which is often not what
> is required: you just want to work with EclObjects wrapping the members
> of the list. The iterator protocol seems to yield a convenient and well-
> defined interface. Examples:
> {{{
> sage: from sage.libs.ecl import *
> sage: [i for i in EclObject("(1 2 3)")]
> [<ECL: 1>, <ECL: 2>, <ECL: 3>]
> sage: [i for i in EclObject("(1 2 . 3)")]
> [<ECL: 1>, <ECL: 2>, <ECL: 3>]
> sage: [i for i in EclObject("NIL")]
> []
> sage: [i for i in EclObject("T")]
> Traceback (most recent call last):
> ...
> TypeError: ECL object is not iterable
> }}}
>

> ----
>
> Apply attachment:trac_10743-ecl-iter_p1.patch
>
> If it doesn't screw up #7377 applying properly (which it shouldn't, as
> #7377 only touches ecl.pyx in one small place far from here), also apply
> attachment:trac_10743-reviewer.patch

New description:

 Experience teaches that EclObjects wrapping LISP lists would often be
 convenient to iterate over in list comprehensions and for loops.
 Pythonizing the EclObject would work recursively, which is often not what
 is required: you just want to work with EclObjects wrapping the members of
 the list. The iterator protocol seems to yield a convenient and well-
 defined interface. Examples:

 {{{
 sage: from sage.libs.ecl import *
 sage: [i for i in EclObject("(1 2 3)")]
 [<ECL: 1>, <ECL: 2>, <ECL: 3>]
 sage: [i for i in EclObject("(1 2 . 3)")]
 [<ECL: 1>, <ECL: 2>, <ECL: 3>]
 sage: [i for i in EclObject("NIL")]
 []
 sage: [i for i in EclObject("T")]
 Traceback (most recent call last):
 ...
 TypeError: ECL object is not iterable
 }}}
 ----
 Depends on [http://trac.sagemath.org/sage_trac/ticket/10766 #10766].

 Apply attachment:trac_10743-ecl-iter_p1.patch

 If it doesn't screw up #7377 applying properly (which it shouldn't, as
 #7377 only touches ecl.pyx in one small place far from here), also apply
 attachment:trac_10743-reviewer.patch

--

Comment(by jpflori):

 Just wanted to add that the minor change in the p1 patch has been
 introduced by the new ECL package so this should depend on
 [http://trac.sagemath.org/sage_trac/ticket/10766 #10766] to pass doctests.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10743#comment:11>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to