ToDo:
だなんて言ってるヤツが失望してほげほげなのさ、 とシニカルに言うのが流行りらしいから、 関数型言語が銀の弾丸だと言ってるヤツはほげほげなのさ、 と言うことにしようか。
(15:10)
結局、リクエストは UTF-8 で来てるので、 それを EUC になおさず処理しちまうのが一番良い。
そんで
http://kawa.at.webry.info/200511/article_9.html
紅茶は text/plain だからうまくいってるのかなぁ。 よくわからん。
(22:39)
ごめんなさい再帰的にほげほげはこりゃ無理だと思って諦めました。
オサレじゃなくてもすぐできたから、 あっさりできた、と書いたとか。
具体的にはこんな感じの rettype と argtype ができれば自明な実装。
http://shinh.skr.jp/tmp/signature.d
(16:27)
ほめてもらたーと思いつつ。
なんというか、書いてる最中とか 書き終わった後は何がキモだったか覚えてるけど、 memo/hatena 書いてる最中は忘れてる現象。
ぷろぐらむの語彙が貧弱な僕こそ 適当に名前をつけてキモを把握しておいた方がいいんでないかとか、 いややっぱデザパタ重要なんじゃないかとか。 だいたい自分のできたことすら把握してないから 人と話す時困るんだ。
マッチング能力は、 暗黙テンプレート引数>明示テンプレート引数>static if の : 、 なんだけど、 C++ だと 暗黙のテンプレート引数でマッチさせたものは関数なので、 そこから型を取り出すことが(たぶん)できない。 その関数を実際に呼んでしまってクラス返せばできるけどね。 でも D は typeof あるから取り出せるぜへへん、っていう話か。
static if はええとなんで弱いんだっけ。 思い出せんのだからメモをすべきだ。
ええと…
is ((T, U) : ???) って感じで書きたかったのは覚えている。
思い出した。
is (T (U, V) : U function(V)) と書きたかったんだ。 つかこれできたら暗黙テンプレートと同じマッチ能力あるじゃん。
つか2変数以上の部分特殊化ができない、 って書いてくれてるじゃん。
暗黙テンプレート引数>明示テンプレート引数=static if の :
だなたぶん。
やっとノウハウとして蓄積できた気がした…
D in depth Wiki とか作って C++ と違うテクニックを集積するとか。
誰が見るんだ、って勢いの Wiki を。
集積したテクニックはたぶんよく使えそうなものは もっと簡単な文法を Walter さんが導入しちゃうんだろうけど、 まぁ言語の進化ってのはそういうものだろう。
とりあえず /template/ みたいなノリで ひどい状態の /d/ をなんとかしよう。
(01:20)
前から思ってるけど、 いろいろタイムリーな気がするので bind が書きたい。
しかし現実逃避はよくない。良いんだけど。
過度の現実逃避はあなたの社会生活を害する恐れがあります。
(01:43)
をおされに書く方法が無ければやる気が起きないと気付く。
なんとかして再帰的な定義に持ち込めないか…
void (T t, ...) と void (T t) のオーバロードが できればなんとかできそうだけどできない。
つかそれがなんとかできても tail みたいなのが実装できんか。
argNum は実装できそうだなぁ。
TODO: 現実逃避をやめる。
(03:36)
なんかみんなやってるけど オサレな関数とか作るのもういいから、 だって別に他の関数型言語でもいいしな、 モナドとか型やろうぜーとか言ったら
http://haskell.g.hatena.ne.jp/mr_konn/20060613/1150213544
やった。
いやすげーなあああああ
(けど実は簡単な)IOモナド
というフレーズが実にクルものが。
IO はやっぱ IO って名前でいい気がします。 あと do の外でモナド外せたらマズくね、とか。
次はぜひ型をお願いします。
(07:13)
auto dubl = convolution(&concatMap, &replicate);
とは書けない気はする。 うぬぬ生意気な。
けど本当にできないのかな。 なんかほげほげできそうな。
メモ template opCall
(12:51)
int func(char, bool, char[], int[char[]]); alias functor!(typeof(&func)) f; static assert(is (f.rettype == int)); static assert(is (f.argtypes == TL!(char, bool, char[], int[char[]])));
ふむ。割にあっさりできた。
(18:48)
lib*-devel が入っていない lib* なんていらない。
i@u ~> rpm -qa | egrep '^lib' G devel | sort | perl -pe 's/devel-//' > devel i@u ~> rpm -qa | egrep '^lib' G -v devel | sort | perl -pe 's/devel-//' > libs i@u ~> diff libs devel | perl -pe 's/< //' G lib | perl -pe 's/-.*/-devel/' > devs i@u ~> for i in `cat devs`; do ~ 1:50 echo $i; sudo apt-get install $i done
(01:52)
http://slashdot.jp/article.pl?sid=06/06/12/2111252
サーバURLはntp.nict.jpとなっている。" (つづく...)
それURLなんか。
(10:45)
http://www.complexification.net/
via http://d.hatena.ne.jp/MDA/20060612/1150046311
かっこいいなぁ
漠然とこういうのに対する憧れがあるんだが 何していいかいまひとつピンと来ないんだよなぁ。
(02:51)
インストールできなかった。
どうすっかな。
(07:18)
i@u ~/test/hs> cat beki.hs len2 x y = (^^) x 2 + (^^) y 2 i@u ~/test/hs> ghci beki.hs ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.4.1, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base-1.0 ... linking ... done. Compiling Main ( beki.hs, interpreted ) Ok, modules loaded: Main. *Main> len2 3 4 25.0
今さら何を言ってるという感なんだろうな。
(08:12)
http://haskell.g.hatena.ne.jp/nobsun/20060611/p3
を見て思った。
main = putStrLn ("hamaji" ++ at ++ "nii" ++ dot ++ "ac" ++ dot ++ "jp")
where at = "@"
dot = "."
(21:36)
Windows のパーティションの切り方はよくわからない。
こんな感じかなぁ。
Linux いるのかなぁ? coLinux でいい気がする。
つかデスクトップをメインにしてもいいという話もあるのだが。
とりあえず testgl_net 走らせてみて考えるとか。
(05:15)
さくらのクローン環境が欲しい。 Presario に FreeBSD つっこむか。
(06:20)
気がついたら割とたくさんある。
i@u ~> /bin/ls -1 arch/hyperestraier-* arch/hyperestraier-0.3.13.tar.gz arch/hyperestraier-0.5.0.tar.gz arch/hyperestraier-0.5.1.tar.gz arch/hyperestraier-0.5.2.tar.gz arch/hyperestraier-0.5.3.tar.gz arch/hyperestraier-0.5.7.tar.gz arch/hyperestraier-0.9.0.tar.gz arch/hyperestraier-0.9.1.tar.gz arch/hyperestraier-0.9.2.tar.gz arch/hyperestraier-1.0.0.tar.gz arch/hyperestraier-1.0.1.tar.gz arch/hyperestraier-1.0.2.tar.gz arch/hyperestraier-1.0.3.tar.gz arch/hyperestraier-1.0.6.tar.gz arch/hyperestraier-1.1.0-experimental.tar.gz arch/hyperestraier-1.1.6.tar.gz arch/hyperestraier-1.2.0-experimental.tar.gz arch/hyperestraier-1.2.1.tar.gz arch/hyperestraier-1.2.2.tar.gz arch/hyperestraier-1.2.3.tar.gz
しょっちゅう消すせいか、案外すくない。
i@u ~> /bin/ls -1 arch/gcc-* arch/gcc-1.42.tar.gz arch/gcc-core-4.0.3.tar.bz2 arch/gcc-g++-3.4.0.tar.bz2 arch/gcc-g++-4.0.0.tar.bz2 arch/gcc-g++-4.0.2.tar.bz2 arch/gcc-g++-4.0.3.tar.bz2 arch/gcc-java-3.4.0.tar.bz2 arch/gcc-java-4.0.2.tar.bz2 arch/gcc-java-4.0.3.tar.bz2 arch/gcc-objc-4.0.2.tar.bz2
(08:04)
http://www.kmonos.net/alang/etc/ecmascript.php
の例をかたっぱしから実行。
匿名関数を () で囲ってほげれない、のかな。
i@u ~/test/js> cat ki10.ds
var x = ( function(a, b) {
return (a==0 ? b : arguments.callee(b%a, a));
} )( 60, 84 );
println( x );
i@u ~/test/js> ds ki10.ds
Digital Mars DMDScript 1.10
www.digitalmars.com
Compiled by Digital Mars DMD D compiler
Copyright (c) 1999-2006 by Digital Mars
written by Walter Bright
1 source files
Error: (1) : Error: cannot assign to function (a,b)
{
return b ? arguments.callee(b % a, a);
}
i@u ~/test/js> cat ki11.ds
var f = function(a, b) {
return (a==0 ? b : arguments.callee(b%a, a));
}
var x = f( 60, 84 );
println( x );
i@u ~/test/js> ds ki11.ds
Digital Mars DMDScript 1.10
www.digitalmars.com
Compiled by Digital Mars DMD D compiler
Copyright (c) 1999-2006 by Digital Mars
written by Walter Bright
1 source files
12
closure が無いのかね。
i@u ~/test/js> cat ki12.ds
function map( arr, f )
{
var newArr = new Array(arr.length);
for( var i=0; i<arr.length; ++i )
newArr[i] = f( arr[i] );
return newArr;
}
function mem_fn( mf )
{
println('OUTSIDE: ' + mf);
return function(obj) {
println('INSIDE: ' + mf);
var args = new Array(arguments.length-1);
for( var i=1; i<arguments.length; ++i )
args[i-1] = arguments[i];
return mf.apply( obj, args );
};
}
x = map(
['hoge', 'fuga', 'hagyo'],
mem_fn( String.prototype.toUpperCase )
);
map( x, println );
i@u ~/test/js> ds ki12.ds
Digital Mars DMDScript 1.10
www.digitalmars.com
Compiled by Digital Mars DMD D compiler
Copyright (c) 1999-2006 by Digital Mars
written by Walter Bright
1 source files
OUTSIDE: function toUpperCase() { [native code] }
INSIDE: undefined
Error: Undefined undefined.apply is undefined and has no Call method
関数に name メソッドが無いかしら。
i@u ~/test/js> cat ki14.ds
function Point()
{
this.x = 0;
this.y = 0;
this.distanceFromOrigin = function()
{
return Math.sqrt( this.x*this.x + this.y*this.y );
}
}
var pt = new Point();
pt.x = 5;
pt.y = -12;
println( pt.distanceFromOrigin() );
println( pt.constructor );
println( pt.constructor.name );
i@u ~/test/js> ds ki14.ds
Digital Mars DMDScript 1.10
www.digitalmars.com
Compiled by Digital Mars DMD D compiler
Copyright (c) 1999-2006 by Digital Mars
written by Walter Bright
1 source files
13
function Point()
{
}
undefined
こっちは closure ぽく動くな。
i@u ~/test/js> cat ki16.ds
function Point()
{
var x = 0;
var y = 0;
this.getX = function() { return x; }
this.getY = function() { return y; }
this.set = function(i_x, i_y) { x=i_x; y=i_y; }
}
var pt = new Point();
pt.set(100, 200);
println( pt.getX() + ' ' + pt.getY() );
i@u ~/test/js> ds ki16.ds
Digital Mars DMDScript 1.10
www.digitalmars.com
Compiled by Digital Mars DMD D compiler
Copyright (c) 1999-2006 by Digital Mars
written by Walter Bright
1 source files
100 200
scope chain の話、の部分も当然だめ。 closure 系悲しす。
MS 拡張らしいが動く。
i@u ~/test/js> cat ki24.ds
// written for JScript.NET
function Point()
{
this.x = 0.0;
this.y = 0.0;
}
function Point.prototype.distanceFromOrigin()
{
return this.x*this.x + this.y*this.y;
}
println( (new Point()).distanceFromOrigin() );
i@u ~/test/js> ds ki24.ds
Digital Mars DMDScript 1.10
www.digitalmars.com
Compiled by Digital Mars DMD D compiler
Copyright (c) 1999-2006 by Digital Mars
written by Walter Bright
1 source files
0
arity もあるみたい。
i@u ~/test/js> cat ki25.ds
// written for Rhino
function add(x, y)
{
return x + y;
}
println( add.arity );
i@u ~/test/js> ds ki25.ds
Digital Mars DMDScript 1.10
www.digitalmars.com
Compiled by Digital Mars DMD D compiler
Copyright (c) 1999-2006 by Digital Mars
written by Walter Bright
1 source files
2
__proto__ はない。
i@u ~/test/js> cat ki26.ds
// written for Rhino
var objA = { f: function(){print("objA")} }
var objB = { f: function(){print("objB")} }
var objC = new Object();
var objD = new Object();
var objE = new Object();
objD.__proto__ = objE.__proto__ = objC;
objC.__proto__ = objA; // Cのプロトタイプ変更
objD.f();
objE.f();
objC.__proto__ = objB; // Cのプロトタイプ変更
objD.f();
objE.f();
i@u ~/test/js> ds ki26.ds
Digital Mars DMDScript 1.10
www.digitalmars.com
Compiled by Digital Mars DMD D compiler
Copyright (c) 1999-2006 by Digital Mars
written by Walter Bright
1 source files
Error: Object [object Object].f is undefined and has no Call method
a.caller も無いみたいね。
// written for MocaScript
function f1() { f2(); }
function f2() { f3(); }
function f3() { f4(); }
function f4() { f5(); }
function f5() { g(); }
function g() {
for(var a=arguments; a; a=a.caller) // 呼び出し元を順にたどる
if( a.callee == f1 ) // 呼び出され関数がf1なら…?
println("g was called inside f1");
}
f1();
i@u ~/test/js> ds ki27.ds
Digital Mars DMDScript 1.10
www.digitalmars.com
Compiled by Digital Mars DMD D compiler
Copyright (c) 1999-2006 by Digital Mars
written by Walter Bright
1 source files
(09:00)
import dmdscript.script;
void* Dglobal_hello(Dobject pthis, CallContext *cc,
Dobject othis, Value* ret, Value[] arglist)
{
writef("hello\n");
return null;
}
int main() {
static char[] TEXT_hello = "hello";
static NativeFunctionData nfd[] = [
{ &TEXT_hello, &Dglobal_hello },
];
Program p = new Program();
DnativeFunction.init(p.callcontext.global, nfd, DontEnum);
p.compile(`test1`, `println('hello1'); hello();`, null);
p.execute(null);
return 0;
}
compile するごとに別の状態になるので、 Web なんかで使ってる JS 的な、 状態持たせてちょっとずつ走らせるとかできんぽい。
うーん、使えない…
(09:42)
僕はモナドの章の引用が ディアスポラだったのでうっかり衝動買いしてしまった。
世間的にはふつけるの方が人気なのかしら。 とりあえず、ある程度はわかっていたであろう僕には わかりやすいなぁ。 1年前の僕ならちょいキツかったかもだけど。
(23:19)
| 前 | 2025年 10月 |
次 | ||||
| 日 | 月 | 火 | 水 | 木 | 金 | 土 |
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |
全てリンクフリーです。 コード片は自由に使用していただいて構いません。 その他のものはGPL扱いであればあらゆる使用に関して文句は言いません。 なにかあれば下記メールアドレスへ。