7. 1-7-4節 記念碑 Quine (Monumental Quine)
円柱 Column
3D モデルデータ
3D model data
Ruby program https://www.shapeways.com/shops/mametter
Available for just $198
Ruby実行
execution
3Dプリント
3D print
8. 詳しくは書籍で
See the book
8
• こんなプログラムばかり
約 40 個ほど載ってます
includes 40 programs like these
– ほぼRuby、一部C言語
written in Ruby (and C)
– 実装技法の解説も
implementation techniques
are also disclosed
– Matzによる前書きも必見
preface by matz
9. Ruby 3.0 と超絶技巧プログラミング
Ruby 3.0 and transcendental programming
• Immutable string literal [Feature #11473]
– Ruby 3.0では文字列リテラルを破壊的に変更できなくなる
In Ruby 3.0, all string literals are frozen by default
– 導入理由:高速化などなど (for performance improvement)
• 個人的にはネガティブ (I’m against this change)
– Ruby には何事も「動的」であってほしい
I hope Ruby is always dynamic, as far as possible
9
""<<32
s="foobar"
s.gsub!("ob", "OB")
10. 「超絶技巧のために反対?」 No
”Are you against the change because of TP?” No!
• 超絶技巧プログラミングは言語仕様の枠と戦う遊び
We enjoy TP within the language spec
– 言語が変わるならそれに合わせて遊ぶだけ
If the language changes, we change how to enjoy
• ていうか対応は難しくない(はず)
Or rather, we also enjoy immutable string literals!
10
""<<32
""*1<<32
32.chr
"".dup<<32
11. 実証 Proof
• 本に掲載されている全プログラムを
immutable string literal 対応してみた
I’ve made all programs in the book ready for immutable string literals
11
http://github.com/mame/trance-book/tree/ruby-3.0
12. 一番やばかったやつ
Worst case
12
); s[ 8] =s
$> << s[ 0,
17 << 3] #C
Y. En do h!
); s[ 8] =s
$> << s[ 0,
17 << 3] #C
s= %( s= %(
13. チェスボード上の Quine
Quine on the chessboard
13
); s[ 8] =s
$> << s[ 0,
17 << 3] #C
Y. En do h!
); s[ 8] =s
$> << s[ 0,
17 << 3] #C
s= %( s= %(
15. 感想
Discussion
• 思ったよりは大変でした
It was harder than I expected
– 問題個所を見つけにくい
very hard to find the cause
– レイアウトを手動で再調整した
needed to rearrange the layout
– 別の Ruby のバグに遭遇した [Bug #11594]
encountered unrelated Ruby bug
15
とても優雅な時間を過ごせました
I enjoyed the change!
16. まとめ
Conclusion
• 自著を紹介しました
I introduced my book
– 技術評論社から発売中
gihyo.jp
– 2,680円+税
¥2,680 + tax
• Ruby 3.0 でも
遊べます(予定)
you can enjoy the book in 3.0
– 安心して
お買い上げください
Don’t hesitate to buy it!
16