-
-
Notifications
You must be signed in to change notification settings - Fork 4
quote
A quote is an uninterpreted, unevaluated and possibly unanalyzed and unparsed block of data. In a sense, a block is a first-level quote of code as data.
Strings are extreme forms of quotes, other forms such as makros have at least partial inner semantics. There is a historic reasons why strings are denoted with double-quotes: "example". Literals are strings without quotes. The occur in contexts, where no code is expected (after certain keywords and functions) :
In the examples
import "test.h"
import test.h
import graphics
import github:pannous/angle
The arguments of the keyword import are read self-quoted, meaning that they are parsed literally (letter by letter instead of interpreted) without semantic connections to the programs references and symbols such as variables. Even if graphics is an object declared before the import statement, it is naturally obvious that import graphics
does not refer to it. (todo:wording)
Auto-quoting keywords and functions are those which are followed by quotes without needing special notation upon occurrence.
The import
keyword is an example of an auto-quoting keyword, as seen above.
To turn functions into auto-quoting symbols, there are two mechanisms:
It could be defined via the literal argument type as
import package:literal := download(package) and evaluate result
Depending on the signature of download, the package literal could be auto converted to a string:=
download package:string := curl(package,cache=/tmp)
A more structured definition of import
would be
import package:path
where path has a reduced/specified? literal constructur which expects specific forms such as github:pannous/angle. (protocol':'domain'/'resource)
curl path:string cache:path?:= ... where path=literal of form "/"+…
This contrasts with block as type keyword in function arguments:
if condition:block then:block else:block = …
Here the then-block is not evalutated when the (fictional) if-function is called but handed over as a block which is lazyly only applied if the condition block evaluates to true (inside the call, or outside the call does not matter).
- The := construct acts as a soft-makro, taking any symbol as group
f x := 2x
A quote can be unquoted and applied, whence it may become evaluatable depending on the context.