From 44d6247b46beb8696d8fb57885c3b628321ca781 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Mon, 14 Jan 2019 18:28:23 -0600 Subject: [PATCH] DOCS: Modify the docs to reflect macros as closures. --- docsite/site/content/_index.md | 10 ++++++---- docsite/site/content/reference/_index.md | 2 +- docsite/site/content/reference/expressions.md | 16 +++++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docsite/site/content/_index.md b/docsite/site/content/_index.md index c5fb7ce..f2fe24a 100644 --- a/docsite/site/content/_index.md +++ b/docsite/site/content/_index.md @@ -2,10 +2,12 @@ title = "Introduction to UCG" in_seach_index = true +++ -[UCG](https://crates.io/crates/ucg) is a universal grammar for configuration. It's goal is not to define a configuration format -like JSON, YAML, or TOML. It is not intended to replace the other configuration formats. Instead -it is intended to provide a common grammar for generating those formats. Currently UCG is able to -generate conversions for the following formats. + +[UCG](https://crates.io/crates/ucg) is a universal grammar for configuration. +It's goal is not to define a configuration format like JSON, YAML, or TOML. It +is not intended to replace the other configuration formats. Instead it is +intended to provide a common grammar for generating those formats. Currently +UCG is able to generate conversions for the following formats. * Environment Variables * Command Line Flags diff --git a/docsite/site/content/reference/_index.md b/docsite/site/content/reference/_index.md index af9ec9f..9730842 100644 --- a/docsite/site/content/reference/_index.md +++ b/docsite/site/content/reference/_index.md @@ -9,7 +9,7 @@ An Overview ----------- UCG is a language specialized for generating configurations. It does not have classes, -inheritance, closures, or a full type system. All values are immutable once bound to +inheritance, or a full type system. All values are immutable once bound to a name. A valid UCG file is composed of a series of statements. Statements can be an expression, introduce named bindings, or create different outputs. All statements must be terminiated by a semicolon. diff --git a/docsite/site/content/reference/expressions.md b/docsite/site/content/reference/expressions.md index 271afae..2239f57 100644 --- a/docsite/site/content/reference/expressions.md +++ b/docsite/site/content/reference/expressions.md @@ -407,25 +407,27 @@ Macros ----- Macros look like functions but they are resolved at compile time and -configurations don't execute so they never appear in output. Macros do not -close over their environment so they can only reference values defined in their -arguments. They can't refer to bindings or other macros defined elsewhere. They -are useful for constructing tuples of a certain shape or otherwise promoting -data reuse. You define a macro with the `macro` keyword followed by the -arguments in parentheses, a `=>`, and then a tuple literal. +configurations don't execute so they never appear in output. Macros close over +their environment in the file they are declared in. They are useful for +constructing tuples of a certain shape or otherwise promoting data reuse. You +define a macro with the `macro` keyword followed by the arguments in +parentheses, a `=>`, and then a tuple literal. ``` let mymacro = macro (arg1, arg2) => { host = arg1, port = arg2, connstr = "couchdb://@:@" % (arg1, arg2), -} +}; let my_dbconf = mymacro("couchdb.example.org", "9090"); let my_dbhost = dbconf.host; ``` +Note that while macros can close over their environment they can not reference +other fields in the macro body itself. + Modules -------