Documentation ¶
Overview ¶
Package std provides a number of basic WDTE functions.
The functions provided by this package are slightly different from those in many of the standard library's packages in that they are intended to be directly inserted into the top-level scope, rather than imported. They provide basic functionality, such as addition and subtraction, as well as some more language-specific functionality, such as the ability to check the type of a value.
Index ¶
- Constants
- Variables
- func And(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func At(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Collect(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Div(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Equals(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func F() wdte.Frame
- func Greater(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func GreaterEqual(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Known(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Len(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Less(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func LessEqual(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Minus(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Mod(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Not(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Or(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Plus(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Reflect(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Register(name string, module *wdte.Scope)
- func Sub(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Times(frame wdte.Frame, args ...wdte.Func) wdte.Func
Constants ¶
const ( // True is a WDTE function with the following signature: // // true // // As you can probably guess, it returns a boolean true. True wdte.Bool = true // False is a WDTE function with the following signature: // // false // // Returns a boolean false. This is rarely necessary as most // built-in functionality considers any value other than a boolean // true to be false, but it's provided for completeness. False wdte.Bool = false )
Variables ¶
var ( // Import provides a simple importer that imports registered // modules. Import = wdte.ImportFunc(stdImporter) )
var Scope = wdte.S().Map(map[wdte.ID]wdte.Func{ "+": wdte.GoFunc(Plus), "-": wdte.GoFunc(Minus), "*": wdte.GoFunc(Times), "/": wdte.GoFunc(Div), "%": wdte.GoFunc(Mod), "==": wdte.GoFunc(Equals), "<": wdte.GoFunc(Less), ">": wdte.GoFunc(Greater), "<=": wdte.GoFunc(LessEqual), ">=": wdte.GoFunc(GreaterEqual), "true": True, "false": False, "&&": wdte.GoFunc(And), "||": wdte.GoFunc(Or), "!": wdte.GoFunc(Not), "len": wdte.GoFunc(Len), "at": wdte.GoFunc(At), "collect": wdte.GoFunc(Collect), "known": wdte.GoFunc(Known), "sub": wdte.GoFunc(Sub), "reflect": wdte.GoFunc(Reflect), })
Scope is a scope containing the functions in this package.
This scope is primarily useful for bootstrapping an environment for running scripts in. To use it, simply pass a frame containing it or a subscope of it to a function call. In many cases, a client can simply call F to obtain such a frame.
Functions ¶
func And ¶
And is a WDTE function with the following signature:
&& ...
Returns true if all of its arguments are true.
func At ¶
At is a WDTE function with the following signatures:
at a i (at i) a
Returns the ith index of a. a is assumed to implement wdte.Atter.
func Collect ¶
Collect is a WDTE function with the following signature:
collect compound
Collect takes a compound as its argument and returns the scope collected from executing that compound. The argument must be a compound literal or the function will fail. Assigning a compound to an ID and then passing that ID will not work.
It surrounds the returned scope with a bound called "collect".
func Div ¶
Div is a WDTE function with the following signatures:
/ a b (/ b) a
Returns a divided by b.
func Equals ¶
Equals is a WDTE function with the following signatures:
== a b (== b) a
Returns true if a equals b. If a implements wdte.Comparer, the equality check is done using that implementation. If a does not but b does, b's implementation is used. If neither does, a direct Go equality check is used.
func Greater ¶
Greater is a WDTE function with the following signatures:
> a b (> b) a
Returns true if a is greater than b. Comparison rules are the same as those used for Equals, with the exception that the argument used must not only implement wdte.Comparer but that that implementation must support ordering.
func GreaterEqual ¶
GreaterEqual is a WDTE function with the following signatures:
>= a b (>= b) a
Returns true if a is greater than or equal to b. Comparison rules are the same as those used for Equals, with the exception that the argument used must not only implement wdte.Comparer but that that implementation must support ordering.
func Known ¶ added in v0.2.2
Known is a WDTE function with the following signature:
known scope
Returns an array containing known identifiers in the given scope sorted alphabetically.
func Len ¶
Len is a WDTE function with the following signature:
len a
Returns the length of a if a implements wdte.Lenner, or false if it doesn't.
func Less ¶
Less is a WDTE function with the following signatures:
< a b (< b) a
Returns true if a is less than b. Comparison rules are the same as those used for Equals, with the exception that the argument used must not only implement wdte.Comparer but that that implementation must support ordering.
func LessEqual ¶
LessEqual is a WDTE function with the following signatures:
<= a b (<= b) a
Returns true if a is less than or equal to b. Comparison rules are the same as those used for Equals, with the exception that the argument used must not only implement wdte.Comparer but that that implementation must support ordering.
func Not ¶
Not is a WDTE function with the following signature:
! a
Returns true if a is not true or false if a is not true.
func Or ¶
Or is a WDTE function with the following signature:
|| ...
Returns true if any of its arguments are true.
func Plus ¶
Plus is a WDTE function with the following signatures:
- a ... (+ a) ...
Returns the sum of a and the rest of its arguments.
func Reflect ¶ added in v0.4.2
Reflect is a WDTE function with the following signature:
reflect v type (reflect type) v
It provides a simple wrapper around wdte.Reflect, checking underlying type compatability.
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package all is a convenience package that imports the entire standard library, thus registering it with std.Import.
|
Package all is a convenience package that imports the entire standard library, thus registering it with std.Import. |
Package arrays contains functions for manipulating arrays.
|
Package arrays contains functions for manipulating arrays. |
Package io contains WDTE functions for dealing with files and other types of data streams.
|
Package io contains WDTE functions for dealing with files and other types of data streams. |
file
Package file provides functions for dealing with files.
|
Package file provides functions for dealing with files. |
Package math contains wdte.Funcs for performing mathematical operations.
|
Package math contains wdte.Funcs for performing mathematical operations. |
Package stream provides WDTE functions for manipulating streams of data.
|
Package stream provides WDTE functions for manipulating streams of data. |
Package strings contains functions for dealing with strings.
|
Package strings contains functions for dealing with strings. |