Version 12 by komaz
on Nov 22, 2010 19:34.

compared with
Version 13 by komaz
on Nov 25, 2010 18:32.

This line was removed.
This word was removed. This word was added.
This line was added.

Changes (6)

View Page History
Everything between the <| and |> tokens is considered source code of the DSL itself. The anchor type defines how to the compile the DSL. DslPlugins are registered on the anchor type, and called by the Fantom compiler to translate them into a Fantom expression.
Technically speaking, DSLs are presented as DSL expressions, and it's result type is defined by the anchor type, so that
For built-in DSLs, the expression type matches to the anchor type, so that
str := Str<|hello, world!|> // str has type Str
foo := Foo<|bar|> // foo has type Foo
regex := Regex<|\d+|> // regex has type Regex
However, it is not necessary - basically the DSL expression can be compiled to expression of any type - I don't know whether this is a bug or feature :)

Therefore, the most obvious way to use DSL expressions is instantiation of some complex objects. For example, imagine we are writing a library for graph manipulation, so we define classes like {{Graph}}, {{Node}}, and {{Edge}}. See [^]
And imagine that we need to instantiate some graphs for our tests, so we write the code like this: