chibi-scheme/lib/scheme/division.sld
Alex Shinn 8b5eb68238 File descriptors maintain a reference count of ports open on them
They can be close()d explicitly with close-file-descriptor, and
will close() on gc, but only explicitly closing the last port on
them will close the fileno.  Notably needed for network sockets
where we open separate input and output ports on the same socket.
2014-02-20 22:32:50 +09:00

31 lines
1.1 KiB
Scheme

;; This library is deprecated, occurring in early R7RS drafts before
;; being removed.
(define-library (scheme division)
(import (chibi))
(export ceiling-quotient ceiling-remainder ceiling/
centered-quotient centered-remainder centered/
euclidean-quotient euclidean-remainder euclidean/
floor-quotient floor-remainder floor/
round-quotient round-remainder round/
truncate-quotient truncate-remainder truncate/)
;; The second definition is always valid, but the first is simpler
;; and faster if exact ratios are supported and handled correctly
;; but floor/ceil/round.
(cond-expand
(ratios
(begin
(define-syntax copy-exactness2
(syntax-rules ()
((copy-exactness2 src1 src2 expr)
expr)))))
(else
(begin
(define-syntax copy-exactness2
(syntax-rules ()
((copy-exactness2 src1 src2 expr)
(let ((tmp expr))
(if (and (exact? src1) (exact? src2))
(inexact->exact tmp)
tmp))))))))
(include "division.scm"))