fixed up bad markdown :)

This commit is contained in:
James Strachan
2012-03-12 20:48:54 +00:00
parent f927b38a14
commit f490242c00
@@ -1,15 +1,15 @@
== Warning experimental APIs
## Warning experimental APIs
This package contains a couple of alternative experimental implementations of string templates.
These are not yet integrated into the language, but are here to compare implementation details,
suitability, code size, complexity and efficiency.
=== Aims
### Aims
* make it easy to generate various kinds of output such as text, text with internationalisation, HTML/XML, JSON, URL/URLs or make JDBC calls while reusing the same language templates with $ expressions
=== Issues
### Issues
* how many objects are created per call?
* how extensible & easy to reuse the concept of String Templates in other library features
@@ -17,7 +17,7 @@ suitability, code size, complexity and efficiency.
* avoid where possible lots of "if (value is SomeType)" runtime checks to determine what encoding strategy should be used
==== experiment1
#### experiment1
Here we convert a string template into a function on some kind of builder object where we invoke the text() method for static text and expression() for dynamic expressions
@@ -33,7 +33,7 @@ Pro:
* we can only use this strategy if the template expression is passed to a function and we can detect the function parameter takes a fn: (T) -> Unit; and T has suitable text() and expression() methods.
(We can use extension methods to allow regular builder-like classes such as java.lang.StringBuilder to be used to minimise redundant object creation) - so the code generation is a bit more complex
==== experiment2
#### experiment2
Here we create a single StringTemplate object containing the constant text array and the values array. Then we use functions or extension functions as ways to do other things.
@@ -47,7 +47,7 @@ Cons:
* requires runtime instanceof checks on each expression value
* fair bit of object construction per call (2 arrays, a template object, then the string builder and lots of index lookup of arrays
==== experiment 3
#### experiment 3
The idea is we create a FooTemplate object with the static constant strings inside; so we can easily cache the immutable stuff on startup. Then we basically use pseudo code like