Files
emacs.d/elpa/racket-mode-20171116.1435/util.rkt
Mateus Pinto Rodrigues 2362e805bd Add new packages installed
2018-03-27 20:52:59 -03:00

27 lines
632 B
Racket

#lang racket/base
(require (for-syntax racket/base
syntax/parse))
(provide display-commented
with-dynamic-requires
box-swap!)
(define (display-commented str)
(eprintf "; ~a\n"
(regexp-replace* "\n" str "\n; ")))
(define-syntax (with-dynamic-requires stx)
(syntax-parse stx
[(_ ([lib:id id:id] ...+) body:expr ...+)
#'(let ([id (dynamic-require 'lib 'id)] ...)
body ...)]))
(define (box-swap! box f . args)
(let loop ()
(let* ([old (unbox box)]
[new (apply f old args)])
(if (box-cas! box old new)
new
(loop)))))