Hi Srini, > I read both of these references before, but am struggling to apply. From the > first one: > Functions with controlling expressions are case, casq, prog1, prog2, > and the bodies of *Run tasks. > Functions with conditional expressions are and, cond, do, for, if, if2, > ifn, loop, nand, nond, nor, not, or, state, unless, until, when and > while. > > So probably @ is updated by the function "later" ("body of run tasks").
To be precise: The value of '@' is the result of 'mapcan', i.e. the list of newly 'cons'ed cells: (prog1 (mapcan '((N) (later (cons) (* N N))) (1 2 3 4)) (wait NIL (full @)) ) However, it is not 'mapcan' that modifies '@', but 'prog1'. 'prog1' is one of the above "Functions with controlling expressions". So in the example, 'full' receives the list (NIL NIL NIL NIL). It looks at it repeatedly, until all 'NIL's are replaced with numeric results. This works because 'later' operates on a 'var', i.e. it remembers the cell and writes the result from the child's pipe into it. > Another possibility is that prog1 that updates the @ with NIL NIL NIL > NIL (the result of the first "expression"), but this is not likely, I No, this is correct. > think, as the @ would only be updated by it after the wait completes as > well. The value of '@' doesn't change again. It is the _contents_ of the cells which change. Perhaps two more explicit variations of the above example make things more clear, not regarding '@', but the interplay of the variables in 'later' and 'wait'. The following three expressions return the same result (1 4 9 16): (prog1 (mapcan '((N) (later (cons) (* N N))) (1 2 3 4)) (wait NIL (full @)) ) (use (A B C D) (later 'A (* 1 1)) # We hope to have a value later in 'A' (later 'B (* 2 2)) # We hope to have a value later in 'B' (later 'C (* 3 3)) # We hope to have a value later in 'C' (later 'D (* 4 4)) # We hope to have a value later in 'D' (wait NIL (and A B C D)) (list A B C D) ) (let L (list NIL NIL NIL NIL) (later L (* 1 1)) # We hope to have a value later in the first cell (later (cdr L) (* 2 2)) # We hope to have a value later in the second cell (later (cddr L) (* 3 3)) # We hope to have a value later in the third cell (later (cdddr L) (* 4 4)) # We hope to have a value later in the fourth cell (wait NIL (and # An explicit variant of (full L) (car L) (cadr L) (caddr L) (cadddr L) ) ) L ) ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe