Skip to content

Instantly share code, notes, and snippets.

@SaitoAtsushi
Created January 15, 2015 17:59
Show Gist options
  • Save SaitoAtsushi/ea6362aa21d20b648282 to your computer and use it in GitHub Desktop.
Save SaitoAtsushi/ea6362aa21d20b648282 to your computer and use it in GitHub Desktop.
(picrin protocol) の使用例。 ライブラリシステムとの相性?
(define-library (lib1)
(import
(scheme base)
(picrin protocol))
(begin
(define-protocol (SHOW t)
(show t))
)
(export show SHOW))
(define-library (lib2)
(import
(picrin class)
(picrin protocol)
(lib1)
(scheme base))
(begin
(define-instance (SHOW <boolean>)
(lambda (x)
(if x
"#<boolean true>"
"#<boolean false>")))
(define (show-number-1)
(show 1))
(define (show-true)
(show #true))
)
(export show-number-1 show-true))
(import (lib1)
(lib2)
(scheme base)
(scheme write)
(picrin class)
(picrin protocol))
(define-instance (SHOW <number>)
(lambda(x)
(string-append "#<number " (number->string x) ">")))
(display (show-number-1))
(newline)
(display (show-true))
(newline)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment