File: receive.rkt

package info (click to toggle)
racket 6.7-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 97,344 kB
  • ctags: 39,484
  • sloc: ansic: 277,847; sh: 33,512; asm: 13,558; lisp: 7,113; cpp: 2,872; makefile: 2,421; pascal: 2,262; exp: 499; python: 274; xml: 11
file content (22 lines) | stat: -rw-r--r-- 776 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
;;;
;;; <receive.rkt> ---- SRFI 8 Binding to Multiple Values port to PLT Scheme
;;; Time-stamp: <02/05/10 12:22:37 solsona>
;;;
;;; Usually, I would add a copyright notice, and the announce that
;;; this code is under the LGPL licence.  Nevertheless, I only did the
;;; port to PLT Scheme v200 (it was written for the 103), and here is
;;; the copyright notice, comments, and licence from the original
;;; source:
;;;
;;; oh well, there is no such comment.

#lang racket/base
(provide receive)

;; (receive vars producer . body)
(define-syntax receive
  (syntax-rules ()
    ((receive (var ...) ?producer . ?body)
     (let-values ([(var ...) ?producer]) . ?body))
    ((receive ?vars ?producer . ?body)
     (call-with-values (lambda () ?producer) (lambda ?vars . ?body)))))