intro.texi (13760B)
1 @c -*-texinfo-*- 2 @setfilename ../src/intro 3 4 @node License, Introduction, Top, Top 5 @comment node-name, next, previous, up 6 7 klisp is licensed under the terms of the MIT license reproduced below. 8 This means that klisp is free software and can be used for both academic 9 and commercial purposes at absolutely no cost. 10 The two projects whose code klisp uses, Lua & IMath, are also distributed 11 under the MIT license. 12 13 @itemize @bullet 14 @item 15 klisp Parts: Copyright @copyright{} 2011-2012 Andres Navarro, Oto Havle. 16 @item 17 Lua Parts: Copyright @copyright{} 1994-2010 Lua.org, PUC-Rio. 18 @item 19 IMath Parts: Copyright @copyright{} 2002-2007 Michael J. Fromberger. 20 @item 21 srfi-78: Copyright @copyright{} 2005-2006 Sebastian Egner. 22 @end itemize 23 24 @unnumbered MIT/X11 License 25 26 Permission is hereby granted, free of charge, to any person obtaining a copy 27 of this software and associated documentation files (the "Software"), to deal 28 in the Software without restriction, including without limitation the rights 29 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 30 copies of the Software, and to permit persons to whom the Software is 31 furnished to do so, subject to the following conditions: 32 33 The above copyright notice and this permission notice shall be included in 34 all copies or substantial portions of the Software. 35 36 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 37 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 38 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 39 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 40 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 41 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 42 THE SOFTWARE. 43 44 @c next node should be types 45 @node Introduction, Interpreter, License, Top 46 @chapter Introduction 47 48 klisp is an open source interpreter for the Kernel Programming 49 Language. It aims at being comprehensive and robust as specified in 50 the @cite{Revised(-1) Report on the Kernel Programming Language}, but 51 that probably won't happen for some time. It is written in C99 under 52 the MIT license. It draws heavily from the Lua interpreter source 53 code & file structure. It uses the IMath library for arbitrary sized 54 integers and rationals. 55 56 The Kernel programming language is a statically scoped and properly 57 tail-recursive dialect of Lisp, descended from Scheme. It is designed 58 to be simpler and more general than Scheme, with an exceptionally 59 clear, simple, and versatile semantics, only one way to form compound 60 expressions, and no inessential restrictions on the power of that one 61 compound form. Imperative, functional, and message-passing programming 62 styles (to name a few) may be conveniently expressed in Kernel. 63 64 An important property of Kernel is that all manipulable entities in 65 Kernel are first-class objects. In particular, Kernel has no 66 second-class combiners; instead, the roles of special forms and macros 67 are subsumed by operatives, which are first-class, statically scoped 68 combiners that act directly on their unevaluated operands. Kernel 69 also has a second type of combiners, applicatives, which act on their 70 evalu- ated arguments. Applicatives are roughly equivalent to Scheme 71 procedures. However, an applicative is nothing more than a wrapper to 72 induce operand evaluation, around an underlying operative (or, in 73 principle, around another applicative, though that isn’t usually 74 done); applicatives themselves are mere facilitators to computation. 75 76 You can read more about Kernel at 77 @url{http://web.cs.wpi.edu/~jshutt/kernel.html}. 78 79 klisp is freely available for both academic and commercial purposes. 80 See LICENSE for details. it can be downloaded at 81 @url{https://bitbucket.org/AndresNavarro/klisp} 82 83 klisp is developed by Andres Navarro, a Computer Science 84 undergraduate at Buenos Aires University (UBA). You can reach him at 85 @email{canavarro82@@gmail.com}. Significant contributions are being 86 done by Oto Havle, his fork is at 87 @url{https://bitbucket.org/havleoto/klisp}. 88 89 This manual describes klisp version 0.3, presuming some familiarity 90 with the Lisp family of languages in general, and with the Kernel 91 Programming Language in particular. There are frequent references to 92 the Kernel Programming Language Report. Unlike in the report, no 93 rationale is provided for any feature, only a description of the 94 implemented functionality. 95 96 This is edition 0.3. 97 98 @menu 99 * Caveats:: Flaws and a request for help. 100 * Kernel History:: Kernel is descended from Scheme. 101 * Conventions:: How the manual is formatted. 102 * Acknowledgements:: Contributions to this manual. 103 @end menu 104 105 @node Caveats, Kernel History, Introduction, Introduction 106 @section Caveats 107 108 This is the first draft of this manual. It will be incomplete for 109 some time. It will also evolve, together with klisp and the Kernel 110 Programming Language, both of which, right now, are in a quite fluid 111 state. 112 113 @c this is below, in history 114 The main reference on Kernel is the preliminary report: 115 @cite{Revised(-1) Report on the Kernel Programming Language}. Some 116 sections of the report are still incomplete, so both klisp and this 117 manual will use specifications from other languages in these sections, 118 trying to follow the Kernel spirit. These instances will be documented 119 throughout the manual. 120 121 Please mail comments and corrections to 122 @email{canavarro82@@gmail.com}. 123 124 @noindent 125 @display 126 --Andres Navarro 127 @end display 128 129 @node Kernel History, Conventions, Caveats, Introduction 130 @section Kernel History 131 @cindex Kernel history 132 133 The Kernel Programming Language is a work in progress. It is being 134 developed by John N. Shutt, Ph.D, who created it while studying at the 135 Worcester Polytechnic Institute (I think about 2002, or so... ASK). It 136 is descended from scheme, with the idea that all objects should be 137 first class values. In particular, Kernel replaces macros with 138 operatives (kinda like statically scoped fexprs and fsubrs) and has 139 first class environments. Kernel also has the notion of encapsulated 140 objects which limits the ammount of information an implementation can 141 share with a Kernel program (e.g. There is no way in Kernel to get the 142 parents or a complete list of bindings of an environment object). 143 144 @c this is repeated above, in caveats 145 The main reference on Kernel is the preliminary report: 146 @cite{Revised(-1) Report on the Kernel Programming Language}. Some 147 sections of the report are still incomplete, so both klisp and this 148 manual will use specifications from other languages in these sections, 149 trying to follow the Kernel spirit. These instances will be documented 150 throughout the manual. 151 152 You can read all about Kernel at John's homepage at WPI 153 @url{http://www.cs.wpi.edu/~jshutt/}, including the preliminary report 154 on the language and his doctoral dissertation which gives a 155 theorethical frame for fexprs. You can contact him at 156 @email{jshutt@@cs.wpi.edu}. 157 158 @node Conventions, Acknowledgements, Kernel History, Introduction 159 @section Conventions 160 161 This section explains the notational conventions that are used in this 162 manual. You may want to skip this section and refer back to it later. 163 164 @menu 165 * Some Terms:: Explanation of terms we use in this manual. 166 @c TODO add sections for booleans, parameter trees, list structures, 167 @c naming conventions, etc. 168 * Evaluation Notation:: The format we use for examples of evaluation. 169 * Printing Notation:: The format we use for examples that print output. 170 * Error Messages:: The format we use for examples of errors. 171 * Format of Descriptions:: Notation for describing functions, variables, etc. 172 @end menu 173 174 @node Some Terms, Evaluation Notation, Conventions, Conventions 175 @subsection Some Terms 176 177 Throughout this manual, the phrases ``the Kernel reader'' and ``the Kernel 178 printer'' are used to refer to those routines in Lisp that convert 179 textual representations of Kernel objects into actual objects, and 180 @c TODO xref to printed representations 181 vice versa. XXX Printed Representation XXX, for more details. You, the 182 person reading this manual, are assumed to be ``the programmer'' or 183 ``the user''. 184 185 @cindex fonts 186 Examples of Kernel code appear in this font or form: @code{(list 1 2 187 3)}. Names that represent arguments or metasyntactic variables appear 188 in this font or form: @var{first-number}. 189 190 @node Evaluation Notation, Printing Notation, Some Terms, Conventions 191 @subsection Evaluation Notation 192 @cindex evaluation notation 193 @cindex documentation notation 194 195 When you evaluate a piece of Kernel code, it produces a result. In the 196 examples in this manual, this is indicated with @samp{@result{}}: 197 198 @example 199 (car (cons 1 2)) 200 @result{} 1 201 @end example 202 203 @noindent 204 You can read this as ``@code{(car (cons 1 2))} evaluates to 1''. 205 206 The semantics of a language feature are sometimes clarified, or even 207 defined, in its entry by specifying that two expressions are 208 equivalent. This is notated with @samp{@equiv{}}. For example, the 209 semantics of applicative list* can be defined by following 210 equivalences: 211 @example 212 (list* arg1) @equiv{} arg1 213 (list* arg1 . more-args) @equiv{} (cons arg1 (list* . more-args)) 214 @end example 215 Notice that in these kind of examples the applicatives or operatives 216 referred to are the first class values and not the symbols bound to 217 them in the ground environment. This definition would hold even if 218 @code{cons} or @code{list*} were redefined in the current dynamic 219 environment. 220 221 @node Printing Notation, Error Messages, Evaluation Notation, Conventions 222 @subsection Printing Notation 223 @cindex printing notation 224 225 Many of the examples in this manual print text when they are 226 evaluated. In examples that print text, the printed text is indicated with 227 @samp{@print{}}. The value returned by evaluating the form (here 228 @code{#t}) follows on a separate line. 229 230 @group 231 @example 232 ($sequence (write 1) (write 2) #t) 233 @print{} 1 234 @print{} 2 235 @result{} #t 236 @end example 237 @end group 238 239 @node Error Messages, Format of Descriptions, Printing Notation, Conventions 240 @subsection Error Messages 241 @cindex error message notation 242 243 Some examples cause errors to be signaled. The report doesn't 244 specify what objects are passed to the error continuation, but in 245 klisp, objects passed to the error continuation are encapsulated error 246 objects that have at least a message and possibly some additional 247 objects and context informations (such as source code location). In 248 the examples, the error message is shown on a line starting with 249 @samp{@error{}}. 250 251 @example 252 (+ 23 #t) 253 @error{} Wrong type argument: (expected number) (#t) 254 @end example 255 256 @node Format of Descriptions, , Error Messages, Conventions 257 @subsection Format of Descriptions 258 @cindex description format 259 260 Applicatives, operatives, and other objects are described in this manual 261 in a uniform format. The first line of a description contains the 262 name of the item followed by its operands or arguments, if any. 263 @ifinfo 264 The category---operative, applicative, or whatever---appears at the 265 beginning of the line. 266 @end ifinfo 267 @iftex 268 The category---operative, applicative, or whatever---is printed next to the 269 right margin. 270 @end iftex 271 The description follows on succeeding lines, sometimes with examples. 272 273 @menu 274 * A Sample Applicative Description:: 275 @c TODO add operative and/or variable like root-continuation 276 @end menu 277 278 @node A Sample Applicative Description, , Format of Descriptions, Format of Descriptions 279 @subsubsection A Sample Applicative Description 280 @cindex applicative descriptions 281 @cindex operative descriptions 282 @cindex object descriptions 283 284 In an applicative description, the name of the applicative being 285 described appears first. It is followed on the same line by an 286 applicative combination that includes the name of the applicative and 287 the arguments, as would appear in a program. The names used for the 288 arguments are also used in the body of the description. 289 290 Here is a description of an imaginary applicative @code{foo}: 291 292 @deffn Applicative foo (foo integer1 integer2 . rest) 293 The applicative @code{foo} subtracts @var{integer1} from @var{integer2}, 294 then adds all the rest of the arguments to the result. 295 296 @example 297 (foo 1 5 3 9) 298 @result{} 16 299 @end example 300 301 More generally, 302 303 @example 304 (foo @var{w} @var{x} @var{y}@dots{}) 305 @equiv{} 306 (+ (- @var{x} @var{w}) @var{y}@dots{}) 307 @end example 308 @end deffn 309 310 Any parameter whose name contains the name of a type (e.g., 311 @var{integer}, @var{integer1} or @var{continuation}) is expected to be of that 312 type. A plural of a type (such as @var{numbers}) often means a list of 313 objects of that type. Parameters named @var{object} may be of any 314 type. Additionally parameters named @var{k}, or @var{kn} (for any 315 value of @var{n}), should be exact, non-negative integers. 316 @c TODO add xref types of objects 317 (XXX Types of Lisp Object XXX, for a list of Kernel object types.) 318 Parameters with other sorts of names are 319 discussed specifically in the description of the combiner. In some 320 sections, features common to parameters of several combiners are 321 described at the beginning. 322 323 @c TODO xref to ptree 324 @c TODO clean this up a little 325 Operative descriptions have the same format, but the word 326 `Applicative' is replaced by `Operative', and `Argument' is replaced 327 by `Operand'. Also Operatives always have an environment parameter 328 (that can be #ignore or a symbol). 329 330 @node Acknowledgements,, Conventions, Introduction 331 @section Acknowledgements 332 333 This manual was written by Andres Navarro. 334 335 The structure and some text for this introductory section were 336 borrowed from the Elisp Manual by the Free Sofware Foundation. This 337 manual also borrows freely from both the Kernel Report and the Scheme 338 Reports.