Re: case and foreach

new topic     » goto parent     » topic index » view thread      » older message » newer message

codepilot Gmail Account wrote:
> 
> Pros
> I think foreach could be used to add some parallelism to euphoria and
> simplify a few things that for loops and subscripting are used for.
> Case would be good for simplifying if/elsif/else blocks to a more
> manageable level and could also help in optimization.
> 
> Cons
> Does anyone have something against case or foreach(element in a
> sequence) in euphoria?

I use the for...each construct a lot in my VBA programs. However, that's
because I can iterate through objects. For example:

dim tbl as Table
for each tbl in ActiveDocument.Tables
   '... manipulate the data
next

Since Euphoria doesn't have objects, I don't see how this would be more
useful than what's already available.

for each x in 1 to 50 do
    ?x
end for

Although it would work for iterating through sequences...

sequence s
s = {1,2,3,4,5}
for each x in s do
    ?x
end for

Do any of the OOP libraries out there use this construct to loop through
objects in a class/library/whatever?

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu