ell

package module
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 25 Imported by: 2

README

ell

ℒ (ell) is a LISP dialect, with semantics similar to Scheme, but adds Keywords, Structs, user-defined Types, and other features.

Getting started

The reference version of Ell is written in Go. If you have Go installed on your machine, you can install Ell easily:

go get github.com/boynton/ell/...

This installs the self-contained binary into $GOPATH/bin/ell. Ell loads its library files from locations defined by the ELL_PATH environment variable. If that variable is not defined, the default path is ".:$HOME/lib/ell:$GOPATH/src/github.com/boynton/ell/lib".

If you have a .ell file in your home directory, it will get loaded and executed when running ell interactively.

$ ell
[loading /Users/lee/.ell]
ell v0.2
?

The ? prompt is the Read-Eval-Print-Loop (REPL) for ell, waiting for your input. Entering CTRL-D will end the REPL and exit back to the shell.

Primitive types

Ell defines a variety of native data types, all of which have an external textual representation. This data notation is called EllDN, and is a superset of JSON.

? 5.2
= 5.2
? "five"
= "five"
? true
= true
? null
= null
? [1, 2, 3]
= [1 2 3]
? {"x": 1, "y": 2}
= {"x" 1 "y" 2}

The basic JSON types are supported as you would expect. Although JSON-compatible format is accepted for vectors (JSON arrays) and structs (JSON objects), the canonical form for both does not include separating commas.

EllDN also introduces keywords, types, symbols, and lists to the syntax.

Keywords are symbolic identifiers that end in a colon (':'), and types are symbolic identifiers surrounded by angle brackets ('<' and '>'). Both are self-evaluating, but used for different purposes:

? foo:
= foo:
? <string>
= <string>

Symbols are identifiers that form variable references in Ell, so are interpreted differently. Lists are ordered sequences, and form the syntax for function (or macro) calls in Ell:

? length				; a reference to the `length` variable
= #[function length]
? (length "foo")        ; a function call to the length function
= 3

Most types evaluate to themselves. Since symbols and lists do not evaluate to themselves, they must be quoted to be taken literally:

? x
 *** [error: Undefined symbol: x]
? 'x
= x
? (f 23)
 *** [error: Undefined symbol: f]
? '(f 23)
= (f 23)

The vector and struct elements are also evaluated, so you sometimes need to quote them, too (as that is more convenient than quoting every interior item):

? [1 two 3]
 *** [error: Undefined symbol: two] 
