From 1ead356219bb2eb59487d1012f837bd07ec336f5 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 8 Mar 2016 01:30:14 -0800 Subject: 2735 - define recipes using 'def' I'm dropping all mention of 'recipe' terminology from the Readme. That way I hope to avoid further bike-shedding discussions while I very slowly decide on the right terminology with my students. I could be smarter in my error messages and use 'recipe' when code uses it and 'function' otherwise. But what about other words like ingredient? It would all add complexity that I'm not yet sure is worthwhile. But I do want separate experiences for veteran programmers reading about Mu on github and for people learning programming using Mu. --- edit/001-editor.mu | 32 ++++----- edit/002-typing.mu | 62 +++++++++--------- edit/003-shortcuts.mu | 126 ++++++++++++++++++------------------ edit/004-programming-environment.mu | 26 ++++---- edit/005-sandbox.mu | 44 ++++++------- edit/006-sandbox-edit.mu | 6 +- edit/007-sandbox-delete.mu | 8 +-- edit/008-sandbox-test.mu | 12 ++-- edit/009-sandbox-trace.mu | 10 +-- edit/010-errors.mu | 6 +- edit/011-editor-undo.mu | 8 +-- 11 files changed, 170 insertions(+), 170 deletions(-) (limited to 'edit') diff --git a/edit/001-editor.mu b/edit/001-editor.mu index d338b4bb..818f3520 100644 --- a/edit/001-editor.mu +++ b/edit/001-editor.mu @@ -2,7 +2,7 @@ # temporary main for this layer: just render the given text at the given # screen dimensions, then stop -recipe! main text:address:shared:array:character [ +def! main text:address:shared:array:character [ local-scope load-ingredients open-console @@ -48,7 +48,7 @@ container editor-data [ # creates a new editor widget and renders its initial appearance to screen # top/left/right constrain the screen area available to the new editor # right is exclusive -recipe new-editor s:address:shared:array:character, screen:address:shared:screen, left:number, right:number -> result:address:shared:editor-data, screen:address:shared:screen [ +def new-editor s:address:shared:array:character, screen:address:shared:screen, left:number, right:number -> result:address:shared:editor-data, screen:address:shared:screen [ local-scope load-ingredients # no clipping of bounds @@ -79,13 +79,13 @@ recipe new-editor s:address:shared:array:character, screen:address:shared:screen ] -recipe insert-text editor:address:shared:editor-data, text:address:shared:array:character -> editor:address:shared:editor-data [ +def insert-text editor:address:shared:editor-data, text:address:shared:array:character -> editor:address:shared:editor-data [ local-scope load-ingredients # early exit if text is empty - reply-unless text, editor/same-as-ingredient:0 + return-unless text, editor/same-as-ingredient:0 len:number <- length *text - reply-unless len, editor/same-as-ingredient:0 + return-unless len, editor/same-as-ingredient:0 idx:number <- copy 0 # now we can start appending the rest, character by character curr:address:shared:duplex-list:character <- get *editor, data:offset @@ -99,7 +99,7 @@ recipe insert-text editor:address:shared:editor-data, text:address:shared:array: idx <- add idx, 1 loop } - reply editor/same-as-ingredient:0 + return editor/same-as-ingredient:0 ] scenario editor-initializes-without-data [ @@ -129,10 +129,10 @@ scenario editor-initializes-without-data [ # Assumes cursor should be at coordinates (cursor-row, cursor-column) and # updates before-cursor to match. Might also move coordinates if they're # outside text. -recipe render screen:address:shared:screen, editor:address:shared:editor-data -> last-row:number, last-column:number, screen:address:shared:screen, editor:address:shared:editor-data [ +def render screen:address:shared:screen, editor:address:shared:editor-data -> last-row:number, last-column:number, screen:address:shared:screen, editor:address:shared:editor-data [ local-scope load-ingredients - reply-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 + return-unless editor, 1/top, 0/left, screen/same-as-ingredient:0, editor/same-as-ingredient:1 left:number <- get *editor, left:offset screen-height:number <- screen-height screen right:number <- get *editor, right:offset @@ -226,10 +226,10 @@ recipe render screen:address:shared:screen, editor:address:shared:editor-data -> } bottom:address:number <- get-address *editor, bottom:offset *bottom <- copy row - reply row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 + return row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] -recipe clear-line-delimited screen:address:shared:screen, column:number, right:number -> screen:address:shared:screen [ +def clear-line-delimited screen:address:shared:screen, column:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients space:character <- copy 32/space @@ -248,23 +248,23 @@ recipe clear-line-delimited screen:address:shared:screen, column:number, right:n } ] -recipe clear-screen-from screen:address:shared:screen, row:number, column:number, left:number, right:number -> screen:address:shared:screen [ +def clear-screen-from screen:address:shared:screen, row:number, column:number, left:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients # if it's the real screen, use the optimized primitive { break-if screen clear-display-from row, column, left, right - reply screen/same-as-ingredient:0 + return screen/same-as-ingredient:0 } # if not, go the slower route screen <- move-cursor screen, row, column clear-line-delimited screen, column, right clear-rest-of-screen screen, row, left, right - reply screen/same-as-ingredient:0 + return screen/same-as-ingredient:0 ] -recipe clear-rest-of-screen screen:address:shared:screen, row:number, left:number, right:number -> screen:address:shared:screen [ +def clear-rest-of-screen screen:address:shared:screen, row:number, left:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients row <- add row, 1 @@ -422,7 +422,7 @@ after [ ] # so far the previous color is all the information we need; that may change -recipe get-color color:number, c:character -> color:number [ +def get-color color:number, c:character -> color:number [ local-scope load-ingredients color-is-white?:boolean <- equal color, 7/white @@ -464,7 +464,7 @@ recipe get-color color:number, c:character -> color:number [ } # otherwise no change +exit - reply color + return color ] scenario render-colors-assignment [ diff --git a/edit/002-typing.mu b/edit/002-typing.mu index f3f6b321..7a68bb64 100644 --- a/edit/002-typing.mu +++ b/edit/002-typing.mu @@ -2,7 +2,7 @@ # temporary main: interactive editor # hit ctrl-c to exit -recipe! main text:address:shared:array:character [ +def! main text:address:shared:array:character [ local-scope load-ingredients open-console @@ -11,7 +11,7 @@ recipe! main text:address:shared:array:character [ close-console ] -recipe editor-event-loop screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data -> screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data [ +def editor-event-loop screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data -> screen:address:shared:screen, console:address:shared:console, editor:address:shared:editor-data [ local-scope load-ingredients { @@ -45,35 +45,35 @@ recipe editor-event-loop screen:address:shared:screen, console:address:shared:co ] # process click, return if it was on current editor -recipe move-cursor-in-editor screen:address:shared:screen, editor:address:shared:editor-data, t:touch-event -> in-focus?:boolean, editor:address:shared:editor-data [ +def move-cursor-in-editor screen:address:shared:screen, editor:address:shared:editor-data, t:touch-event -> in-focus?:boolean, editor:address:shared:editor-data [ local-scope load-ingredients - reply-unless editor, 0/false + return-unless editor, 0/false click-row:number <- get t, row:offset - reply-unless click-row, 0/false # ignore clicks on 'menu' + return-unless click-row, 0/false # ignore clicks on 'menu' click-column:number <- get t, column:offset left:number <- get *editor, left:offset too-far-left?:boolean <- lesser-than click-column, left - reply-if too-far-left?, 0/false + return-if too-far-left?, 0/false right:number <- get *editor, right:offset too-far-right?:boolean <- greater-than click-column, right - reply-if too-far-right?, 0/false + return-if too-far-right?, 0/false # position cursor editor <- snap-cursor screen, editor, click-row, click-column undo-coalesce-tag:number <- copy 0/never # gain focus - reply 1/true + return 1/true ] # Variant of 'render' that only moves the cursor (coordinates and # before-cursor). If it's past the end of a line, it 'slides' it left. If it's # past the last line it positions at end of last line. -recipe snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, target-row:number, target-column:number -> editor:address:shared:editor-data [ +def snap-cursor screen:address:shared:screen, editor:address:shared:editor-data, target-row:number, target-column:number -> editor:address:shared:editor-data [ local-scope load-ingredients - reply-unless editor + return-unless editor left:number <- get *editor, left:offset right:number <- get *editor, right:offset screen-height:number <- screen-height screen @@ -155,11 +155,11 @@ recipe snap-cursor screen:address:shared:screen, editor:address:shared:editor-da # Process an event 'e' and try to minimally update the screen. # Set 'go-render?' to true to indicate the caller must perform a non-minimal update. -recipe handle-keyboard-event screen:address:shared:screen, editor:address:shared:editor-data, e:event -> screen:address:shared:screen, editor:address:shared:editor-data, go-render?:boolean [ +def handle-keyboard-event screen:address:shared:screen, editor:address:shared:editor-data, e:event -> screen:address:shared:screen, editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients go-render? <- copy 0/false - reply-unless editor + return-unless editor screen-width:number <- screen-width screen screen-height:number <- screen-height screen left:number <- get *editor, left:offset @@ -179,12 +179,12 @@ recipe handle-keyboard-event screen:address:shared:screen, editor:address:shared # ignore any other special characters regular-character?:boolean <- greater-or-equal *c, 32/space go-render? <- copy 0/false - reply-unless regular-character? + return-unless regular-character? # otherwise type it in editor, screen, go-render?:boolean <- insert-at-cursor editor, *c, screen - reply + return } # special key to modify the text or move the cursor k:address:number <- maybe-convert e:event, keycode:variant @@ -192,10 +192,10 @@ recipe handle-keyboard-event screen:address:shared:screen, editor:address:shared # handlers for each special key will go here go-render? <- copy 1/true - reply + return ] -recipe insert-at-cursor editor:address:shared:editor-data, c:character, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ +def insert-at-cursor editor:address:shared:editor-data, c:character, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ local-scope load-ingredients before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset @@ -226,7 +226,7 @@ recipe insert-at-cursor editor:address:shared:editor-data, c:character, screen:a move-cursor screen, save-row, save-column print screen, c go-render? <- copy 0/false - reply + return } { # not at right margin? print the character and rest of line @@ -240,7 +240,7 @@ recipe insert-at-cursor editor:address:shared:editor-data, c:character, screen:a # hit right margin? give up and let caller render go-render? <- copy 1/true at-right?:boolean <- greater-than curr-column, right - reply-if at-right? + return-if at-right? break-unless curr # newline? done. currc:character <- get *curr, value:offset @@ -252,14 +252,14 @@ recipe insert-at-cursor editor:address:shared:editor-data, c:character, screen:a loop } go-render? <- copy 0/false - reply + return } go-render? <- copy 1/true - reply + return ] # helper for tests -recipe editor-render screen:address:shared:screen, editor:address:shared:editor-data -> screen:address:shared:screen, editor:address:shared:editor-data [ +def editor-render screen:address:shared:screen, editor:address:shared:editor-data -> screen:address:shared:screen, editor:address:shared:editor-data [ local-scope load-ingredients left:number <- get *editor, left:offset @@ -697,7 +697,7 @@ after [ } go-render? <- copy 1/true - reply + return } ] @@ -818,11 +818,11 @@ after [ editor <- insert-new-line-and-indent editor, screen go-render? <- copy 1/true - reply + return } ] -recipe insert-new-line-and-indent editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ +def insert-new-line-and-indent editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset @@ -846,7 +846,7 @@ recipe insert-new-line-and-indent editor:address:shared:editor-data, screen:addr } # indent if necessary indent?:boolean <- get *editor, indent?:offset - reply-unless indent? + return-unless indent? d:address:shared:duplex-list:character <- get *editor, data:offset end-of-previous-line:address:shared:duplex-list:character <- prev *before-cursor indent:number <- line-indent end-of-previous-line, d @@ -862,13 +862,13 @@ recipe insert-new-line-and-indent editor:address:shared:editor-data, screen:addr # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the number of spaces at the start of the line containing 'curr'. -recipe line-indent curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ +def line-indent curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 - reply-unless curr + return-unless curr at-start?:boolean <- equal curr, start - reply-if at-start? + return-if at-start? { curr <- prev curr break-unless curr @@ -995,7 +995,7 @@ after [ indent?:address:boolean <- get-address *editor, indent?:offset *indent? <- copy 0/false go-render? <- copy 1/true - reply + return } ] @@ -1006,13 +1006,13 @@ after [ indent?:address:boolean <- get-address *editor, indent?:offset *indent? <- copy 1/true go-render? <- copy 1/true - reply + return } ] ## helpers -recipe draw-horizontal screen:address:shared:screen, row:number, x:number, right:number -> screen:address:shared:screen [ +def draw-horizontal screen:address:shared:screen, row:number, x:number, right:number -> screen:address:shared:screen [ local-scope load-ingredients style:character, style-found?:boolean <- next-ingredient diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu index f6c762a6..c09c3441 100644 --- a/edit/003-shortcuts.mu +++ b/edit/003-shortcuts.mu @@ -32,7 +32,7 @@ after [ editor, screen, go-render?:boolean <- insert-at-cursor editor, 32/space, screen go-render? <- copy 1/true - reply + return } ] @@ -73,14 +73,14 @@ after [ editor, screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character <- delete-before-cursor editor, screen - reply + return } ] # return values: # go-render? - whether caller needs to update the screen # backspaced-cell - value deleted (or 0 if nothing was deleted) so we can save it for undo, etc. -recipe delete-before-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character [ +def delete-before-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, backspaced-cell:address:shared:duplex-list:character [ local-scope load-ingredients before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset @@ -88,7 +88,7 @@ recipe delete-before-cursor editor:address:shared:editor-data, screen:address:sh # if at start of text (before-cursor at § sentinel), return prev:address:shared:duplex-list:character <- prev *before-cursor go-render?, backspaced-cell <- copy 0/no-more-render, 0/nothing-deleted - reply-unless prev + return-unless prev trace 10, [app], [delete-before-cursor] original-row:number <- get *editor, cursor-row:offset editor, scroll?:boolean <- move-cursor-coordinates-left editor @@ -96,14 +96,14 @@ recipe delete-before-cursor editor:address:shared:editor-data, screen:address:sh data <- remove *before-cursor, data # will also neatly trim next/prev pointers in backspaced-cell/*before-cursor *before-cursor <- copy prev go-render? <- copy 1/true - reply-if scroll? + return-if scroll? screen-width:number <- screen-width screen cursor-row:number <- get *editor, cursor-row:offset cursor-column:number <- get *editor, cursor-column:offset # did we just backspace over a newline? same-row?:boolean <- equal cursor-row, original-row go-render? <- copy 1/true - reply-unless same-row? + return-unless same-row? left:number <- get *editor, left:offset right:number <- get *editor, right:offset curr:address:shared:duplex-list:character <- next *before-cursor @@ -113,7 +113,7 @@ recipe delete-before-cursor editor:address:shared:editor-data, screen:address:sh # hit right margin? give up and let caller render at-right?:boolean <- greater-or-equal curr-column, right go-render? <- copy 1/true - reply-if at-right? + return-if at-right? break-unless curr # newline? done. currc:character <- get *curr, value:offset @@ -130,7 +130,7 @@ recipe delete-before-cursor editor:address:shared:editor-data, screen:address:sh go-render? <- copy 0/false ] -recipe move-cursor-coordinates-left editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ +def move-cursor-coordinates-left editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients before-cursor:address:shared:duplex-list:character <- get *editor, before-cursor:offset @@ -144,7 +144,7 @@ recipe move-cursor-coordinates-left editor:address:shared:editor-data -> editor: trace 10, [app], [decrementing cursor column] *cursor-column <- subtract *cursor-column, 1 go-render? <- copy 0/false - reply + return } # if at left margin, we must move to previous row: top-of-screen?:boolean <- equal *cursor-row, 1 # exclude menu bar @@ -179,7 +179,7 @@ recipe move-cursor-coordinates-left editor:address:shared:editor-data -> editor: break-if wrap? *cursor-column <- add left, end-of-line } - reply + return } # case 2: if previous-character was not newline, we're just at a wrapped line trace 10, [app], [wrapping to previous line] @@ -189,13 +189,13 @@ recipe move-cursor-coordinates-left editor:address:shared:editor-data -> editor: # takes a pointer 'curr' into the doubly-linked list and its sentinel, counts # the length of the previous line before the 'curr' pointer. -recipe previous-line-length curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ +def previous-line-length curr:address:shared:duplex-list:character, start:address:shared:duplex-list:character -> result:number [ local-scope load-ingredients result:number <- copy 0 - reply-unless curr + return-unless curr at-start?:boolean <- equal curr, start - reply-if at-start? + return-if at-start? { curr <- prev curr break-unless curr @@ -338,23 +338,23 @@ after [ editor, screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character <- delete-at-cursor editor, screen - reply + return } ] -recipe delete-at-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character [ +def delete-at-cursor editor:address:shared:editor-data, screen:address:shared:screen -> editor:address:shared:editor-data, screen:address:shared:screen, go-render?:boolean, deleted-cell:address:shared:duplex-list:character [ local-scope load-ingredients before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset data:address:shared:duplex-list:character <- get *editor, data:offset deleted-cell:address:shared:duplex-list:character <- next *before-cursor go-render? <- copy 0/false - reply-unless deleted-cell + return-unless deleted-cell currc:character <- get *deleted-cell, value:offset data <- remove deleted-cell, data deleted-newline?:boolean <- equal currc, 10/newline go-render? <- copy 1/true - reply-if deleted-newline? + return-if deleted-newline? # wasn't a newline? render rest of line curr:address:shared:duplex-list:character <- next *before-cursor # refresh after remove above cursor-row:address:number <- get-address *editor, cursor-row:offset @@ -366,7 +366,7 @@ recipe delete-at-cursor editor:address:shared:editor-data, screen:address:shared # hit right margin? give up and let caller render at-right?:boolean <- greater-or-equal curr-column, screen-width go-render? <- copy 1/true - reply-if at-right? + return-if at-right? break-unless curr # newline? done. currc:character <- get *curr, value:offset @@ -421,11 +421,11 @@ after [ screen <- move-cursor screen, *cursor-row, *cursor-column undo-coalesce-tag:number <- copy 2/right-arrow - reply + return } ] -recipe move-cursor-coordinates-right editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ +def move-cursor-coordinates-right editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients before-cursor:address:shared:duplex-list:character <- get *editor before-cursor:offset @@ -442,11 +442,11 @@ recipe move-cursor-coordinates-right editor:address:shared:editor-data, screen-h *cursor-column <- copy left below-screen?:boolean <- greater-or-equal *cursor-row, screen-height # must be equal go-render? <- copy 0/false - reply-unless below-screen? + return-unless below-screen? *cursor-row <- subtract *cursor-row, 1 # bring back into screen range go-render? <- copy 1/true - reply + return } # if the line wraps, move cursor to start of next row { @@ -463,11 +463,11 @@ recipe move-cursor-coordinates-right editor:address:shared:editor-data, screen-h *cursor-row <- add *cursor-row, 1 *cursor-column <- copy left below-screen?:boolean <- greater-or-equal *cursor-row, screen-height # must be equal - reply-unless below-screen?, editor/same-as-ingredient:0, 0/no-more-render + return-unless below-screen?, editor/same-as-ingredient:0, 0/no-more-render *cursor-row <- subtract *cursor-row, 1 # bring back into screen range go-render? <- copy 1/true - reply + return } # otherwise move cursor one character right *cursor-column <- add *cursor-column, 1 @@ -691,13 +691,13 @@ after [ # if not at start of text (before-cursor at § sentinel) prev:address:shared:duplex-list:character <- prev *before-cursor go-render? <- copy 0/false - reply-unless prev + return-unless prev editor, go-render? <- move-cursor-coordinates-left editor *before-cursor <- copy prev undo-coalesce-tag:number <- copy 1/left-arrow - reply + return } ] @@ -954,11 +954,11 @@ after [ editor, go-render? <- move-to-previous-line editor undo-coalesce-tag:number <- copy 3/up-arrow - reply + return } ] -recipe move-to-previous-line editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ +def move-to-previous-line editor:address:shared:editor-data -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset @@ -982,14 +982,14 @@ recipe move-to-previous-line editor:address:shared:editor-data -> editor:address curr:address:shared:duplex-list:character <- before-previous-line curr, editor no-motion?:boolean <- equal curr, old go-render? <- copy 0/false - reply-if no-motion? + return-if no-motion? } { old <- copy curr curr <- before-previous-line curr, editor no-motion?:boolean <- equal curr, old go-render? <- copy 0/false - reply-if no-motion? + return-if no-motion? } *before-cursor <- copy curr *cursor-row <- subtract *cursor-row, 1 @@ -1010,14 +1010,14 @@ recipe move-to-previous-line editor:address:shared:editor-data -> editor:address loop } go-render? <- copy 0/false - reply + return } { # if cursor already at top, scroll up break-unless already-at-top? go-render? <- copy 1/true - reply + return } ] @@ -1179,11 +1179,11 @@ after [ editor, go-render? <- move-to-next-line editor, screen-height undo-coalesce-tag:number <- copy 4/down-arrow - reply + return } ] -recipe move-to-next-line editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ +def move-to-next-line editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data, go-render?:boolean [ local-scope load-ingredients cursor-row:address:number <- get-address *editor, cursor-row:offset @@ -1207,7 +1207,7 @@ recipe move-to-next-line editor:address:shared:editor-data, screen-height:number scroll?:boolean <- greater-than *cursor-row, 1 break-if scroll?, +try-to-scroll:label go-render? <- copy 0/false - reply + return } *cursor-row <- add *cursor-row, 1 *before-cursor <- copy next-line @@ -1227,7 +1227,7 @@ recipe move-to-next-line editor:address:shared:editor-data, screen-height:number loop } go-render? <- copy 0/false - reply + return } +try-to-scroll @@ -1306,7 +1306,7 @@ after [ undo-coalesce-tag:number <- copy 0/never go-render? <- copy 0/false - reply + return } ] @@ -1319,11 +1319,11 @@ after [ undo-coalesce-tag:number <- copy 0/never go-render? <- copy 0/false - reply + return } ] -recipe move-to-start-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ +def move-to-start-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients # update cursor column @@ -1477,7 +1477,7 @@ after [ undo-coalesce-tag:number <- copy 0/never go-render? <- copy 0/false - reply + return } ] @@ -1490,11 +1490,11 @@ after [ undo-coalesce-tag:number <- copy 0/never go-render? <- copy 0/false - reply + return } ] -recipe move-to-end-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ +def move-to-end-of-line editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset @@ -1620,11 +1620,11 @@ after [ deleted-cells:address:shared:duplex-list:character <- delete-to-start-of-line editor go-render? <- copy 1/true - reply + return } ] -recipe delete-to-start-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ +def delete-to-start-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ local-scope load-ingredients # compute range to delete @@ -1754,11 +1754,11 @@ after [ deleted-cells:address:shared:duplex-list:character <- delete-to-end-of-line editor go-render? <- copy 1/true - reply + return } ] -recipe delete-to-end-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ +def delete-to-end-of-line editor:address:shared:editor-data -> result:address:shared:duplex-list:character, editor:address:shared:editor-data [ local-scope load-ingredients # compute range to delete @@ -1937,13 +1937,13 @@ after [ *top-of-screen <- before-start-of-next-line *top-of-screen, max no-movement?:boolean <- equal old-top, *top-of-screen go-render? <- copy 0/false - reply-if no-movement? + return-if no-movement? ] # takes a pointer into the doubly-linked list, scans ahead at most 'max' # positions until the next newline # beware: never return null pointer. -recipe before-start-of-next-line original:address:shared:duplex-list:character, max:number -> curr:address:shared:duplex-list:character [ +def before-start-of-next-line original:address:shared:duplex-list:character, max:number -> curr:address:shared:duplex-list:character [ local-scope load-ingredients count:number <- copy 0 @@ -1957,7 +1957,7 @@ recipe before-start-of-next-line original:address:shared:duplex-list:character, count <- add count, 1 } { - reply-unless curr, original + return-unless curr, original done?:boolean <- greater-or-equal count, max break-if done? c:character <- get *curr, value:offset @@ -1967,8 +1967,8 @@ recipe before-start-of-next-line original:address:shared:duplex-list:character, count <- add count, 1 loop } - reply-unless curr, original - reply curr + return-unless curr, original + return curr ] scenario editor-scrolls-down-past-wrapped-line-using-arrow-keys [ @@ -2304,13 +2304,13 @@ after [ *top-of-screen <- before-previous-line *top-of-screen, editor no-movement?:boolean <- equal old-top, *top-of-screen go-render? <- copy 0/false - reply-if no-movement? + return-if no-movement? ] # takes a pointer into the doubly-linked list, scans back to before start of # previous *wrapped* line # beware: never return null pointer -recipe before-previous-line in:address:shared:duplex-list:character, editor:address:shared:editor-data -> out:address:shared:duplex-list:character [ +def before-previous-line in:address:shared:duplex-list:character, editor:address:shared:editor-data -> out:address:shared:duplex-list:character [ local-scope load-ingredients curr:address:shared:duplex-list:character <- copy in @@ -2327,8 +2327,8 @@ recipe before-previous-line in:address:shared:duplex-list:character, editor:addr break-if len # empty line; just skip this newline prev:address:shared:duplex-list:character <- prev curr - reply-unless prev, curr - reply prev + return-unless prev, curr + return prev } _, max:number <- divide-with-remainder len, max-line-length # remainder 0 => scan one width-worth @@ -2348,7 +2348,7 @@ recipe before-previous-line in:address:shared:duplex-list:character, editor:addr count <- add count, 1 loop } - reply curr + return curr ] scenario editor-scrolls-up-past-wrapped-line-using-arrow-keys [ @@ -2698,7 +2698,7 @@ after [ no-movement?:boolean <- equal *top-of-screen, old-top go-render? <- not no-movement? - reply + return } ] @@ -2714,18 +2714,18 @@ after [ no-movement?:boolean <- equal *top-of-screen, old-top go-render? <- not no-movement? - reply + return } ] # page-down skips entire wrapped lines, so it can't scroll past lines # taking up the entire screen -recipe page-down editor:address:shared:editor-data -> editor:address:shared:editor-data [ +def page-down editor:address:shared:editor-data -> editor:address:shared:editor-data [ local-scope load-ingredients # if editor contents don't overflow screen, do nothing bottom-of-screen:address:shared:duplex-list:character <- get *editor, bottom-of-screen:offset - reply-unless bottom-of-screen + return-unless bottom-of-screen # if not, position cursor at final character before-cursor:address:address:shared:duplex-list:character <- get-address *editor, before-cursor:offset *before-cursor <- prev bottom-of-screen @@ -2890,7 +2890,7 @@ after [ no-movement?:boolean <- equal *top-of-screen, old-top go-render? <- not no-movement? - reply + return } ] @@ -2907,11 +2907,11 @@ after [ no-movement?:boolean <- equal *top-of-screen, old-top # don't bother re-rendering if nothing changed. todo: test this go-render? <- not no-movement? - reply + return } ] -recipe page-up editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data [ +def page-up editor:address:shared:editor-data, screen-height:number -> editor:address:shared:editor-data [ local-scope load-ingredients max:number <- subtract screen-height, 1/menu-bar, 1/overlapping-line diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu index 75d14245..e8ff90d8 100644 --- a/edit/004-programming-environment.mu +++ b/edit/004-programming-environment.mu @@ -3,7 +3,7 @@ # Consists of one editor on the left for recipes and one on the right for the # sandbox. -recipe! main [ +def! main [ local-scope open-console initial-recipe:address:shared:array:character <- restore [recipes.mu] @@ -21,7 +21,7 @@ container programming-environment-data [ sandbox-in-focus?:boolean # false => cursor in recipes; true => cursor in current-sandbox ] -recipe new-programming-environment screen:address:shared:screen, initial-recipe-contents:address:shared:array:character, initial-sandbox-contents:address:shared:array:character -> result:address:shared:programming-environment-data, screen:address:shared:screen [ +def new-programming-environment screen:address:shared:screen, initial-recipe-contents:address:shared:array:character, initial-sandbox-contents:address:shared:array:character -> result:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients width:number <- screen-width screen @@ -48,7 +48,7 @@ recipe new-programming-environment screen:address:shared:screen, initial-recipe- ] -recipe event-loop screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data -> screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data [ +def event-loop screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data -> screen:address:shared:screen, console:address:shared:console, env:address:shared:programming-environment-data [ local-scope load-ingredients recipes:address:shared:editor-data <- get *env, recipes:offset @@ -180,7 +180,7 @@ recipe event-loop screen:address:shared:screen, console:address:shared:console, } ] -recipe resize screen:address:shared:screen, env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data, screen:address:shared:screen [ +def resize screen:address:shared:screen, env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients clear-screen screen # update screen dimensions @@ -372,7 +372,7 @@ def] ] ] -recipe render-all screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ +def render-all screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ local-scope load-ingredients trace 10, [app], [render all] @@ -405,7 +405,7 @@ recipe render-all screen:address:shared:screen, env:address:shared:programming-e show-screen screen ] -recipe render-recipes screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ +def render-recipes screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ local-scope load-ingredients trace 11, [app], [render recipes] @@ -424,7 +424,7 @@ recipe render-recipes screen:address:shared:screen, env:address:shared:programmi ] # replaced in a later layer -recipe render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ +def render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ local-scope load-ingredients current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset @@ -439,7 +439,7 @@ recipe render-sandbox-side screen:address:shared:screen, env:address:shared:prog clear-screen-from screen, row, left, left, right ] -recipe update-cursor screen:address:shared:screen, recipes:address:shared:editor-data, current-sandbox:address:shared:editor-data, sandbox-in-focus?:boolean, env:address:shared:programming-environment-data -> screen:address:shared:screen [ +def update-cursor screen:address:shared:screen, recipes:address:shared:editor-data, current-sandbox:address:shared:editor-data, sandbox-in-focus?:boolean, env:address:shared:programming-environment-data -> screen:address:shared:screen [ local-scope load-ingredients @@ -458,10 +458,10 @@ recipe update-cursor screen:address:shared:screen, recipes:address:shared:editor # print a text 's' to 'editor' in 'color' starting at 'row' # clear rest of last line, move cursor to next line -recipe render screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:shared:screen [ +def render screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, color:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients - reply-unless s + return-unless s column:number <- copy left screen <- move-cursor screen, row, column screen-height:number <- screen-height screen @@ -519,10 +519,10 @@ recipe render screen:address:shared:screen, s:address:shared:array:character, le ] # like 'render' for texts, but with colorization for comments like in the editor -recipe render-code screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ +def render-code screen:address:shared:screen, s:address:shared:array:character, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients - reply-unless s + return-unless s color:number <- copy 7/white column:number <- copy left screen <- move-cursor screen, row, column @@ -608,7 +608,7 @@ after [ ## helpers -recipe draw-vertical screen:address:shared:screen, col:number, y:number, bottom:number -> screen:address:shared:screen [ +def draw-vertical screen:address:shared:screen, col:number, y:number, bottom:number -> screen:address:shared:screen [ local-scope load-ingredients style:character, style-found?:boolean <- next-ingredient diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu index 4f96e55e..361a346f 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -4,7 +4,7 @@ # (non-editable) sandboxes below the editor, showing the result and a maybe # few other things. -recipe! main [ +def! main [ local-scope open-console initial-recipe:address:shared:array:character <- restore [recipes.mu] @@ -142,11 +142,11 @@ after [ } ] -recipe run-sandboxes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ +def run-sandboxes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients errors-found?:boolean, env, screen <- update-recipes env, screen - reply-if errors-found? + return-if errors-found? # check contents of right editor (sandbox) current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset @@ -189,7 +189,7 @@ recipe run-sandboxes env:address:shared:programming-environment-data, screen:add # copy code from recipe editor, persist, load into mu # replaced in a later layer (whereupon errors-found? will actually be set) -recipe update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ +def update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients recipes:address:shared:editor-data <- get *env, recipes:offset @@ -200,7 +200,7 @@ recipe update-recipes env:address:shared:programming-environment-data, screen:ad ] # replaced in a later layer -recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ local-scope load-ingredients data:address:shared:array:character <- get *sandbox, data:offset @@ -209,14 +209,14 @@ recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:p *response, _, *fake-screen <- run-interactive data ] -recipe update-status screen:address:shared:screen, msg:address:shared:array:character, color:number -> screen:address:shared:screen [ +def update-status screen:address:shared:screen, msg:address:shared:array:character, color:number -> screen:address:shared:screen [ local-scope load-ingredients screen <- move-cursor screen, 0, 2 screen <- print screen, msg, color, 238/grey/background ] -recipe save-sandboxes env:address:shared:programming-environment-data [ +def save-sandboxes env:address:shared:programming-environment-data [ local-scope load-ingredients current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset @@ -237,7 +237,7 @@ recipe save-sandboxes env:address:shared:programming-environment-data [ } ] -recipe! render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ +def! render-sandbox-side screen:address:shared:screen, env:address:shared:programming-environment-data -> screen:address:shared:screen, env:address:shared:programming-environment-data [ local-scope load-ingredients trace 11, [app], [render sandbox side] @@ -261,13 +261,13 @@ recipe! render-sandbox-side screen:address:shared:screen, env:address:shared:pro clear-rest-of-screen screen, row, left, right ] -recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number -> row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [ +def render-sandboxes screen:address:shared:screen, sandbox:address:shared:sandbox-data, left:number, right:number, row:number, render-from:number, idx:number -> row:number, screen:address:shared:screen, sandbox:address:shared:sandbox-data [ local-scope load-ingredients - reply-unless sandbox + return-unless sandbox screen-height:number <- screen-height screen at-bottom?:boolean <- greater-or-equal row, screen-height - reply-if at-bottom?:boolean + return-if at-bottom?:boolean hidden?:boolean <- lesser-than idx, render-from { break-if hidden? @@ -304,7 +304,7 @@ recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:san } +render-sandbox-end at-bottom?:boolean <- greater-or-equal row, screen-height - reply-if at-bottom? + return-if at-bottom? # draw solid line after sandbox draw-horizontal screen, row, left, right, 9473/horizontal-double } @@ -324,7 +324,7 @@ recipe render-sandboxes screen:address:shared:screen, sandbox:address:shared:san ] # assumes programming environment has no sandboxes; restores them from previous session -recipe restore-sandboxes env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data [ +def restore-sandboxes env:address:shared:programming-environment-data -> env:address:shared:programming-environment-data [ local-scope load-ingredients # read all scenarios, pushing them to end of a list of scenarios @@ -358,10 +358,10 @@ recipe restore-sandboxes env:address:shared:programming-environment-data -> env: # print the fake sandbox screen to 'screen' with appropriate delimiters # leave cursor at start of next line -recipe render-screen screen:address:shared:screen, sandbox-screen:address:shared:screen, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ +def render-screen screen:address:shared:screen, sandbox-screen:address:shared:screen, left:number, right:number, row:number -> row:number, screen:address:shared:screen [ local-scope load-ingredients - reply-unless sandbox-screen + return-unless sandbox-screen # print 'screen:' header:address:shared:array:character <- new [screen:] row <- render screen, header, left, right, 245/grey, row @@ -510,7 +510,7 @@ scenario run-instruction-manages-screen-per-sandbox [ ] ] -recipe editor-contents editor:address:shared:editor-data -> result:address:shared:array:character [ +def editor-contents editor:address:shared:editor-data -> result:address:shared:array:character [ local-scope load-ingredients buf:address:shared:buffer <- new-buffer 80 @@ -518,7 +518,7 @@ recipe editor-contents editor:address:shared:editor-data -> result:address:share # skip § sentinel assert curr, [editor without data is illegal; must have at least a sentinel] curr <- next curr - reply-unless curr, 0 + return-unless curr, 0 { break-unless curr c:character <- get *curr, value:offset @@ -655,7 +655,7 @@ after [ break-unless scrolling? cursor-column:number <- get *current-sandbox, left:offset screen <- move-cursor screen, 2/row, cursor-column # highlighted sandbox will always start at row 2 - reply + return } ] @@ -678,21 +678,21 @@ after [ # sandbox belonging to 'env' whose next-sandbox is 'in' # return 0 if there's no such sandbox, either because 'in' doesn't exist in 'env', or because it's the first sandbox -recipe previous-sandbox env:address:shared:programming-environment-data, in:address:shared:sandbox-data -> out:address:shared:sandbox-data [ +def previous-sandbox env:address:shared:programming-environment-data, in:address:shared:sandbox-data -> out:address:shared:sandbox-data [ local-scope load-ingredients curr:address:shared:sandbox-data <- get *env, sandbox:offset - reply-unless curr, 0/nil + return-unless curr, 0/nil next:address:shared:sandbox-data <- get *curr, next-sandbox:offset { - reply-unless next, 0/nil + return-unless next, 0/nil found?:boolean <- equal next, in break-if found? curr <- copy next next <- get *curr, next-sandbox:offset loop } - reply curr + return curr ] scenario scrolling-down-on-recipe-side [ diff --git a/edit/006-sandbox-edit.mu b/edit/006-sandbox-edit.mu index de4be675..7354d60b 100644 --- a/edit/006-sandbox-edit.mu +++ b/edit/006-sandbox-edit.mu @@ -92,7 +92,7 @@ after [ } ] -recipe empty-editor? editor:address:shared:editor-data -> result:boolean [ +def empty-editor? editor:address:shared:editor-data -> result:boolean [ local-scope load-ingredients head:address:shared:duplex-list:character <- get *editor, data:offset @@ -100,13 +100,13 @@ recipe empty-editor? editor:address:shared:editor-data -> result:boolean [ result <- not first ] -recipe extract-sandbox env:address:shared:programming-environment-data, click-row:number -> result:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def extract-sandbox env:address:shared:programming-environment-data, click-row:number -> result:address:shared:sandbox-data, env:address:shared:programming-environment-data [ local-scope load-ingredients sandbox:address:address:shared:sandbox-data <- get-address *env, sandbox:offset start:number <- get **sandbox, starting-row-on-screen:offset in-editor?:boolean <- lesser-than click-row, start - reply-if in-editor?, 0 + return-if in-editor?, 0 { next-sandbox:address:shared:sandbox-data <- get **sandbox, next-sandbox:offset break-unless next-sandbox diff --git a/edit/007-sandbox-delete.mu b/edit/007-sandbox-delete.mu index 3d6d2d12..567e3cd6 100644 --- a/edit/007-sandbox-delete.mu +++ b/edit/007-sandbox-delete.mu @@ -77,14 +77,14 @@ after [ } ] -recipe delete-sandbox t:touch-event, env:address:shared:programming-environment-data -> was-delete?:boolean, env:address:shared:programming-environment-data [ +def delete-sandbox t:touch-event, env:address:shared:programming-environment-data -> was-delete?:boolean, env:address:shared:programming-environment-data [ local-scope load-ingredients click-column:number <- get t, column:offset current-sandbox:address:shared:editor-data <- get *env, current-sandbox:offset right:number <- get *current-sandbox, right:offset at-right?:boolean <- equal click-column, right - reply-unless at-right?, 0/false + return-unless at-right?, 0/false click-row:number <- get t, row:offset prev:address:address:shared:sandbox-data <- get-address *env, sandbox:offset curr:address:shared:sandbox-data <- get *env, sandbox:offset @@ -108,13 +108,13 @@ recipe delete-sandbox t:touch-event, env:address:shared:programming-environment- break-unless reset-scroll? *render-from <- copy -1 } - reply 1/true # force rerender + return 1/true # force rerender } prev <- get-address *curr, next-sandbox:offset curr <- get *curr, next-sandbox:offset loop } - reply 0/false + return 0/false ] scenario deleting-sandbox-after-scroll [ diff --git a/edit/008-sandbox-test.mu b/edit/008-sandbox-test.mu index 5fa4c70c..a3311891 100644 --- a/edit/008-sandbox-test.mu +++ b/edit/008-sandbox-test.mu @@ -132,7 +132,7 @@ after [ } ] -recipe find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ +def find-click-in-sandbox-output env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen @@ -152,13 +152,13 @@ recipe find-click-in-sandbox-output env:address:shared:programming-environment-d } # return sandbox if click is in its output region response-starting-row:number <- get *sandbox, response-starting-row-on-screen:offset - reply-unless response-starting-row, 0/no-click-in-sandbox-output + return-unless response-starting-row, 0/no-click-in-sandbox-output click-in-response?:boolean <- greater-or-equal click-row, response-starting-row - reply-unless click-in-response?, 0/no-click-in-sandbox-output - reply sandbox + return-unless click-in-response?, 0/no-click-in-sandbox-output + return sandbox ] -recipe toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ +def toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients expected-response:address:address:shared:array:character <- get-address *sandbox, expected-response:offset @@ -166,7 +166,7 @@ recipe toggle-expected-response sandbox:address:shared:sandbox-data -> sandbox:a # if expected-response is set, reset break-unless *expected-response *expected-response <- copy 0 - reply sandbox/same-as-ingredient:0 + return sandbox/same-as-ingredient:0 } # if not, current response is the expected response response:address:shared:array:character <- get *sandbox, response:offset diff --git a/edit/009-sandbox-trace.mu b/edit/009-sandbox-trace.mu index d95350bc..0ac17120 100644 --- a/edit/009-sandbox-trace.mu +++ b/edit/009-sandbox-trace.mu @@ -81,7 +81,7 @@ scenario sandbox-shows-app-trace-and-result [ 1:address:shared:array:character <- new [ recipe foo [ stash [abc] - reply 4 + reply 4 ]] # run it 2:address:shared:array:character <- new [foo] @@ -127,7 +127,7 @@ container sandbox-data [ ] # replaced in a later layer -recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ local-scope load-ingredients data:address:shared:array:character <- get *sandbox, data:offset @@ -166,7 +166,7 @@ after [ } ] -recipe find-click-in-sandbox-code env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ +def find-click-in-sandbox-code env:address:shared:programming-environment-data, click-row:number -> sandbox:address:shared:sandbox-data [ local-scope load-ingredients # assert click-row >= sandbox.starting-row-on-screen @@ -192,9 +192,9 @@ recipe find-click-in-sandbox-code env:address:shared:programming-environment-dat click-on-sandbox-code?:boolean <- and click-above-response?, click-below-menu? { break-if click-on-sandbox-code? - reply 0/no-click-in-sandbox-output + return 0/no-click-in-sandbox-output } - reply sandbox + return sandbox ] # when rendering a sandbox, dump its trace before response/warning if display-trace? property is set diff --git a/edit/010-errors.mu b/edit/010-errors.mu index 32dff4fa..aa4283e1 100644 --- a/edit/010-errors.mu +++ b/edit/010-errors.mu @@ -5,7 +5,7 @@ container programming-environment-data [ ] # copy code from recipe editor, persist, load into mu, save any errors -recipe! update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ +def! update-recipes env:address:shared:programming-environment-data, screen:address:shared:screen -> errors-found?:boolean, env:address:shared:programming-environment-data, screen:address:shared:screen [ local-scope load-ingredients recipes:address:shared:editor-data <- get *env, recipes:offset @@ -19,7 +19,7 @@ recipe! update-recipes env:address:shared:programming-environment-data, screen:a status:address:shared:array:character <- new [errors found ] update-status screen, status, 1/red errors-found? <- copy 1/true - reply + return } errors-found? <- copy 0/false ] @@ -81,7 +81,7 @@ container sandbox-data [ errors:address:shared:array:character ] -recipe! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ +def! update-sandbox sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data, idx:number -> sandbox:address:shared:sandbox-data, env:address:shared:programming-environment-data [ local-scope load-ingredients data:address:shared:array:character <- get *sandbox, data:offset diff --git a/edit/011-editor-undo.mu b/edit/011-editor-undo.mu index d79e056c..5866fb52 100644 --- a/edit/011-editor-undo.mu +++ b/edit/011-editor-undo.mu @@ -72,7 +72,7 @@ after [ redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset *redo <- push op, *redo - reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render + return screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render } ] @@ -88,7 +88,7 @@ after [ undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset *undo <- push op, *undo - reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render + return screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render } ] @@ -189,14 +189,14 @@ before [ # redo stack, because it's now obsolete. # Beware: since we're counting cursor moves as operations, this means just # moving the cursor can lose work on the undo stack. -recipe add-operation editor:address:shared:editor-data, op:address:shared:operation -> editor:address:shared:editor-data [ +def add-operation editor:address:shared:editor-data, op:address:shared:operation -> editor:address:shared:editor-data [ local-scope load-ingredients undo:address:address:shared:list:address:shared:operation <- get-address *editor, undo:offset *undo <- push op *undo redo:address:address:shared:list:address:shared:operation <- get-address *editor, redo:offset *redo <- copy 0 - reply editor/same-as-ingredient:0 + return editor/same-as-ingredient:0 ] after [ -- cgit 1.4.1-2-gfad0