News for hackers. Stuff that matters.
Re:Project for bringing macros to Scala by dxbydt on Wednesday November 09, 2011 @11:46AM (#3216202)
> Scala macros might be a solution to a problem nobody has

Pls read slide 10 of this document - http://scalamacros.org/talks/2011-10-18-WhatsUp.pdf

--Proposed Code snippet with macro ---

class Queryable[T, Repr](query: Query) { macro def filter(p: T => Boolean): Repr = <[ val b = $this.newBuilder b.query = Filter($this.query, $reify(p)) b.result ]> } val products = db.products products.filter(p => p.startsWith("foo")).toList --

My takeaways : 1. adding LINQ support to Scala via macros 2. macros virtualize XXX, where XXX = vals, vars, defs, types, classes, traits. So macro XXX can be used in place of XXX.

The author also says "We can tailor macros to fit your particular use case". He mentions OR-mapping, and a Scala-to-javascript compiler that might end up using these macro invocations, among other things.

There are no comments on this comment yet.