PasteRack.org
Paste # 63734
2017-09-18 15:25:23

Fork as a new paste.

Paste viewed 73 times.


Embed:

string->pict-function

  1. #lang racket/base
  2. (require pict)
  3.  
  4. (define-namespace-anchor src-anchor)
  5.  
  6. (define pict-only-namespace
  7.   (parameterize ([current-namespace (make-empty-namespace)])
  8.     (namespace-attach-module (namespace-anchor->namespace src-anchor) 'pict)
  9.     (namespace-require 'pict)
  10.     (current-namespace)))
  11.  
  12. ;; `eval`s a string to a function from the `pict` module.
  13. ;; Raises an exception if `pict` doesn't export an identifier that
  14. ;;  matches the given string.
  15. (define (string->pict-function str)
  16.   (eval (string->symbol str) pict-only-namespace))
  17.  
  18. ((string->pict-function "vl-append") (blank 0 0))
  19.  
  20. (string->pict-function "string-append")

=>

image

string-append: unbound identifier;

 also, no #%top syntax transformer is bound

  in: string-append