views:

1279

answers:

11

After reading Practical Common Lisp I finally understood what the big deal about macros was, and I have been looking for a language for the .NET platform that supports this. There are a few lisp dialects for .NET but from what I have been able to gather all are either very beta or abandoned. Recently my interest has been sparked by Clojure, but it's for the java platform and while on probably could use ikvm it doesn't feel some integrated. Especially when you want to do stuff like WPF.

Recently I have been hearing whisper about F#, I tried to look at the documentation if I could find anything about macro support, but haven't found it. So does anyone know?

Thanks :)

+4  A: 

Nope. No macros for F#.

James Deville
+5  A: 

Well, F# is based on OCaml and OCaml has a rather extensive macro system. Given the syntactic and semantic similarities of F# and OCaml you may be able to port over the Ocaml macro system to F#.

Other than stealing Ocaml's macro system I'm unaware of a canned macro system for F#.

Jason Dagit
Porting camlp4 is not a trivial task. But it is not required as long as you are staying in ocaml-compatible subset of F#. Though the whole process will require some manual setup and lead to certain constraints.
ygrek
+1  A: 

Thanks, but good horrors the syntax in those ocaml examples looks obscure :)

Anders Rune Jensen
+4  A: 

but good horrors the syntax in those ocaml examples looks obscure

There you're running into the same fundamental syntactic trade-off you do with Lisp. If you want the power of lisp-like macros, you tend to either end up with lisp-like syntax for the language, or else your macro syntax looks quite different from your regular syntax... nothing wrong with either approach, just different choices

simon
Not really. OCaml's macros are complicated by the need to differentiate between different kinds of syntactic constructs (e.g. type definitions vs expressions) because they are represented by values of different static types. Mathematica has rich syntax and powerful macros at the same time, for example.
Jon Harrop
+6  A: 

Nemerle, at http://nemerle.org/ , is a .NET language (also supporting mono) that supports a lot of of the functional programming paradigm while staying visually close to C#. It has extensive macro support.

ben
+4  A: 

Have you looked at Boo? While Boo doesn't have macros, it has an open compiler pipeline, which is a good alternative to macros for syntactic metaprogramming.

[EDIT] As noted in the comments, Boo does have macros now.

Jörg W Mittag
Boo currently does have macros (this may not have been the case when you posted).
JasonTrue
Might be. More likely, it *did* have macros when I posted that, but didn't when I last checked (which was long before that post.) Doesn't matter anyway, since you can do everything you can do with macros with an open compiler and vice versa.
Jörg W Mittag
+1  A: 

That may be the other way around than what you want, but do you know about RDNZL? It's a foerign-function interface (FFI) that lets you call .NET libraries from your Lisp code.

They are most probably much less mature than any Common Lisp or Scheme implementation, but there are Lisp dialects for .NET: L# and DotLisp.

Nowhere man
Just FYI Dotlist isn't being maintained anymore (Rich is the guy behind Clojure) so I don't think I'd mess with it. Mind if you want a lisp-like that isn't CL/Scheme I'd use Clojure, personally.
Runevault
DotLisp is admittedly a little stunted, but that's because it's stable, working, and I'm too busy to upload my patches :-(
Mark Hurd
+1  A: 

There are two actively developed Lisps for .net

IronScheme - DLR based scheme implementation

Xronos - DLR based port of clojure

Stefan Rusek
+1  A: 

How about using F# quotations?

http://tomasp.net/blog/fsquotations.aspx

Tuomas Hietanen
Quotations just let you quote code to get a runtime representation of it, and F# quotations often don't even let you do that (e.g. F# refuses to quote `<@ a @>`). Macros let you do more, e.g. change the syntax of the language. There is no way to do that in F#. F# doesn't have a complete CodeDOM either so you cannot use the F# compiler programmatically. Indeed, you could say that F# is specifically designed to prevent this kind of programming.
Jon Harrop
+1  A: 

Recently I have been hearing whisper about F#, I tried to look at the documentation if I could find anything about macro support, but haven't found it. So does anyone know?

F# does not support macros and it is unlikely that it ever will.

Jon Harrop