Browse thread
Where are the AST specs?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-03-19 (16:08) |
From: | Loup Vaillant <loup.vaillant@g...> |
Subject: | Re: [Caml-list] Where are the AST specs? |
2007/3/19, Nicolas Pouillard <nicolas.pouillard@gmail.com>: > [...camlp4code...] > $ cat test_macros.ml > let cons x xs = x :: xs;; > > foldl(( + ), 1, 2, 3, 4);; > foldr(cons, 1, 2, 3, []);; > > $ camlp4o ./macros.cmo test_macros.ml > let cons x xs = x :: xs > let _ = ((1 + 2) + 3) + 4 > let _ = cons 1 (cons 2 (cons 3 [])) Impressive. If it is possible, It would be best would be to be able to write something like: (def_foldl + plus) and then just (+ x y z) (+ x y z w) ... The same for cons: (def_foldr :: cons) (:: x y z L) (:: x y z t []) Such macros are possible, and I think not very hard in Common Lisp. I will try tonight. As for Camlp4, I don't know. (I don't know camlp4 enough --yet). The point is to define macros that write macro definitions. > What's wrong with the current anti quotation system? Err, actually, nothing... I just found the '$' ugly. But it is one character, and I may as well use it "as is". Loup Vaillant