MIT SchemeにR7RS bytevectorが登場
yuniが急にMIT/GNU Schemeで動かなくなったので調べてみると、どうも最近のMIT Scheme(9.4になるバージョン)にはbytevector関連の手続きが一通り用意されているようだ。
- https://github.com/okuoku/yuni/commit/ea9d9737ea3b4e08c7228eb0aad56a0e32963ccf
- yuniにはstringを使ったbytevector実装が有ったのでコメントアウトしといた
(yunibaseのDockerイメージには素の処理系も入れてあるので、パスさえ指定すれば直ぐに試すことができる)
oku@ubuntults:~$ docker run -it --rm okuoku/yunibase:latest /yunibase/current/mit-scheme/bin/scheme MIT/GNU Scheme running under GNU/Linux Type `^C' (control-C) followed by `H' to obtain information about interrupts. Copyright (C) 2017 Massachusetts Institute of Technology This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Image saved on Saturday February 25, 2017 at 4:46:23 AM Release 9.2.1 || Microcode 15.3 || Runtime 15.7 || SF 4.41 LIAR/x86-64 4.118 || Edwin 3.116 1 ]=> (define bv (make-bytevector 10 1)) ;Value: bv 1 ]=> bv ;Value 13: #u8(1 1 1 1 1 1 1 1 1 1) 1 ]=> (bytevector-u8-set! bv 1 2) ;Unspecified return value 1 ]=> bv ;Value 13: #u8(1 2 1 1 1 1 1 1 1 1) 1 ]=>
stable側(= MIT Scheme 9.2)にはmake-bytevectorは無い。
oku@ubuntults:~$ docker run -it --rm okuoku/yunibase:latest /yunibase/stable/mit-scheme/bin/scheme MIT/GNU Scheme running under GNU/Linux Type `^C' (control-C) followed by `H' to obtain information about interrupts. Copyright (C) 2014 Massachusetts Institute of Technology This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Image saved on Saturday May 17, 2014 at 2:39:25 AM Release 9.2 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 Edwin 3.116 1 ]=> make-bytevector ;Unbound variable: make-bytevector ;To continue, call RESTART with an option number: ; (RESTART 3) => Specify a value to use instead of make-bytevector. ; (RESTART 2) => Define make-bytevector to a given value. ; (RESTART 1) => Return to read-eval-print level 1. 2 error>
MIT Schemeはこの辺 http://git.savannah.gnu.org/cgit/mit-scheme.git/commit/?id=414206177f6478c3a396999e135dc8cd2f0bf6a6 のコミットのようにFFIでもbytevectorを使う方向に切り替えていくように見える(ただし特にML等でやりとりしているわけでは無さそうなので実際にどういう方向なのかは謎)。同時にChris Hansonによるstring周りの実装も進んでいるので、次のMIT SchemeのリリースではそれなりにR7RS互換性の向上を期待できそうだ。
... というわけでbytevectorの無いメジャーどころのScheme処理系はもう無いって考えて良いんだろうか。。R6RSから10年経ってるわけで流石にそろそろ前提にさせて欲しいところ。まぁ従来のMIT Schemeのようにbytevectorなんてstringで十分じゃん とやっていると、stringをUnicodeにしようというときに色々と微妙なのでやっぱり分けといた方が良いと個人的には思う。