Resources for Learning CamlP4

For an accessible introduction to modern (>= 3.10) Camlp4, you may be interested in Jake Donham’s blog post series “Reading Camlp4” : http://ambassadortothecomputers.blogspot.com/search/label/camlp4
You will also find valuable (though incomplete) information on the camlp4 wiki : http://brion.inria.fr/gallium/index.php/Camlp4
The older version of camlp4 (< 3.10, now called camlp5) also provides a documentation http://caml.inria.fr/pub/docs/tutorial-camlp4/index.html , and you can also use to Martin Jambon’s tutorial
http://martin.jambon.free.fr/extend-ocaml-syntax.html (for the older camlp4).

— bluestorm

You can also see the articles in sequence at
http://ambassadortothecomputers.blogspot.com/p/reading-camlp4.html

which I recommend since later articles depend on earlier material.

— Jake Donham

Shameless self-plug, but I wrote a blog post this summer about my experience figuring out how to do it. I provide a walk-through and explanation of a minimal syntax extension which adds lazy list pattern matching support based on Batteries. The URL:
http://www.elehack.net/michael/blog/2010/06/ocaml-syntax-extension
I do assume a basic knowledge of parsing context-free grammars, but a generic tutorial on parsing with a tool such as Yacc can fill in that gap. The Wikipedia article[1] may also be helpful.
Once you’ve lept the hurdle of figuring out what pieces you need to write and build a syntax extension, the remaining tricky part is to figure out what pieces of the grammar you need to extend to accomplish your objective. For that, I consult the definition of the OCaml parser in Camlp4OCamlParser.ml in the OCaml source tree.
1. http://en.wikipedia.org/wiki/Context-free_grammar

— Michael Ekstrand

If you consider yourself as a n00b, don’t start by camlp4. This is probably the most difficult part of OCaml — and to program camlp4 you need to use OCaml standard syntax (or revised syntax, it depends if you
use antiquotations).
If you still want to follow the hard path, as suggested elsewhere, Jake Donham’s blog posts are very good:
http://ambassadortothecomputers.blogspot.com/p/reading-camlp4.html
Or if you are around, there is a tutorial session at CUFP:
http://cufp.org/conference/sessions/2010/camlp4-and-template-haskell.
(but you need to subscribe).

— Sylvain Le Gall
(via Caml-list)

Do you really want to rev it like that?

FYI, but engine stresses go up as the square of RPM.
IOW, double the revs, and you quadruple the stresses on the engine parts. Triple the revs, and you increase stress by a factor of 9x.
If there’s no compelling reason to have the engine spinning at high revs (ie, I want the power), I don’t.
Above is theoretical.

(via Doug G on COG)

When your Concours won't let you bumpstart it

As to not getting the bike in any gear but first, that is Kawasaki’s patented neutral finder. The bike must be moving five mph or faster to select second gear. You can defeat this by putting it on the centerstand and spinning the rear wheel by hand as fast as possible. You will then need to hold the clutch disengaged while taking the bike off the stand.

(via on Claudio O COG)

A Proposal Against Parentheses in Racket

P4P:

This document proposes an alternate syntax for Racket. It reduces the parenthetical burden, makes the language appear more traditional, and respects indentation, though not in the way you think. It does all this while retaining the essence of Racket syntax, and even offering a high degree of tool reuse.

(via Racket-users)

Calling Java Under Cygwin

While trying to set up Clojure under Cygwin I found that doing mixed-mode between Cygwin and Java isn’t very happy due to the ‘;’ vs ‘:’ in the classpath.
This post (via this post) provided an obfuscated Ruby program to take care of that for you… thanks!

#!/bin/ruby
# Slightly obfuscated cygwin + windows java wrapper, automate cygpath
cpi = ARGV.index("-cp") + 1
cp = ARGV[cpi] if cpi
XBCP = "-Xbootclasspath/a:"
xbcpi = ARGV.index{|i|i=~/^#{XBCP}.*/}
xbcp = ARGV[xbcpi] if xbcpi
if cp or xbcpi
  def convert_paths(paths)
    paths = paths.gsub(':', ';').split(';')
    paths.map{|p|`cygpath -aw #{p}`.strip}.join ';'
  end
  ARGV[cpi] = convert_paths(cp) if cp
  ARGV[xbcpi] = XBCP + convert_paths(xbcp.sub(XBCP, '')) if xbcp
end
java = '/cygdrive/c/Program Files/Java/jdk1.6.0_18/bin/java'
cmd = .concat ARGV
def e(s); "\"#{s.strip.gsub('"','\"')}\""; end
exec(cmd.map{|a|e a}.join(' '))