Skip to content

Instantly share code, notes, and snippets.

@gregspurrier
Created May 27, 2013 21:10
Show Gist options
  • Save gregspurrier/5659105 to your computer and use it in GitHub Desktop.
Save gregspurrier/5659105 to your computer and use it in GitHub Desktop.
specdoc output of KLaSC as of May 27, 2013.
Testing KLamba specification compliance of:
Shen 2010, copyright (C) 2010 Mark Tarver
released under the Shen license
www.shenlanguage.org, version 11
running under Common Lisp, implementation: CLisp
port 1.5 ported by Mark Tarver
Atoms:
a string
is self-evaluating
a symbol literal
is self-evaluating
may include any of the legal characters for symbol other than ; : { }
may begin with any legal character other than a digit or ; : { }
may be ; as a single character
may be : as a single character
may be { as a single character
may be } as a single character
may not begin with a digit
numbers
parses integers as integers
parses floating point numbers as reals
with leading sign characters
recognizes negative numbers
treats any odd number of minuses as negative
treats any even number of minuses as positive
ignores leading plusses
true
evaluates to boolean true rather than a symbol
false
evaluates to boolean false rather than a symbol
Primitives for Arithmetic
+
adds its arguments
returns an integer when both arguments are integers
returns a real when either argument is a real
raises an error if its first argument is not an integer or a real
raises an error if its second argument is not an integer or a real
evaluates its arguments from left to right
supports partial application of 1 argument
-
subtracts its second argument from its first
returns an integer when both arguments are integers
returns a real when either argument is a real
raises an error if its first argument is not an integer or a real
raises an error if its second argument is not an integer or a real
evaluates its arguments from left to right
supports partial application of 1 argument
*
multiplies its arguments
returns an integer when both arguments are integers
returns a real when either argument is a real
raises an error if its first argument is not an integer or a real
raises an error if its second argument is not an integer or a real
evaluates its arguments from left to right
supports partial application of 1 argument
/
divides its first argument by its second argument
returns an integer when an integer evenly divides another integer
returns a real when an integer does not evenly divide another integer
returns a real when either argument is a real
raises an error if its first argument is not an integer or a real
raises an error if its second argument is not an integer or a real
evaluates its arguments from left to right
supports partial application of 1 argument
>
returns false if its first argument is less than its second argument
returns false if its first argument is equal to its second argument
returns true if its first argument is greater than its second argument
raises an error if its first argument is not an integer or a real
raises an error if its second argument is not an integer or a real
evaluates its arguments from left to right
supports partial application of 1 argument
<
returns true if its first argument is less than its second argument
returns false if its first argument is equal to its second argument
returns false if its first argument is greater than its second argument
raises an error if its first argument is not an integer or a real
raises an error if its second argument is not an integer or a real
evaluates its arguments from left to right
supports partial application of 1 argument
>=
returns false if its first argument is less than its second argument
returns true if its first argument is equal to its second argument
returns true if its first argument is greater than its second argument
raises an error if its first argument is not an integer or a real
raises an error if its second argument is not an integer or a real
evaluates its arguments from left to right
supports partial application of 1 argument
<=
returns true if its first argument is less than its second argument
returns true if its first argument is equal to its second argument
returns false if its first argument is greater than its second argument
raises an error if its first argument is not an integer or a real
raises an error if its second argument is not an integer or a real
evaluates its arguments from left to right
supports partial application of 1 argument
number?
returns true when its argument is an integer
returns true when its argument is a real
returns false when its argument is of any other type
Primitives for assignment
(set Name Value)
associates Value with Name
returns Value
overwrites the previous value when called again with same Name
supports partial application of 1 argument
evaluates its arguments from left to right
(value Name)
returns the value associated with Name
raises an error if Name has not previously been set
Primitives for Boolean Operations
if special form
supports partial application of 1 argument
supports partial application of 2 arguments
evaluates its first argument
when its first argument evaluates to true
returns the normal form of its second argument
does not evaluate its third argument
when its first argument evaluates to false
returns the normal form of its third argument
does not evaluate its second argument
and special form
evaluates its first argument
may be passed as an argument to a higher-order function
when its first argument evaluates to true
returns true if its second argument evaluates to true
returns false if its second argument evaluates to false
when its first argument evaluates to false
returns false
does not evaluate it second argument
partial application
supports partial application of 1 argument
results in it no longer short-circuiting argument evaluation
or special form
evaluates its first argument
may be passed as an argument to a higher-order function
when its first argument evaluates to false
returns true if its second argument evaluates to true
returns false if its second argument evaluates to false
when its first argument evaluates to true
returns true
does not evaluate it second argument
partial application
supports partial application of 1 argument
results in it no longer short-circuiting argument evaluation
Primitives for Generic Functions
(defun Name ArgList Expr)
does not evaulate Expr
returns Name
binds Name to a function having ArgList as its formals and Expr as its body
allows ArgList to be the empty list
allows previously defined non-primitive functions to be redefined
raises an error when attempting to redefine a primitive
raises an error if ArgList is not a list
raises an error if ArgList contains non-symbols
raises an error when given 0 arguments
raises an error when given 1 argument
raises an error when given 2 arguments
(lambda X Expr)
does not evaulate Expr
returns a function
raises an error when given 0 arguments
raises an error when given 1 argument
the returned function, when applied
evaluates Expr with X bound to its argument
(freeze Expr)
does not evaluate Expr
returns a continuation
the returned continuation, upon thawing
evaluates and returns the value of Expr
re-evaluates Expr with each thawing
partial application
supports partial application of 0 arguments
results in it no longer delaying execution of Expr
Primitives for lists
(cons Hd Tl)
creates a list with Hd as the head and Tl as the tail
allows Tl to be a non-list
supports partial application of 1 argument
evaluates its arguments from left to right
(hd L)
returns the head of L
raises an error if its first argument is not a list, a dotted pair, or an empty list
(tl L)
returns the tail of L
raises an error if its first argument is not a list, a dotted pair, or an empty list
cons?
returns true when its argument is a list
returns true when its argument is a dotted pair
returns false when its argument is of any other type
Primitives for strings
(pos S N)
returns the character at zero-based index N of S as a unit string
raises an error if N is negative
raises an error if N is >= the length of S
raises an error if its first argument is not a string
raises an error if its second argument is not an integer
supports partial application of 1 argument
evaluates its arguments from left to right
(tlstr S)
returns a string containing all but the first character of S
raises an error when S is the empty string
string?
returns true when its argument is a string
returns false when its argument is of any other type
(n->string N)
returns a unit string containing the character with ASCII code N
raises an error if its first argument is not an integer
(string->n S)
returns the ASCII code of the unit string S
returns the ASCII code of the first character of non-unit string S
raises an error when S is the empty string
raises an error if its first argument is not a string
Primitives for symbols
intern
converts a string to its corresponding symbol
converts the string "true" to boolean true
converts the string "false" to boolean false
raises an error if its first argument is not a string
Primitive functions for vectors
(absvector N)
returns a new absolute vector of size N
raises an error if N is negative
raises an error if its first argument is not an integer
(address-> V N Value)
returns the vector V updated with Value at index N
raises an error if N is negative
raises an error if N is >= the size of the vector
raises an error if its second argument is not an integer
supports partial application of 1 argument
supports partial application of 2 arguments
(<-address V N)
returns the value previously stored at index N in V
returns an unspecified value if index N has not been stored to
raises an error if N is negative
raises an error if N is >= the size of the vector
raises an error if its second argument is not an integer
evaluates its arguments from left to right
(absvector? X)
returns true if X is an absvector
returns a boolean of unspecified value when X was not created via absvector
Tail recursion
does not consume stack space for self tail calls
Finished in 2.43 seconds
179 examples, 0 failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment