clarity-lang / reference

The Clarity Reference
146 stars 34 forks source link

Distinguish functions from syntactic forms #34

Open njordhov opened 3 years ago

njordhov commented 3 years ago

The documentation and related material conflates Clarity functions with syntactic forms. They should be clearly distinguished to avoid confusion and aid developers in using the language.

For example, the Clarity reference says:

The let function accepts a list of variable name and expression pairs, evaluating each expression and binding it to the corresponding variable name.

However. let is not a function but a syntactic form.

Although functions and syntactic forms share the S-expression syntax, syntactic forms are evaluated in custom ways rather than according to the convention for functions, where each argument is evaluated into a value during function invocation.

Other syntactic forms include the many define-* constructs, which don't call their evaluated arguments like normal functions but rather are evaluated in special ways. Additional examples of syntactic forms are listed on https://github.com/blockstack/docs/issues/495

kantai commented 3 years ago

@njordhov -- should this just be a documentation issue for the docs repo? Or is this an issue in the generated documentation in the stacks-blockchain repo as well?

njordhov commented 3 years ago

should this just be a documentation issue for the docs repo? Or is this an issue in the generated documentation in the stacks-blockchain repo as well?

@kantai The conflation of functions and syntactic forms is primarily an issue with the documentation, although the confusion spreads to tutorials and general discussion of the language. Although the sources for the auto generated documentation obviously is aware of the distinction by encoding for Special forms, there are still inconsistencies: