tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | README | LICENSE

tisp.7 (8402B)


      1 .TH TISP 1 "March 2021" "tisp 0.0.0" 
      2 .PP
      3 .SH NAME
      4 tisp \- tiny lisp
      5 .PP
      6 .SH SYNOPSIS
      7 tisp [-hv] [-c COMMAND] [-] [FILE ...]
      8 .PP
      9 .SH DESCRIPTION
     10 .PP
     11 
     12 .PP
     13 Tisp is a tiny, terse, and transparent lisp programming language designed to be lightweight and easy to embedded in other programs. Simply drop the 'tisp.c' and 'tisp.h' files into your project in order to use the necessary functions for your program. An example command line interpreter is provided in 'main.c'. Tisp is a single value name language (lisp-1) which tries to be unambiguous and focus on simplicity.  Much of the language is defined with Tisp itself leaving the C code as short as possible.
     14 .PP
     15 The language is still in active development and not yet stable. Until the 'v1.0' release expect non-backwards compatible changes in minor releases.
     16 .PP
     17 .SH LANGUAGE
     18 .PP
     19 Tisp is mainly based off of scheme, with minor features borrowed from other lisps and scripting languages.
     20 .PP
     21 .SS GENERAL
     22 .TP
     23 \fBComments\fP
     24 Single line comments with a semicolon, \fBeg\fP '(cons 1 2) ; ingnored by tisp until new line'.
     25 .PP
     26 .SS TYPES
     27 .TP
     28 \fBNil\fP
     29 Nil, null, empty, or false, represented as an empty list, \fBeg\fP '()', 'nil' 'false'.
     30 .PP
     31 .TP
     32 \fBIntegers\fP
     33 Whole real numbers, positive or negative with optional '+' or '-' prefixes repressively. Also supports scientific notation with a capital or lowercase 'e'. The exponent needs to be an positive integer, it can also be negative but that would just round to zero.  \fBeg\fP '1', '-48', '+837e4', '3E-2'.
     34 .PP
     35 .TP
     36 \fBDecimals\fP
     37 Floating point numbers, also know as decimals, are numbers followed by a period and an optional mantissa. Like integers they can be positive or negative with scientific notation, but still need an integer as an exponent. \fBeg\fP '1.', '+3.14', '-43.00', '800.001e-3'.
     38 .PP
     39 .TP
     40 \fBRationals\fP
     41 Fraction type, a ratio of two integers. Similar rules apply for numerator and dominator as integers (real positive or negative), except for scientific notation. Will simplify fraction where possible, and will through error on division by zero. \fBeg\fP '1/2', '4/3' '-1/2', '01/-30', '-6/-3'.
     42 .PP
     43 .TP
     44 \fBStrings\fP
     45 String of characters contained inside two double quotes. Any character is valid, including actual newlines, execpt for double quotes and backspace which need to be escaped as '\"' and '\\' respectively. Newlines and tabs can also be escaped with '\n' and '\t' \fBeg\fP '"foo"', '"foo bar"', '"string \"quoted\""', '"C:\\windows\\path"' '\twhite\n\tspace'.
     46 .PP
     47 .TP
     48 \fBSymbols\fP
     49 Case sensitive symbols which are evaluated as variable names. Supports lower and upper case letters, numbers, as well as the characters '_+-*/\\^=<>!?@#$%&~'. First character can not be a number, if the first character is a '+' or '-' then the second digit cannot be a number either. Unlike all the previously listed types, symbols are not self evaluating, but instead return the value they are defined to. Throws an error if a symbol is evaluated without it being previously assigned a value. \fBeg\fP 'foo', 'foo-bar', 'cat9', '+', '>=', 'nil?'.
     50 .PP
     51 .TP
     52 \fBLists\fP
     53 Lists composed of one or more elements of any type, including lists themselves. Expressed with surrounding parentheses and each element is separated by whitespace. When evaluated the procedure found at the first element is run with the rest of the elements as arguments. Technically list is not a type, but simply a nil-terminated chain of nested pairs. A pair is a group of two and only two elements, normally represented as '(a . b)', with 'a' being the first element (car/first) and 'b' being the second element (cdr/rest). For example '(a b c)' is equivilent to '(a . (b . (c . ())))', but it is often easier to express them the first way syntactically. To create an improper list (not nil-terminated list) the dot notation can be used, '(1 2 3 . 4)'.
     54 .PP
     55 .TP
     56 \fBFunctions\fP
     57 Lambda functions created within Tisp itself. Called using list syntax where the first element is the function name and any proceeding elements are the arguments to be evaluated. For example '(cadr '(1 2 3))' is a list of elements 'cadr' and ''(1 2 3)'. It calls the function 'cadr' which returns the 2nd element of the argument given, in this case a list of size 3, which returns '2'. \fBeg\fP 'list', 'not', 'apply', 'map', 'root', 'sqrt', 'print'
     58 .PP
     59 .TP
     60 \fBPrimitives\fP
     61 Procedures built in to the language written in C. Called like regular functions, see primitives section for more details. \fBeg\fP 'car', 'cond', 'def', 'write', '+'
     62 .PP
     63 .TP
     64 \fBMacros\fP
     65 Like lambda functions macros are defined within Tisp and are called in a similar fashion. However unlike functions and primitives the arguments are not evaluated before being given to the macro, and the output of a macro is only evaluated at the end. This means instead of taking in values and returning values, macros take in code and return code, allowing you to extend the language at compile time. \fBeg\fP 'if', 'and', 'or', 'let', 'assert'
     66 .PP
     67 .SS BUILT-INS
     68 .PP
     69 Built in primitives written in C included by default.
     70 .PP
     71 .TP
     72 \fBcar\fP
     73 Returns first element of given list
     74 .PP
     75 .TP
     76 \fBcdr\fP
     77 Return rest of the given list, either just the second element if it is a pair, or another list with the first element removed.
     78 .PP
     79 .TP
     80 \fBcons\fP
     81 Creates a new pair with the two given arguments, first one as the car, second as the cdr. Can be chained together to create a list if ending with 'nil'.
     82 .PP
     83 .TP
     84 \fBquote\fP
     85 Returns the given argument unevaluated.
     86 .PP
     87 .TP
     88 \fBVoid\fP
     89 Returns nothing. Used to insert a void type in a list or force a function not to return anything.
     90 .PP
     91 .TP
     92 \fBeval\fP
     93 Evaluates the expression given, can be dangerous to use in practice. In general 'apply' should be used instead.
     94 .PP
     95 .TP
     96 \fB=\fP
     97 Tests if multiple values are all equal. Returns 'nil' if any are not, and 't' otherwise.
     98 .PP
     99 .TP
    100 \fBcond\fP
    101 Evaluates each expression if the given condition corresponding to it is true. Runs through all arguments, each is a list with the first element as the condition which needs to be 't' after evaluated, and the rest of the list is the body to be run if and only if the condition is met. Used for if/elseif/else statements found in C-like languages and 'if','when','unless','switch' macros in Tisp.
    102 .PP
    103 .TP
    104 \fBtypeof\fP
    105 Returns a string stating the given argument's type. Used to create 'type?' individual functions.
    106 .PP
    107 .TP
    108 \fBlambda\fP
    109 Creates function, first argument is a list of elements representing the symbol name for any arguments of the new function. Rest of the arguments are code to be run with the supplied arguments.
    110 .PP
    111 .TP
    112 \fBmacro\fP
    113 Similar to lambda, creates anonymous macro with first argument as macro's argument list and rest as macro's body.
    114 .PP
    115 .TP
    116 \fBdef\fP
    117 Create variable with the name of the first argument, with the value of the second. If name given is a list use the first element of this list as a new functions name and rest of list as its arguments. If only variable name is given make it self evaluating.
    118 .PP
    119 .TP
    120 \fBset!\fP
    121 Change the value of the of the variable given by the first argument to the second argument. Errors if variable is not defined before.
    122 .PP
    123 .TP
    124 \fBload\fP
    125 Loads the library given as a string.
    126 .PP
    127 .TP
    128 \fBerror\fP
    129 Throw error, print message given by second argument string with the first argument being a symbol of the function throwing the error.
    130 .PP
    131 .TP
    132 \fBversion\fP
    133 Return string of Tisp's version number.
    134 .PP
    135 .SS DIFFERENCES FROM OTHER LISPS
    136 .PP
    137 In Tisp there are no boolean types, much like common lisp, true is represented by the self evaluating symbol 't' and false is nil, represented as '()', an empty list. 'nil' and 'false' are also mapped to '()'.
    138 .PP
    139 Tisp also only has one builtin equality primitive, '=', which tests integers, symbols, strings, and objects which occupy the same space in memory, such as primitives.
    140 .PP
    141 Symbols are case sensitive, unlike many other older lisps, in order to better interface with modern languages.
    142 .PP
    143 Tisp is single value named, so procedures share the same namespace as variables, removing the need for common lisp's 'defunc' vs 'defvar', 'let' vs 'flet', and redundant syntax for getting the function from a symbol.
    144 .PP
    145 .SH AUTHOR
    146 .PP
    147 Ed van Bruggen <ed@edryd.org>
    148 .PP
    149 .SH SEE ALSO
    150 .PP
    151 tisp(1) tsp(1)
    152 .PP
    153 See project at <https://edryd.org/projects/tisp>
    154 .PP
    155 View source code at <https://git.edryd.org/tisp>
    156 .PP
    157 .SH LICENSE
    158 .PP
    159 zlib License 
    160 .PP
    161