dev-refac-2020
Matthew Butterick 6 years ago
parent 5fb1d5f633
commit b22b907663

@ -1,5 +1,8 @@
#lang racket/base
(require racket/class (for-syntax racket/base racket/syntax) racket/dict)
(require (for-syntax racket/base racket/syntax)
racket/class
racket/promise
racket/dict)
(provide (all-defined-out))
@ -44,7 +47,7 @@
(define ·-helper
(procedure-rename
(λ (x . refs)
(for/fold ([x x])
(for/fold ([x (force x)])
([ref (in-list refs)]
#:break (not x))
(cond
@ -55,7 +58,7 @@
[(dict? x) (dict-ref x ref #f)]
[(object? x) (cond
[(memq ref (field-names x)) (dynamic-get-field ref x)]
[else #f])]
[else #f])]
[else (raise-argument-error '· "object or dict" x)]))) '·))
(define-syntax-rule (· X REF ...) (·-helper X 'REF ...))
@ -83,7 +86,7 @@
(field [foo 'field])
(define/public (bar) 'method)
(define/public (zam) (hasheq 'zoom 'hash))))
(define h (hasheq 'bam (new C) 'foo 'hashlet))
(define h (delay (hasheq 'bam (new C) 'foo 'hashlet)))
(define o (new C))
(check-equal? (· o foo) 'field)
(check-equal? (· o bar) 'method)

Loading…
Cancel
Save