Skip to content

Make a hyperbracketed taffy-zap! operation for updating assignment #12

@rocketnia

Description

@rocketnia

We could have a hyperbracketed operation with a single hole that performs a mutation. For instance, these could be equivalent:

(taffy-zap! `(+ 20 ,(car (retrieve-list))))
(set! (car (retrieve-list)) (+ 20 (car (retrieve-list))))

Note that in this case, the (retrieve-list) expression is evaluated twice. Racket has a notion of set! transformer that processes whole expressions at a time, but it doesn't seem to have something like Arc's setforms where the subexpressions are factored out and only executed once. (The term zap here is also from Arc.)

We could actually address this shortcoming by combining taffy-zap! with taffy-let:

(taffy-let () `(taffy-zap! `(+ 20 ,(car ,(retrieve-list)))))

This would basically desugar to:

(let ([temp (retrieve-list)])
  (set! (car temp) (+ 20 (car temp))))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions