From 86f50d14c080161f2660fe5caaa2700b6e838645 Mon Sep 17 00:00:00 2001 From: Romain Beauxis Date: Sat, 18 Mar 2017 15:29:06 -0500 Subject: [PATCH] Added CHANGELOG entry and doc. --- CHANGES | 2 ++ doc/content/language.txt | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 03a52d631d..ab57b72114 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,8 @@ x.y.z () New: +- Added support for recursive functions (#406) + - Add peak and peak.stereo operators (#364) - Change `track_sensitive` parameter to a boolean getter (fixed value or anonymous function). diff --git a/doc/content/language.txt b/doc/content/language.txt index 652f5dccbf..cc64d4b17d 100644 --- a/doc/content/language.txt +++ b/doc/content/language.txt @@ -24,11 +24,25 @@ The constants and their syntax are quite common: Strings might be surrounded by double or single quotes. In both cases, you can escape the quote you're using: "He said: \"Hello, you\"." is valid but 'He said: "Hello, you".' is equivalent and nicer. -Also, you can include variables in a string using the #{...} +You can include variables in a string using the #{...} syntax: "foo #{quote(my_var)} bar" is equivalent to "foo " ^ quote(my_var) ^ " bar". +Finally, strings can be interpolated using the following syntax: + +%% +# s = 'This is an $(name) string. \ + This is a $(if $(value),"$(value)","undefined") value.';; +# s % [("name","interpolated")];; +- : string = "This is an interpolated string.This is a undefined value." +# s % [("name","interpolated"),("value","defined")];; +- : string = "This is an interpolated string.This is a defined value." +%% + +Most notably, output.file can use string interpolation to specify a different file name +using the source's metadata. + h4. Expressions You can form expressions by using: @@ -59,6 +73,17 @@ end # The full type of foo is ()->string. %% +Recursive functions can be defined using the rec keywork: +%%(lan_rec_func.liq) +def rec fact(n) = + if n == 1 then + 1 + else + n * fact(n-1) + end +end +%% + **Type of an application.** The type of an application is the return type of function if all mandatory arguments are applied. With the function @foo@ previously defined, @foo()@ is a string. Otherwise, the application is "partial", and the expression still has a function type.