ReadIndex()
(type)Data type handler for the index,
[
, builtin
This is a function you would write when programming a Murex data-type.
It’s called by the index, [
, builtin.
The purpose of this function is to allow builtins to support
sequential reads (where possible) and also create a standard interface
for [
(index), thus allowing it to be data-type
agnostic.
Registering your ReadIndex()
// To avoid data races, this should only happen inside func init()
.ReadIndexes[ /* your type name */ ] = /* your readIndex func */ lang
Example ReadIndex()
function:
package json
import (
"github.com/lmorg/murex/lang"
"github.com/lmorg/murex/utils/json"
)
func index(p *lang.Process, params []string) error {
var jInterface interface{}
, err := p.Stdin.ReadAll()
bif err != nil {
return err
}
= json.Unmarshal(b, &jInterface)
err if err != nil {
return err
}
:= func(iface interface{}) ([]byte, error) {
marshaller return json.Marshal(iface, p.Stdout.IsTTY())
}
return lang.IndexTemplateObject(p, params, &jInterface, marshaller)
}
While there is support for a dedicated ReadNotIndex()
for instances of ![
, the template APIs
lang.IndexTemplateObject
and
lang.IndexTemplateTable
are both agnostic to the bang
prefix.
*lang.Process
: Process’s runtime state. Typically
expressed as the variable p
[]string
: slice of parameters used in
[
[[ Element ]]
): Outputs an element from a nested
structureReadArray()
(type): Read from a data type one array element at a timeReadArrayWithType()
(type): Read from a data type one array element at a time and return
the elements contents and data typeReadNotIndex()
(type): Data type handler for the bang-prefixed index,
![
, builtinWriteArray()
(type): Write a data type, one array element at a timelang.IndexTemplateObject()
(template API): Returns element(s) from a data structurelang.IndexTemplateTable()
(template API): Returns element(s) from a tableThis document was generated from lang/stdio/interface_doc.yaml.
This site's content is rebuilt automatically from murex's source code after each merge to the master
branch. Downloadable murex binaries are also built with the website.
Last built on Wed Jul 2 22:12:32 UTC 2025 against commit bb72b6fbb72b6fdd502f835172d7d06207ba4ec2c70886c.
Current version is 7.0.2107 (develop) which has been verified against tests cases.