From 05d9bef9e90d0be0ed7d330e7cfaa376df78f739 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 22 Mar 2019 07:19:24 -0700 Subject: doc: clarifications under lambda. * txr.1: Make it clearer that the default expression of an optional parameter is only evaluated when required. Document that t, nil and keyword symbols can't be used as parameters, and that duplicates symbols are unspecified, the situation being diagnosed by the compiler but ignored by the interpreter. --- txr.1 | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/txr.1 b/txr.1 index e758a790..e6784b09 100644 --- a/txr.1 +++ b/txr.1 @@ -13675,6 +13675,8 @@ In this situation, if the call does not specify a value for the parameter (colon)) then the parameter takes on the value of the expression .metn expr . +This expression is only evaluated when its value is required. + If .meta sym is specified, then @@ -13683,7 +13685,9 @@ will be introduced as an additional binding with a Boolean value which indicates whether or not the optional parameter had been specified by the caller. -The initializer expressions are evaluated an environment in which +Each +.code expr +that is evaluated is evaluated an environment in which all of the previous parameters are visible, in addition to the surrounding environment of the lambda. For instance: @@ -13707,6 +13711,22 @@ by the surrounding let. This reference is captured as part of the .codn lambda 's lexical closure. +Keyword symbols, and the symbols +.code t +and +.code nil +may not be used as parameter names. +The behavior is unspecified if the same symbol is specified +more than once anywhere in the parameter list, whether as a parameter name or as +the indicator +.code sym +in an optional parameter or any combination. + +Implementation note: the \*(TX compiler diagnoses and rejects duplicate +symbols in +.code lambda +whereas the interpreter ignores the situation. + .TP* Examples: .IP "Counting function:" This function, which takes no arguments, captures the -- cgit v1.2.3