SRFI
SARと似てますがまた違いますねぇ。
ええと、「Matzにっき」さんを拝見したらSRFIの文字列が出てきて、これに反応してしまいました。
SRFI、Schemerならば一度は目にし、夢見させてくれる魔法の文字列ですね。
ここでとりあげられていたのがこれ。
http://srfi.schemers.org/srfi-89/srfi-89.html
ええと、やはり英語ですね。
ちゃんと読みましょう>おれ。
とりあえず、グーグル機械翻訳さんを利用。
http://www.google.co.jp/translate?langpair=en%7Cja&hl=ja&u=http%3A//srfi.schemers.org/srfi-89/srfi-89.html
結局今は何がどうなってるの?
:
いつのまにcase-lambdaなんてものが!
(let ((common-part (lambda (a b c d e) (+ a b c d e)))) (case-lambda (() (common-part 1 2 3 4 5)) ((a) (common-part a 2 3 4 5)) ((a b) (common-part a b 3 4 5)) ((a b c) (common-part a b c 4 5)) ((a b c d) (common-part a b c d 5)) ((a b c d e) (common-part a b c d e)))) is equivalent to this SRFI's: (lambda ([a 1] [b 2] [c 3] [d 4] [e 5]) (+ a b c d e))
むうちゃんとしている。なんかきっちりしてますね。で?
シンタックスはまあおいておいて(形式化してますねちゃんと)・・・
こういうときはソースを読め!そして慣れろ!ってことできょうれつなコピペ。
Here are some examples: (define (f a [b #f]) (list a b)) (f 1) ==> (1 #f) (f 1 2) ==> (1 2) (f 1 2 3) ==> error (define (g a [b a] [key: k (* a b)]) (list a b k)) (g 3) ==> (3 3 9) (g 3 4) ==> (3 4 12) (g 3 4 key:) ==> error (g 3 4 key: 5) ==> (3 4 5) (g 3 4 zoo: 5) ==> error (g 3 4 key: 5 key: 6) ==> error (define (h1 a [key: k #f] . r) (list a k r)) (h1 7) ==> (7 #f ()) (h1 7 8 9 10) ==> (7 #f (8 9 10)) (h1 7 key: 8 9 10) ==> (7 8 (9 10)) (h1 7 key: 8 zoo: 9) ==> error (define (h2 [key: k #f] a . r) (list a k r)) (h2 7) ==> (7 #f ()) (h2 7 8 9 10) ==> (7 #f (8 9 10)) (h2 key: 8 9 10) ==> (9 8 (10)) (h2 key: 8 zoo: 9) ==> error (define absent (list 'absent)) (define (element tag content . attributes) (list "<" tag attributes ">" content "</" tag ">")) (define (attribute name value) (if (eq? value absent) '() (list " " name "=" (escape value)))) (define (escape value) value) ; could be improved! (define (make-html-styler tag) (lambda ([id: id absent] [class: class absent] [title: title absent] [style: style absent] [dir: dir absent] [lang: lang absent] [onclick: onclick absent] [ondblclick: ondblclick absent] [onmousedown: onmousedown absent] [onmouseup: onmouseup absent] [onmouseover: onmouseover absent] [onmousemove: onmousemove absent] [onmouseout: onmouseout absent] [onkeypress: onkeypress absent] [onkeydown: onkeydown absent] [onkeyup: onkeyup absent] . content) (element tag content (attribute "id" id) (attribute "class" class) (attribute "title" title) (attribute "style" style) (attribute "dir" dir) (attribute "lang" lang) (attribute "onclick" onclick) (attribute "ondblclick" ondblclick) (attribute "onmousedown" onmousedown) (attribute "onmouseup" onmouseup) (attribute "onmouseover" onmouseover) (attribute "onmousemove" onmousemove) (attribute "onmouseout" onmouseout) (attribute "onkeypress" onkeypress) (attribute "onkeydown" onkeydown) (attribute "onkeyup" onkeyup)))) (define html-b (make-html-styler "b")) (define html-big (make-html-styler "big")) (define html-cite (make-html-styler "cite")) (define html-code (make-html-styler "code")) (define html-dfn (make-html-styler "dfn")) (define html-em (make-html-styler "em")) (define html-i (make-html-styler "i")) (define html-kbd (make-html-styler "kbd")) (define html-samp (make-html-styler "samp")) (define html-small (make-html-styler "small")) (define html-strong (make-html-styler "strong")) (define html-tt (make-html-styler "tt")) (define html-var (make-html-styler "var")) (define (print [port: port (current-output-port)] . args) (let pr ((x args)) (cond ((null? x)) ((pair? x) (pr (car x)) (pr (cdr x))) ((vector? x) (pr (vector->list x))) (else (display x port))))) (print (html-i class: 'molecule id: 'water (html-big "H") (html-small "2") (html-big "O"))) ==> displays on the current output port: <i id=water class=molecule><big>H</big><small>2</small><big>O</big></i>
うわ"(define (g a [b a] [key: k (* a b)]) (list a b k))"とかあたりでなんかもうすごい。
最後のHTML吐き出すあたりなんかもうなにか出来上がりそうなレベル。
そんなことになってましたか・・・
VBとかではなんとなく実装されているものがこうやってかっちりかつなんとなく公開の場で出来上がっていくのはすごいと。
こういうのを見ちゃうともうその、Schemeの継続ベースのウェブアプリとかシステムとかつくれたいいのにという妄想がまたむくむくと。
そういう夢を見させてくれるのはやはり、Shiro Kawaiさんがいらっしゃるからかなぁ。
http://www.shiro.dreamhost.com/scheme/index-j.html
プラクティカルスキームとはまあそのエスペラントを実用化するようなもので、夢のようですね。