Created
January 15, 2015 17:59
-
-
Save SaitoAtsushi/ea6362aa21d20b648282 to your computer and use it in GitHub Desktop.
(picrin protocol) の使用例。 ライブラリシステムとの相性?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-library (lib1) | |
(import | |
(scheme base) | |
(picrin protocol)) | |
(begin | |
(define-protocol (SHOW t) | |
(show t)) | |
) | |
(export show SHOW)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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