Quote - Quote a Point
qpoint = Quote ( point ) | |
qpoint = Unquote ( point ) |
qpoint | A quoted (or unquoted) point | |
point | The point to be quoted |
The Quote module evaluates its first argument and returns the quoted result. The UnQuote module evaluates its first argument; if the result is quoted it strips off the [first] quote and returns the result.
When you specify a point, Int:123 for example, V4 knows that you mean an integer of 123. If you specify an intersection such as [foo], do you mean the point representing that intersection or do you mean the point representing the evaluation of the intersection? In most cases, V4 interprets an intersection as meaning the point resulting in the evaluation. V4 treats context references (ex: customer*) and module references (ex: Plus(1 2)) in the same fashion - they are evaluated. But sometimes you do not want V4 to evaluate. This can be done by quoting (taken from LISP) the point reference. In V4, quoting is done by prefacing the point with the at sign (@). The evaluation of a quoted point simply strips off the quote leaving the remainder unchanged and unevaluated.
V4 evaluates the arguments to a module before actually invoking the module. In the case of a module like Enum, this can become confusing. Compare 'Enum(Int:1..10 Echo(Int*))' to 'Enum(Int:1..10 @Echo(Int*))'. The first case will evaluate the Echo before calling the module. This most likely will result in an error if there is no Dim:Int point in the context. In the second case, the evaluation of '@Echo(Int*)' results in 'Echo(Int*)' and the module enumerates as expected.
Tagged arguments within a module are handled a little differently. The evaluation of a tagged argument results in itself. That is, the evaluation of tag::point results in tag::point just as the evaluation of Int:1 results in Int:1. The evaluation of the point occurs when the tag is used within the module. For example 'Enum([cusList] If::[test] Num::[maxToShow] @Do([whatever]))', the [cusList] is evaluated to a list before the module is invoked. The tagged arguments are left unchanged. The evaluations of [test] and [maxToShow] occur as the module executes. Therefore the [test] intersection is evaluated for each point in [cusList] while [maxToShow] is only evaluated once.
There are a few V4 modules that do not pre-evaluate all of their arguments. DefQ is the most often used of these exceptions. It does not pre-evaluate its first argument. The evaluation of the first argument occurs within the module so it can handle it properly. Assume [undefined] is not a defined intersection, then DefQ([undefined]) returns false while Def([undefined]) fails because the (pre)evaluation of the first argument fails. V4 modules ending with a Q or QE auto-quote one or more of their arguments.
Internally, V4 handles quoted points via a shell dimension- Dim:UQuote. For example, '@[foo]' is really a point on the UQuote dimension- UQuote:[foo]. The V4 interpreter recognizes points on this dimension and evaluates/displays them appropriately.