? [1 'two 3]      ; you can quote just what needs to be quoted
= [1 two 3]
? '[1 two 3]      ; or just quote the whole thing
= [1 two 3]
? {x 2}
 *** [error: Undefined symbol: x]
? '{x 2}
= {x 2}
? {"x" two}
 *** [error: Undefined symbol: two]
? '{"x" two}
= {"x" two}

The complete list of primitive types in Ell is:

  • <null>
  • <boolean>
  • <character>
  • <number>
  • <string>
  • <blob>
  • <symbol>
  • <keyword>
  • <type>
  • <list>
  • <vector>
  • <struct>
  • <function>
  • <code>
  • <error>
  • <channel>

You can define additional types in terms of other types, this is discussed later.

Core expressions

  • _symbol_ - variable reference
  • (quote _expr_) - literal data
  • (do _expr_ ...) - expression sequencing
  • (if _predicate_ _consequent_ _antecedent_) - conditional
  • (_function_ _expr_ ...) - function call
  • (fn (_arg_ ...) _expr_ ...) - function creation
  • (set! _name_ _expr_) - sets the lexically apparent variable to the value
  • (def _name_ _expr_) - define value. At the top level, sets the global variable. Inside a function, creates a new frame with the binding.
  • (defmacro _name_ (_arg_) _expr_ ...) - define a new macro
Variables and literals

As mentioned before, most data items evaluate to themselves. But symbols and lists do not. When a symbol is interpreted, the closest lexical binding of that variable is looked up, starting from the innermost frame, and ending with the global environment.

? +
= #[function +]  		; the global binding for + is the addition function
? (defn f (x) (+ x 1))	; the x here is defined only inside the function
= #[function f]

The quote primitive is used to prevent the normal evaluation if its argument. It is the long form of the single quote reader macro, which actually just produces a quote form:

? (quote foo)
= foo
? 'foo ; a shorthand for the same thing
= foo
? (def x 23)
= 23
? x
= 23
? 'x
= x
Conditionals and sequencing

The primitive for conditionals is if, which takes a predicate, and if the predicate is true evaluates the consequent. An optional antecedent clause will be executed of the predicate is false.

? (if true 'yes)
= yes
? (if false 'yes)
= null
? (if false 'yes 'no)
= no

Sometimes more than one expression is needed in the place of one, largely for side-effects. This is what the do special form is for:

? (do (println "hello") 'blah)
hello
= blah
? (if true (do (println "it was true!") 1) (do (println "it wasn't true!") 0))
it was true!
= 1
Functions and lexical environments

A list is interpreted as a function call. For example, the following applies the + function to the arguments 2 and 3:

? (+ 2 3)
= 5

Ell provides a variety of primitive functions (like +). New functions are defined by the fn special form:

? (fn (x) (+ 1 x))
= #[function]

This creates an anonymous function that takes a single argument x and returns the sum of that and 1. This actually creates a closure over a new frame in the environment containing the variable x, and executes the body of the function in that lexical environment. The function returned is a first class object that itself can be passed around. All other binding forms can be defined in terms of this primitive, for example, consider the following:

(let ((x 23)) (+ 1 x))

The let special form is actually just a macro that generates the equivalent primitive form:

? (macroexpand '(let ((x 23)) (+ 1 x)))
= ((fn (x) (+ 1 x)) 23)

A function lives on with indefinite extent, closed over any variables in its lexical environment. For example:

? (def f (let ((counter 0)) (fn () (set! counter (inc counter)) counter)))
= #[function f]
? (f)
= 1
? (f)
= 2

In the above example, the primitive expression set! is also shown. It sets the value for the variable determined by its first argument (a symbol).

Normally, functions are defined at the top level, i.e. in the global environment, using the defn special form (which itself is just a macro):

? (defn f (x) (+ 1 x))
= #[function f]
? (f 23)
= 24

If def and defn are used inside a function, they create a new binding inside the function, rather than side-effect the global values for the symbols.

The defmacro primitive form allows the definition of new special forms (i.e. syntactic constructs used by the compiler).

? (defmacro blah (lst x) `(cons ~x ~lst))
= blah
? (blah '(1 2) 23)
= (23 1 2)
? (macroexpand '(blah '(1 2) 23))
= (cons 23 '(1 2))

This example shows the quasiquote macro, which simulates a simple quote, but allows escaped values to be inserted. In general ~x means "insert the current value of x here", and ~@x means "splice the list represented by x into the expression here".

Function argument binding forms

In addition to traditional lambda definitions, with explicit arguments and/or "rest" arguments, optional named arguments with defaults, and keyword arguments, are also supported:

? (defn f (x y) (list x y))
= #[function f]
? (f 1 2)
= (1 2)
? (defn f (x & rest) (list x rest))
= #[function f]
? (f 1 2)
= (1 (2))
? (f 1 2 3)
= (1 (2 3))
? (defn f args args)
= #[function f]
? (f 1 2 3)
= (1 2 3)
? (defn f (x [y]) (list x y))
= #[function f]
? (f 1 2)
= (1 2)
? (f 1)
= (1 null)
? (defn f (x [(y 23)]) (list x y))
= #[function f]
? (f 1)
= (1 23)
? (f 1 2)
= (1 2)
? (defn f (x {y: 23 z: 57}) (list x y z))
= #[function f]
? (f 1)
= (1 23 57)
? (f 1 2)                                                                                               
 *** Bad keyword arguments: [2] 
? (f 1 y: 2)
= (1 2 57)
? (f 1 z: 2)
= (1 23 2)
? (f 1 z: 2 y: 3)
= (1 3 2)

Defining new types

The type function returns the type of its argument:

? (type 5)
= <number>
? (type "foo")
= <string>
? (type <string>)
= <type>

Types are referred to symbolically, and also evaluate to themselves. They do not have to be defined to be referred to, as they are essentially just tags on data. A special syntax allows them to be read/written:

? <foo>
= <foo>	
? (type <foo>)
= <type>
? (type #<foo>"blah")
= <foo>
? (value #<foo>"blah")
= "blah"

New types can be introduced by attaching to other data objects. For example:

? (def x (instance <foo> "blah"))
= #<foo>"blah"
? (type x)
= <foo>
? (value x)
= "blah"

Some convenience macros for defining new types are provided:

? (deftype foo (o) (and (string? o) (< (length o) 5)))
= <foo>
? (foo "blah")
= #<foo>"blah"
? (foo "no way")                  
 *** [syntax-error: not a valid <foo>:  "no way"] [in foo]
? (foo? (foo "blah"))
= true
? (foo? "blah")
= false

It is defined in terms of a validation predicate. Once defined, the type is independent, and has no relation to any other type; there is no inheritance of types.

Defining a type that is a struct with certain fields is common enough that a dedicated macro is defined to make it simpler:

? (defstruct point x: <number> y: <number>)
= <point>
? (point)
 *** [validation-error: type <point> missing field x: {}] [in point] 
? (point x: 1 y: 2)
= #<point>{x: 1 y: 2}
? (def data {x: 1 y: 2})
= {x: 1 y: 2}
? (struct? data)
= true
? (point? data)
= false
? (def pt (point data))
= #<point>{x: 1 y: 2}
? (struct? pt)
= false
? (point? pt)
= true
? (value pt)
= {x: 1 y: 2}
? (type (value pt))
= <struct>
? (equal? data (value pt))
= true
? (identical? data (value pt)) ; not identical means a copy was made.
= false
? (point-fields)
= {x: <number> y: <number>}

To access fields of a struct, including any defined as above, the get function can be used, but since all fields have keywords as names, using a keyword as a function is more idiomatic:

? (x: pt)
= 1
? (y: pt)
= 2

Although to change the values, put! must be used on the value of the instance. Any such mutable operation is not encouraged, but sometimes necessary:

? (put! data x: 23)
= null
? data
= {x: 23 y: 2}
? (put! pt x: 23)
 *** [argument-error: put! expected a <struct> for argument 1, got a <point>] 
? (put! (value pt) x: 57)       
= null
? pt
= #<point>{x: 57 y: 2}

Defining methods on types

Ell provides generic method dispatch, supporting multimethods. This means any number of arguments to a function may be specialized, and dispatch can be based on all of them.

For example:

? (defgeneric add (x y))
= #[function add]
? (defmethod add ((x <string>) y) (string x "|other|" y))
= add
? (defmethod add ((x <number>) (y <number>)) (+ x y))
= add
? (defmethod add ((x <string>) (y <string>)) (string x "|string|" y))
= add
? (defmethod add ((x <list>) (y <list>)) (concat x y))
= add
? (defmethod add ((x <vector>) (y <vector>)) (apply vector (concat (to-list x) (to-list y))))
= add
? (add 1 2)
= 3
? (add "foo" "bar")
= "foo|string|bar"
? (add "foo" 'bar)
= "foo|other|bar"
? (add '(1 2) '(3 4))
= (1 2 3 4)
? (add [1 2] [3 4])
= [1 2 3 4]

Other features

Continuations

Full continuations (the same as in Scheme) are support via the callcc function. A few examples are in tests/continuation_test.ell, and a full coroutine scheduler that supports the structured parallel statement is in lib/scheduler.ell. Ell's catch macro and error function are built on continuations.

Socket server, web server

See tests/sockserver.ell and tests/sockclient for a simple example of a TCP server that uses framed messages, and tests/webserver.ell and tests/webclient.ell for example HTTP server/client written in Ell

Threads and Channels

Lightweight threads and asynchronous communication channels are also supported. See tests/channel_test.ell and their usage in tests/sockserver.ell

License

Copyright 2015 Lee Boynton

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Index

Constants

View Source
const MaxFrameSize = 1000000

MaxFrameSize is an arbitrary limit to the tcp server framesize, to avoid trouble

Variables

View Source
var Apply = &Function{}

Apply is a primitive instruction to apply a function to a list of arguments

View Source
var BlobType Value = Intern("<blob>")
View Source
var CallCC = &Function{}

CallCC is a primitive instruction to executable (restore) a continuation

View Source
var CallSymbol = Intern("call")
View Source
var ChannelType Value = Intern("<channel>")

ChannelType - the type of Ell's channel object

View Source
var ClosureSymbol = Intern("closure")
View Source
var CodeType Value = Intern("<code>")
View Source
var ConnectionType = Intern("<connection>")
View Source
var DefglobalSymbol = Intern("defglobal")
View Source
var DefmacroSymbol = Intern("defmacro")
View Source
var EmptyBlob = MakeBlob(0)

EmptyBlob - a blob with no bytes

View Source
var FuncSymbol = Intern("func")
View Source
var FunctionType Value = Intern("<function>")
View Source
var GenfnsSymbol = Intern("*genfns*")
View Source
var GlobalSymbol = Intern("global")
View Source
var HTTPErrorKey = Intern("http-error:")
View Source
var InterruptKey = Intern("interrupt:")
View Source
var JumpSymbol = Intern("jump")
View Source
var JumpfalseSymbol = Intern("jumpfalse")
View Source
var LiteralSymbol = Intern("literal")
View Source
var LocalSymbol = Intern("local")
View Source
var MacroErrorKey = Intern("macro-error:")
View Source
var MethodsKeyword = Intern("methods:")
View Source
var MinusOne = Integer(-1)

MinusOne is the Ell -1 value

View Source
var One = Integer(1)

One is the Ell 1 value

View Source
var PopSymbol = Intern("pop")
View Source
var QuasiquoteSymbol = Intern("quasiquote")
View Source
var QuoteSymbol = Intern("quote")
View Source
var ReturnSymbol = Intern("return")
View Source
var SetlocalSymbol = Intern("setlocal")
View Source
var Spawn = &Function{}

Apply is a primitive instruction to apply a function to a list of arguments

View Source
var StructSymbol = Intern("struct")
View Source
var TailcallSymbol = Intern("tailcall")
View Source
var UndefineSymbol = Intern("undefine")
View Source
var UnquoteSymbol = Intern("unquote")
View Source
var UnquoteSymbolSplicing = Intern("unquote-splicing")
View Source
var UseSymbol = Intern("use")
View Source
var VectorSymbol = Intern("vector")
View Source
var Version = "(development version)"

Version - this version of ell

View Source
var Zero = Integer(0)

Zero is the Ell 0 value

Functions

func AddEllDirectory

func AddEllDirectory(dirname string)

func AsByteValue

func AsByteValue(obj Value) (byte, error)

func AsFloat64Value

func AsFloat64Value(obj Value) (float64, error)

func AsInt64Value

func AsInt64Value(obj Value) (int64, error)

func AsIntValue

func AsIntValue(obj Value) (int, error)

func AsList added in v1.0.4

func AsList(obj Value) *List

func AsStringValue

func AsStringValue(obj Value) (string, error)

AsStringValue - return the native string representation of the object, if possible

func Caar

func Caar(lst Value) Value

Caar - return the Car of the Car of the list

func Cadar

func Cadar(lst Value) Value

Cadar - return the Car of the Cdr of the Car of the list

func Cadddr

func Cadddr(lst Value) Value

Cadddr - return the Car of the Cdr of the Cdr of the Cdr of the list

func Caddr

func Caddr(lst Value) Value

Caddr - return the Car of the Cdr of the Cdr of the list

func Cadr

func Cadr(lst Value) Value

Cadr - return the Car of the Cdr of the list

func Car

func Car(v Value) Value

Car - return the first object in a list

func Cdar

func Cdar(lst Value) *List

Cdar - return the Cdr of the Car of the list

func Cddddr

func Cddddr(lst Value) *List

Cddddr - return the Cdr of the Cdr of the Cdr of the Cdr of the list

func Cdddr

func Cdddr(lst Value) *List

Cdddr - return the Cdr of the Cdr of the Cdr of the list

func Cddr

func Cddr(lst Value) *List

Cddr - return the Cdr of the Cdr of the list

func Cdr

func Cdr(v Value) *List

Cdr - return the rest of the list

func ChannelValue

func ChannelValue(obj Value) chan Value

ChannelValue - return the Go channel object for the Ell channel

func Cleanup

func Cleanup()

func CloseChannel

func CloseChannel(obj Value)

CloseChannel - close the channel object

func CompileFile

func CompileFile(name string) (Value, error)

caveats: when you compile a file, you actually run it. This is so we can handle imports and macros correctly.

func Concat

func Concat(seq1 *List, seq2 *List) (*List, error)

func CurrentTimestamp added in v1.0.5

func CurrentTimestamp(t time.Time) Value

func DefineFunction

func DefineFunction(name string, fun PrimitiveFunction, result Value, args ...Value)

Register a primitive function to the specified global name

func DefineFunctionKeyArgs

func DefineFunctionKeyArgs(name string, fun PrimitiveFunction, result Value, args []Value, defaults []Value, keys []Value)

Register a primitive function with keyword arguments to the specified global name

func DefineFunctionOptionalArgs

func DefineFunctionOptionalArgs(name string, fun PrimitiveFunction, result Value, args []Value, defaults ...Value)

Register a primitive function with optional arguments to the specified global name

func DefineFunctionRestArgs

func DefineFunctionRestArgs(name string, fun PrimitiveFunction, result Value, rest Value, args ...Value)

Register a primitive function with Rest arguments to the specified global name

func DefineGlobal

func DefineGlobal(name string, obj Value)

Bind the value to the global name

func DefineMacro

func DefineMacro(name string, fun PrimitiveFunction)

Register a primitive macro with the specified name.

func Eval

func Eval(expr Value) (Value, error)

func ExpandFilePath

func ExpandFilePath(path string) string

func Fatal

func Fatal(args ...interface{})

func FindModuleByName

func FindModuleByName(moduleName string) (string, error)

func FindModuleFile

func FindModuleFile(name string) (string, error)

func Flatten

func Flatten(lst *List) *List

func Float64Value

func Float64Value(obj Value) float64

Float64Value - return native float64 value of the object

func Get

func Get(obj Value, key Value) (Value, error)

Get - return the value for the key of the object. The Value() function is first called to handle typed instances of <struct>. This is called by the VM, when a keyword is used as a function.

func GetGlobal

func GetGlobal(sym Value) Value

GetGlobal - return the global value for the specified symbol, or nil if the symbol is not defined.

func GetKeywords

func GetKeywords() []Value

GetKeywords - return a slice of Ell primitive reserved words

func GetMacro

func GetMacro(sym Value) *macro

GetMacro - return the macro for the symbol, or nil if not defined

func Globals

func Globals() []*Symbol

Globals - return a slice of all defined global symbols

func Has

func Has(obj Value, key Value) (bool, error)

func Identical

func Identical(o1 Value, o2 Value) bool

Identical - return if two objects are identical

func Init

func Init(extns ...Extension)

func InitPrimitives

func InitPrimitives()

InitEnvironment - defines the global functions/variables/macros for the top level environment

func Int

func Int(n int64) *Number

func Int64Value

func Int64Value(obj Value) int64

Int64Value - return native int64 value of the object

func IntValue

func IntValue(obj Value) int

IntValue - return native int value of the object

func IsDefined

func IsDefined(sym *Symbol) bool

IsDefined - return true if the there is a global value defined for the symbol

func IsDirectoryReadable

func IsDirectoryReadable(path string) bool

IsDirectoryReadable - return true of the directory is readable

func IsFileReadable

func IsFileReadable(path string) bool

IsFileReadable - return true of the file is readable

func IsFloat

func IsFloat(obj Value) bool

func IsFunction

func IsFunction(v Value) bool

func IsInt

func IsInt(obj Value) bool

func IsList

func IsList(obj Value) bool

func IsNumber

func IsNumber(val Value) bool

func IsStruct

func IsStruct(obj Value) bool

func IsSymbol

func IsSymbol(obj Value) bool

func IsVector

func IsVector(obj Value) bool

func Json added in v1.0.4

func Json(val Value, indent string) (string, error)

func ListEqual

func ListEqual(l1 Value, l2 Value) bool

ListEqual returns true if the object is equal to the argument

func ListLength

func ListLength(o Value) int

func Load

func Load(name string) error

func LoadFile

func LoadFile(file string) error

func Macroexpand

func Macroexpand(expr Value) (Value, error)

Macroexpand - return the expansion of all macros in the object and return the result

func Macros

func Macros() []Value

Macros - return a slice of all defined macros

func Main

func Main(extns ...Extension)

func MakeList

func MakeList(count int, val Value) *List

func NamedChar added in v1.0.4

func NamedChar(name string) (rune, error)

func NewConnection added in v1.0.4

func NewConnection(con net.Conn, endpoint string) Value

func NewMacro added in v1.0.4

func NewMacro(name Value, expander *Function) *macro

Macro - create a new Macro

func NewSymbol added in v1.0.4

func NewSymbol(names []Value) (Value, error)

func Now

func Now() float64

func Pretty

func Pretty(val Value) string

func Print

func Print(args ...interface{})

func Println

func Println(args ...interface{})

func Put

func Put(obj Value, key Value, val Value) error

func Random

func Random(min float64, max float64) *Number

func RandomList

func RandomList(size int, min float64, max float64) *List

func RandomSeed

func RandomSeed(n int64)

func ReadAllFromString added in v1.0.4

func ReadAllFromString(s string) (*List, error)

func ReadEvalPrintLoop

func ReadEvalPrintLoop()

func ReadFromString added in v1.0.4

func ReadFromString(s string) (Value, error)

func Reverse

func Reverse(lst *List) *List

func Round

func Round(f float64) float64

Round - return the closest integer value to the float value

func Run

func Run(args ...string)

func RuneValue

func RuneValue(obj Value) rune

RuneValue - return native rune value of the object

func SetFlags

func SetFlags(o bool, v bool, d bool, t bool, i bool)

SetFlags - set various flags controlling the runtime

func Sleep

func Sleep(delayInSeconds float64)

func SlurpFile

func SlurpFile(path string) (string, error)

SlurpFile - return the file contents as a string

func SpitFile

func SpitFile(path string, data string) error

SpitFile - write the string to the file.

func StringCharacters

func StringCharacters(s *String) []Value

StringCharacters - return a slice of <character> objects that represent the string

func StringJoin

func StringJoin(seq Value, delims Value) (*String, error)

func StringRef

func StringRef(s *String, idx int) Value

StringRef - return the <character> object at the specified string index

func StringSplit

func StringSplit(obj Value, delims Value) (*List, error)

func StringToList added in v1.0.4

func StringToList(s *String) *List

func StringToVector added in v1.0.4

func StringToVector(s *String) *Vector

func StringValue

func StringValue(obj Value) string

StringValue - return native string value of the object

func StructEqual

func StructEqual(s1 *Struct, s2 *Struct) bool

Equal returns true if the object is equal to the argument

func StructKeys

func StructKeys(s Value) Value

func StructLength

func StructLength(strct *Struct) int

StructLength - return the length (field count) of the <struct> object

func StructToList added in v1.0.4

func StructToList(s *Struct) (*List, error)

func StructToVector added in v1.0.4

func StructToVector(s *Struct) *Vector

func StructValues

func StructValues(s Value) Value

func SymbolName added in v1.0.4

func SymbolName(obj Value) string

func ToCharacter

func ToCharacter(c Value) (*Character, error)

ToCharacter - convert object to a <character> object, if possible

func ToInt

func ToInt(o Value) (*Number, error)

ToInt - convert the object to an integer number, if possible

func ToList

func ToList(obj Value) (*List, error)

ToList - convert the argument to a List, if possible

func ToNumber

func ToNumber(o Value) (*Number, error)

ToNumber - convert object to a number, if possible

func ToString

func ToString(a Value) (*String, error)

ToString - convert the object to a string, if possible

func ToStruct

func ToStruct(obj Value) (Value, error)

func ToVector

func ToVector(obj Value) (*Vector, error)

ToVector - convert the object to a <vector>, if possible

func TypeNameString added in v1.0.4

func TypeNameString(tval Value) string

func Unkeyworded added in v1.0.4

func Unkeyworded(symOrKeyword Value) (Value, error)

func Unput

func Unput(obj Value, key Value) error

func Use

func Use(sym *Symbol) error

func VM

func VM(stackSize int) *vm

func Write

func Write(val Value) string

func WriteAll

func WriteAll(lst *List) string

func WriteAllIndent added in v1.0.4

func WriteAllIndent(lst *List, indent string) string

func WriteIndent added in v1.0.4

func WriteIndent(val Value, indent string) string

Types

type Blob

type Blob struct {
	Value []byte
}

func MakeBlob

func MakeBlob(size int) *Blob

MakeBlob - create a new blob of the given size. It will be initialized to all zeroes

func NewBlob added in v1.0.4

func NewBlob(bytes []byte) *Blob

Blob - create a new blob, using the specified byte slice as the data. The data is not copied.

func ToBlob

func ToBlob(obj Value) (*Blob, error)

ToBlob - convert argument to a blob, if possible.

func (*Blob) Equals added in v1.0.4

func (b *Blob) Equals(another Value) bool

func (*Blob) String added in v1.0.4

func (b *Blob) String() string

func (*Blob) Type added in v1.0.4

func (b *Blob) Type() Value

type Channel

type Channel struct {
	// contains filtered or unexported fields
}

func NewChannel added in v1.0.4

func NewChannel(bufsize int, name string) *Channel

Channel - create a new channel with the given buffer size and name

func (*Channel) Equals added in v1.0.4

func (ch1 *Channel) Equals(another Value) bool

func (*Channel) String added in v1.0.4

func (ch *Channel) String() string

func (*Channel) Type added in v1.0.4

func (ch *Channel) Type() Value

type Code

type Code struct {
	// contains filtered or unexported fields
}

Code - compiled Ell bytecode

func Compile

func Compile(expr Value) (*Code, error)

Compile - compile the source into a code object.

func MakeCode

func MakeCode(argc int, defaults []Value, keys []Value, name string) *Code

func (*Code) Equals added in v1.0.4

func (code1 *Code) Equals(another Value) bool

func (*Code) String

func (code *Code) String() string

func (*Code) Type added in v1.0.4

func (code *Code) Type() Value

type Connection

type Connection struct {
	Name string
	In   *Channel
	Out  *Channel
	Con  net.Conn
}

func (*Connection) Equals added in v1.0.4

func (c *Connection) Equals(another Value) bool

func (*Connection) String added in v1.0.4

func (c *Connection) String() string

func (*Connection) Type added in v1.0.4

func (c *Connection) Type() Value

type Continuation

type Continuation struct {
	// contains filtered or unexported fields
}

Continuation -

type EllReaderExtension added in v1.0.4

type EllReaderExtension struct {
	// contains filtered or unexported fields
}

func (*EllReaderExtension) HandleChar added in v1.0.4

func (ext *EllReaderExtension) HandleChar(c byte) (Value, error, bool)

func (*EllReaderExtension) HandleReaderMacro added in v1.0.4

func (ext *EllReaderExtension) HandleReaderMacro(c byte) (Value, error, bool)

type EllWriterExtension added in v1.0.4

type EllWriterExtension struct {
	// contains filtered or unexported fields
}

func (*EllWriterExtension) HandleValue added in v1.0.4

func (ext *EllWriterExtension) HandleValue(val Value) (string, error, bool)

type Extension

type Extension interface {
	Init() error
	Cleanup()
	String() string
}

type Frame added in v1.0.4

type Frame struct {
	// contains filtered or unexported fields
}

func (*Frame) String added in v1.0.4

func (frame *Frame) String() string

type Function added in v1.0.4

type Function struct {
	// contains filtered or unexported fields
}

func Closure

func Closure(code *Code, frame *Frame) *Function

func NewContinuation added in v1.0.4

func NewContinuation(frame *Frame, ops []int, pc int, stack []Value) *Function

func NewPrimitive added in v1.0.4

func NewPrimitive(name string, fun PrimitiveFunction, result Value, args []Value, rest Value, defaults []Value, keys []Value) *Function

func (*Function) Equals added in v1.0.4

func (f *Function) Equals(another Value) bool

func (*Function) String added in v1.0.4

func (f *Function) String() string

func (*Function) Type added in v1.0.4

func (f *Function) Type() Value

type Primitive

type Primitive struct {
	// contains filtered or unexported fields
}

Primitive - a primitive function, written in Go, callable by VM

type PrimitiveFunction

type PrimitiveFunction func(argv []Value) (Value, error)

PrimitiveFunction is the native go function signature for all Ell primitive functions

Directories

Path Synopsis
cmd
ell

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL