Server parsing source code
== Description ==
These functions parses file according to the HOP syntax.
== Synopsis ==
(hop-read [input-port] [:charset])
(hop-load path [:charset] [:env] [:mode] [:hook])
(hop-load-once path [:charset] [:env] [:hook])
(hop-load-modified path [:charset] [:env] [:hook])
(hop-load-once-unmark! path)
(the-loading-file)
(the-loading-dir)
== Examples ==
hop-read, hop-load, the-loading-file, the-loading-dir
== Server Definitions ==
=== ++(hop-read [port] [charset (hop-locale) [hook]]++ ===
hop-read
^ arguments ^ type ^ short description ^
| port | input-port | the input port. |
| charset | symbol | the port charset. |
The function ++hop-read++ reads an entire expression from an input port.
When a text is read (the ++[...]++ expressions as described in the
( :class "href wikiref"
:onclick ~(with-history
(lambda ()
(notepad-select "doc-notepad" "doc-core")
(window.scrollTo 0 0)))
"Syntax") section)
are //automatically// encoded into the ++charset++ value. That is,
they are assumed to be expressed in the ++(hop-locale)++ encoding and the
reader decodes and re-encodes them using the encoding specified in the
optional ++charset++ argument.
=== ++(hop-load path [:env] [:mode load] [charset (hop-locale)])++ ===
hop-load
^ arguments ^ type ^ short description ^
| path | string | the file name to be loaded. |
| charset | symbol | the port charset. |
| env | module | the eval environment. |
| mode | symbol | the load mode. |
| hook | symbol | a optional procedure of one argument. |
This function loads the file ++path++. That is, it reads and evaluates
all the expressions. The expressions are evaluated in the environment
++env++. By default the current module's environment is used.
The parameter ++mode++ specifies the loading mode. The --load--
mode evaluates all the loaded expressions and forces ++hop-load++ to
only return the value produced by evaluated the last expression.
The --include-- load mode returns a list of all evaluations.
The parameter ++hook++, when provided, must a procedure of one argument.
It is invoked by ++hop-load++ with the last loaded expression. It is
evaluated in the environment (i.e., the module) defined by the loaded file.
The function ++hop-load++ is thread safe. No more than one thread
can simultaneously reads a single file.
=== ++(hop-load-once path [:env] [charset (hop-locale)])++ ===
hop-load-once
^ arguments ^ type ^ short description ^
| path | string | the file name to be loaded. |
| charset | symbol | the port charset. |
| env | module | the eval environment. |
| hook | symbol | a optional procedure of one argument. |
As ++hop-load++ it loads a file in the ++env++ environment. By contrast
with ++hop-load++ it does not return any value. Hence, ++hop-load-once++
can only be used for its effects.
Invoking ++hop-load-once++ with a parameter ++path++ loads the file in
memory //if not already loaded//. That is, if the file ++path++ is loaded
//if and only if// it has not already been loaded with ++hop-load-once++.
This function is thread safe.
=== ++(hop-load-modified path [:env])++ ===
hop-load-modified
^ arguments ^ type ^ short description ^
| path | string | the file name to be loaded. |
| charset | symbol | the port charset. |
| env | module | the eval environment. |
| hook | symbol | a optional procedure of one argument. |
As ++hop-load-once++ but in addition, the file is reloaded if the file
has changed on the disc since it has been loaded.
=== ++(hop-load-once-unmark! path)++ ===
hop-load-once-unmark!
Unmarks ++path++. The next evaluation of ++(hop-load-once path)++
reloads the file ++path++.
=== ++(the-loading-file)++ ===
the-loading-file
This function returns the name of the file currently being loaded.
=== ++(the-loading-dir)++ ===
the-loading-dir
This function returns the dirname of the file currently being loaded.