[Petal] Does Petal support a simple while loop?

Jean-Michel Hiver jhiver at mkdoc.com
Tue Jun 24 12:02:33 BST 2003


The question about cursors has already been raised by Mark Holland, and
I have already provided an answer that kinda works on the list:

    http://www.email-lists.org/pipermail/petal/2003-February/000301.html

Basically you can turn your cursor into a tied array and then use the
tied array with a normal 'repeat' statement.

It would certainly be good to have a 'cursor:' modifier that would be
generic enough to do that!


> Exactly. If you're going to try it, you could start by adding a 3-parameter 
> tag called petal:iterate, making it totally separate from petal:repeat. 
> You'll have to make it
> 
> petal:iterate="item getNext path/to/object"

    petal:repeat="cursor: item getNext path/to/object"

Would be pretty good too :)


> If there's great demand for it, we could also have
> 
> petal:awkward_java_style_iterator="item hasNext getNext path/to/object"

Or maybe the Petal::Hash::Cursor class could have a different behavior
depending on the numbers of parameters you're passing or something.


Cheers,
-- 
Building a better web - http://www.mkdoc.com/
---------------------------------------------
Jean-Michel Hiver
jhiver at mkdoc.com  - +44 (0)114 255 8097
Homepage: http://www.webmatrix.net/


More information about the Petal mailing list