Hacker Timesnew | past | comments | ask | show | jobs | submitlogin
A Gentle Introduction to Multi-Stage Programming [pdf] (rice.edu)
71 points by _qc3o on Nov 26, 2016 | hide | past | favorite | 7 comments


This is quite old. MetaOCaml has been rewritten since (the new version is linked in another comment)

A better ressource to learn about multi stage metaprog in OCaml is Jeremy Yallop's course on advanced functional programming:

See "staging" sections: https://www.cl.cam.ac.uk/teaching/1415/L28/materials.html

Interactive notebook: http://ocamllabs.github.io/iocamljs/staging.html


I was confused by the fact that you only linked to the first notebook. There are actually several notebooks related to staging in the course outline.

Anyway, thanks!


Anytime I read about multi-stage I'm reminded of this absolutely fascinating project to turn stage 0 code into stage 1 code: https://scala-lms.github.io


Can somebody shed some light on how this is different from delayed/lazy evaluation? I thought languages like Scala and Haskell already support these patterns, but I haven't heard the term 'multi-stage' applied to them...


This is more like hygienic lisp macros, .net expression trees, jvm bytecode generation, etc. You are generating and compiling code instead of just deferring the evaluation to the last minute.


Note that the last release of MetaOCaml was in 2006. This paper is old too, but I don't know exactly how old. But probably about 10 years.


A re-implementation of MetaOCaml was released last year (http://okmij.org/ftp/ML/MetaOCaml.html).




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: