From 3502fe2da07c02b71ef5bc56b68b61bf86e2aff8 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 26 Apr 2019 15:03:37 +0200 Subject: [PATCH] added support for single implicit parameter to FOR EACH prim --- HISTORY.md | 1 + snap.html | 2 +- src/threads.js | 9 +++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 9c47ad45..03a05a14 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -86,6 +86,7 @@ * updated "audio comp" library (for new HOF prims) * updated "parallelism" library (for new HOF prims) * renamed help screens for the new HOF prims +* Theads: added support for single implicit parameter to FOR EACH prim ### 2019-04-25 * updated German translation (for new HOF prims) diff --git a/snap.html b/snap.html index b79dc60b..ab60372e 100755 --- a/snap.html +++ b/snap.html @@ -7,7 +7,7 @@ - + diff --git a/src/threads.js b/src/threads.js index 27f6f009..8fab69a3 100644 --- a/src/threads.js +++ b/src/threads.js @@ -62,7 +62,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy, isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, Color, TableFrameMorph, ColorSlotMorph, isSnapObject, Map, newCanvas, Symbol*/ -modules.threads = '2019-April-24'; +modules.threads = '2019-April-26'; var ThreadManager; var Process; @@ -2103,14 +2103,15 @@ Process.prototype.doForEach = function (upvar, list, script) { this.assertType(list, 'list'); if (isNil(this.context.inputs[3])) {this.context.inputs[3] = 1; } - var index = this.context.inputs[3]; + var index = this.context.inputs[3], + item = list.at(index); this.context.outerContext.variables.addVar(upvar); - this.context.outerContext.variables.setVar(upvar, list.at(index)); + this.context.outerContext.variables.setVar(upvar, item); if (index > list.length()) {return; } this.context.inputs[3] += 1; this.pushContext('doYield'); this.pushContext(); - this.evaluate(script, new List(), true); + this.evaluate(script, new List([item]), true); }; Process.prototype.doFor = function (upvar, start, end, script) {