Functional programming languages introspection?

Haskell's introspection mechanism is Template Haskell which supports compile time metaprogramming, and when combined with e. G llvm provides runtime metaprogramming facilities.

Haskell's introspection mechanism is Template Haskell, which supports compile time metaprogramming, and when combined with e.g. Llvm, provides runtime metaprogramming facilities.

Ocaml has: Camlp4 to manipulate Ocaml concrete syntax trees in Ocaml. The maintained implementation of Camlp4 is Camlp5. MetaOCaml for full-scale multi-stage programming.

Ocamljit to generate native code at run time, but I don't think it's been maintained recently. Ocaml-Java to compile Ocaml code for the Java virtual machine. I don't know if there are nice reflection capabilities.

Camlp4 Wiki: groups.google. Com/group/fa. Caml/browse_thread/thread/… – nlucaroni Sep 8 '10 at 15:28.

Not really an answer, but note also the F# Quotations feature and library, for more homoiconicity stuff.

You might check out the typed variant of Racket (previously known as PLT Scheme). It retains most of the syntactic simplicity of Scheme, but provides a static type system. Since Racket is a Scheme, metaprogramming is par for the course, and the runtime can emit native code by way of a JIT.

I'd also look at Scala or Clojure which come with them all the libraries that have been developed for Java. You'll never need to worry if a library does not exist. But more to the point of your question, these languages give you the same reflection (or more powerful types) that you will find within Java.

The Haskell approach would be more along the lines of parsing the source. The Haskell Platform includes a complete source parser, or you can use the GHC API to get access that way.

I'm sketching a design of something (machine learning of functions) that will preferably want a functional programming language, and also introspection, specifically the ability to examine the program's own code in some nicely tractable format, and preferably also the ability to get machine generated code compiled at runtime, and I'm wondering what's the best language to write it in. Lisp of course has strong introspection capabilities, but the statically typed languages also have advantages; the ones I'm considering are: Can you not just parse the source code like an ordinary interpreter or compiler? Why do you need introspection?

F# - the . Net platform has a good story here, you can read byte code at run time and also emit byte code and get it compiled; I assume there's no problem accessing these facilities from F#. F# has a rudimentary quotation mechanism but you can only quote some expressions and not other kinds of code, most notably type definitions.

Also, its evaluation mechanism is orders of magnitude slower than genuine compilation so it is basically completely useless. You can use reflection to analyze type definitions but, again, it is quite rudimentary. You can read byte code but that has been compiled so a lot of information and structure has been lost.

F# also has lexing and parsing technology (most notably fslex, fsyacc and FParsec) but it is not as mature as OCaml's. Haskell, Ocaml - do these have similar facilities, either via byte code or parse tree? Haskell has Template Haskell but I've never heard of anyone using it (abandonware?).

OCaml has its Camlp4 macro system and a few people do use it but it is poorly documented. As for lexing and parsing, Haskell has a few libraries (most notably Parsec) and OCaml has many libraries. Are there other languages I should also be looking at?

Term rewrite languages like Mathematica would be an obvious choice because they make it trivial to manipulate code. The Pure language might be of interest. You might also consider MetaOCaml for its run-time compilation capabilities.

Well yes, I had been hoping to avoid the need to write my own parser and runtime, but it turned out to be necessary so I'm going ahead and doing it. Thanks for the list anyway, though, upvoted. – rwallace Jun 26 at 5:29.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions