From f490242c00c51bd476c2d6ec075995d30b4e3026 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Mon, 12 Mar 2012 20:48:54 +0000 Subject: [PATCH] fixed up bad markdown :) --- libraries/stdlib/src/kotlin/template/ReadMe.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/stdlib/src/kotlin/template/ReadMe.md b/libraries/stdlib/src/kotlin/template/ReadMe.md index 7e1b7b5e5e9..ea6ca47175d 100644 --- a/libraries/stdlib/src/kotlin/template/ReadMe.md +++ b/libraries/stdlib/src/kotlin/template/ReadMe.md @@ -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