HS: send can reference sender (+1 test)

Three-part fix: (a) emit-send now builds detail=(dict "sender" me) on
(send NAME target) and bare (send NAME) instead of nil, so the receiving
handler has access to the sending element. (b) parser parse-atom now
recognises the `sender` keyword (previously swallowed as noise) and
emits it as (sender). (c) compiler translates bare `sender` symbol and
(sender) list-head to (hs-sender event) — a new runtime helper that
reads (get (host-get event "detail") "sender").

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 22:37:18 +00:00
parent 15c310cdc1
commit ed8d71c9b8
6 changed files with 60 additions and 14 deletions

View File

@@ -687,6 +687,14 @@
(dom-insert-adjacent-html target "beforeend" (str value)))
(true nil)))))
;; Property-based is — check obj.key truthiness
(define
hs-sender
(fn
(event)
(let
((detail (host-get event "detail")))
(if detail (host-get detail "sender") nil))))
;; Array slicing (inclusive both ends)
(define
hs-host-to-sx
(fn
@@ -740,7 +748,7 @@
(dict-set! out k (hs-host-to-sx (host-get v k))))
(host-call (host-global "Object") "keys" v))
out)))))))))))
;; Array slicing (inclusive both ends)
;; Collection: sorted by
(define
hs-fetch
(fn
@@ -750,7 +758,7 @@
(let
((raw (perform (list "io-fetch" url fmt))))
(cond ((= fmt "json") (hs-host-to-sx raw)) (true raw))))))
;; Collection: sorted by
;; Collection: sorted by descending
(define
hs-json-escape
(fn
@@ -781,7 +789,7 @@
(walk)
out)
"\"")))
;; Collection: sorted by descending
;; Collection: split by
(define
hs-json-stringify
(fn
@@ -815,7 +823,7 @@
ks)))
"}")))
(true (hs-json-escape (str v))))))
;; Collection: split by
;; Collection: joined by
(define
hs-coerce
(fn
@@ -929,7 +937,7 @@
(map (fn (k) (list k (get value k))) (keys value))
value))
(true value))))
;; Collection: joined by
(define
hs-gather-form-nodes
(fn