RhinoTrac
LassoSoft Ticket Tracking System
NOTE: If you are using Lasso Server 9.3 please Log your ticket directly via the LUX admin as this will give us more information about your issue.
Ticket #7472: Unexpected Behavior When Yielding in a Loop
- Reported by:
- Brad Lindsay
- Date:
- 19 Nov, 2012
- Priority:
- minor
- Component:
- Lasso 9
- Version:
- 9.2
- Keywords:
- Platform:
When using `yield` within a `[loop]` block, the `[loop]` block loses its position when the capture is called again.
define cycle(...) => {
return {
loop(#rest->size) => {
yield #rest->get(loop_count)
}
currentCapture->restart
}->detach
}
local(x) = cycle(1,2,3)
#x()
#x()
#x()
#x()
Result
1
1
1
1
Expected
1
2
3
1
Note, this may be related to the bug I reported on 29 June 2011 that when you use `[loop]` in a `[->forEach]` definition to implement `[trait_queriable]` — it works fine for query expressions but not with an `[iterate]` block. In that instance, it was discovered that a `[while]` block works as a work around. That is the case here too. Defining `[cycle]` like this gives me the results I expect:
define cycle(...) => {
return {
local(i) = #rest->sizewhile(#i--) => {
yield #rest->get(loop_count)
}
currentCapture->restart
}->detach
}
Please log in to your LassoSoft account to comment