#null
#t #f
12 -- an integer, the default 040 -- octal 0xFFCCAA -- hex 132L -- a long
123.45 -- a double, the default 1.2345E-2 -- scientific notation for doubles 123.45F -- a float 42D -- a double
#\space -- scheme syntax #\a -- scheme syntax #'a' -- java-like syntax #'\n' -- java-like syntax #'\040' -- octal escapes #'\u4FA3' -- unicode escapes
"ab\n\040\uAAC4" -- a string with various Java escapes '5 -- an integer 'car -- a symbol 'Math.sin -- a symbol '(#t car) -- a list
`( 1 () ,(+ 3 4) apple )
#(1 'red 1.2)
One problem with the quasi-string notation is that you still need to quote the close curly braces and open square brackets that occur within. This is inconvenient when generating program code (e.g. HTML containing javascript or CSS contains many curly braces and square brackets; likewise, generating Java code requires quoting many curly braces and square brackets).
Another difference with strong quasi-strings is that we don't automatically flatten. If you want to flatten the escaped code you must do it yourself. The motivation here is that since we are using a heavier syntax anyway, the extra code for explicitly flattening won't be an undue burden, and will also make the code a little more efficient.
The Strong Quasi-string notation provides a simple solution. The idea is to use #{ and }# instead of { and }, and to escape
from the strong quasi-strings using #[ and ]# instead of [ and ]. For example, we write a program that generates a Java class
> (define (prog version) #{ public class Test { int [] a = new int[] { 1,2,3,4,5}; String version = "#[ version ]#"; public static void main(String[] args) {;} } }# ) (lambda prog (version)...) > (begin (display (prog "abc 6/16/04")) (newline) (newline) 'yes) public class Test { int [] a = new int[] { 1,2,3,4,5}; String version = "abc 6/16/04"; public static void main(String[] args) {;} } yes >
#{ some text #[ (list 'and 'an {excape "here" with reg quasi-strings }) ]# more text }#The idea is that strong quasi-strings are useful when quoting program text, but standard quasi-strings are more convenient for other text....