racket/collects/texpict/private/convertible.rkt
Matthew Flatt 351e82735b move and rename pict `convert' support
Renamed `convert' to `pict-convert', etc., to avoid confusion
with `file/convert' bindings.

Moved out of `slideshow/pict' to `slideshow/pict-convert', because
most `slideshow/pict' clients do not need it.
2012-04-06 18:51:10 -06:00

20 lines
667 B
Racket

#lang racket/base
(provide prop:pict-convertible prop:pict-convertible? pict-convertible? pict-convert)
(define-values (prop:pict-convertible -pict-convertible? pict-convertible-ref)
(make-struct-type-property 'pict-convertible))
(define-values (prop:pict-convertible? pict-convertible?? pict-convertible?-ref)
(make-struct-type-property 'pict-convertible?))
(define (pict-convertible? x)
(and (-pict-convertible? x)
(if (pict-convertible?? x)
((pict-convertible?-ref x) x)
#t)))
(define (pict-convert v)
(unless (pict-convertible? v)
(raise-type-error 'pict-convert "pict-convertible" v))
((pict-convertible-ref v) v))