00:02:59
icon

ちゃんと休まないと治らないものも治らない…

00:03:31
icon

一般的なWeb開発者の画面

Attach image
11:50:26
icon

最初のawait ...の評価で#が流れてくるのがなぜか分からん

(require racket/control)

(define (then promise chain)
  (lambda (resolve reject)
    (promise (lambda (x) (resolve (chain x))) reject)))
    
(define (catch promise chain)
  (lambda (resolve reject)
    (promise resolve (lambda (x) (reject (chain x))))))
    
(define-syntax async
   (syntax-rules ()
     ((_ await body ...)
       (let ((tag (make-continuation-prompt-tag)))
         (lambda (resolve reject)
           (resolve
            (let/cc break
             (commit-loop reject
              (reset-at tag
               (let ((await (lambda (promise) (shift-at tag k (then promise k)))))
                 (break (begin body ...))))))))))))
           
 (define-syntax define-async
   (syntax-rules ()
     ((_ await (proc . args) body ...) (define (proc . args) (async await body ...)))))
 
 (define (commit-loop reject promise)
   (promise
      (lambda (result) (commit-loop reject result))
      (lambda (reason) (reject reason))))

(define (commit promise)
  (promise print print))

(define fetch-queue '())

(define (fetch-promise resolve reject)
  (set! fetch-queue
    (cons
      (lambda (x) (print "fetched") (resolve x))
      fetch-queue)))

(define (onFetch data)
  ((last fetch-queue) data)
  (set! fetch-queue (drop-right fetch-queue 1)))

(define-async await (fetch-n n)
  (let loop ((m 0))
    (if (= n m) n
      (begin
        (print
          (format "fetch #~a: ~a" m (await fetch-promise)))
        (loop (+ m 1))))))

> (commit (async await (print (await (fetch-n 3)))))
# #
> (onFetch "test")
"fetched""fetch #0: test"
> (onFetch "test2")
"fetched""fetch #1: test2"
> (onFetch "test3")
"fetched""fetch #2: test3"3#

19:11:46
icon

(set! fetch-queue ...)の返り値がcommit-loopの返り値になってそれがbreakして流れてくるのだった
commit-loopは普通の意味でのループではないことを忘れていた

RE:
https://misskey-square.net/notes/9z69mlt8gn

19:44:21
icon

継続ひねくり回していると、内部状態を正確にイメージできないから怪しそうなところを勘でプログラムして偶然動いたらラッキーという誤った方策に走りがちな初心者の気持ちがわかる

19:48:13
icon

結局二択になりがち

特にこだわりがない、動けばよい→Ubuntu
脳死で最新環境を使いたい→Arch