home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk1.iso / altsrc / articles / 11155 < prev    next >
Internet Message Format  |  1994-08-23  |  31KB

  1. Path: wupost!uhog.mit.edu!news.kei.com!travelers.mail.cornell.edu!newstand.syr.edu!galileo.cc.rochester.edu!ceas.rochester.edu!ceas.rochester.edu!not-for-mail
  2. From: weisberg@kirchoff.ee.rochester.edu (Jeff Weisberg)
  3. Newsgroups: alt.sources
  4. Subject: jlisp interpreter part00 / 10
  5. Followup-To: alt.sources.d
  6. Date: 23 Aug 1994 11:07:16 -0400
  7. Organization: University of Rochester School of Engineering and Applied Science
  8. Lines: 1156
  9. Message-ID: <Jlisp94Aug23part00@ee.rochester.edu>
  10. References: <Jlisp94Aug23Notice@ee.rochester.edu>
  11. NNTP-Posting-Host: kirchoff.ee.rochester.edu
  12.  
  13.  
  14. Archive-name: jlisp-1.03
  15. Submitted-by: weisberg@ee.rochester.edu
  16.  
  17. #! /bin/sh
  18. # 0. this is shell archive
  19. # 1. Remove everything above the #! /bin/sh line
  20. # 2. Save the resulting text in a file
  21. # 3. Execute the file with /bin/sh (not csh)
  22. # 4. Or use your favorite variant of unshar
  23. # 5. To overwrite existing files use "sh -c"
  24. #
  25. # Created by: weisberg@ankara on Tue Aug 23 10:50:12 EDT 1994
  26. # This archive contains:
  27. #    jlisp-1.03/
  28. #    jlisp-1.03/Doc/
  29. #    jlisp-1.03/bin/
  30. #    jlisp-1.03/etc/
  31. #    jlisp-1.03/lisp/
  32. #    jlisp-1.03/src/
  33. #    jlisp-1.03/README
  34. #    jlisp-1.03/Acknowledgements
  35. #    jlisp-1.03/Describble
  36. #    jlisp-1.03/Doc/Balls
  37. #    jlisp-1.03/Doc/Hooks
  38. #    jlisp-1.03/Doc/Ports
  39. #    jlisp-1.03/Doc/Signals
  40. #    jlisp-1.03/Doc/numbers
  41. #    jlisp-1.03/Doc/strings
  42. #    jlisp-1.03/Internals
  43. #    jlisp-1.03/License
  44. #    jlisp-1.03/Makefile
  45. #    jlisp-1.03/ToDo
  46. #    jlisp-1.03/bin/if-changed
  47. #    jlisp-1.03/etc/example-.jlisprc
  48. #    jlisp-1.03/etc/example-emacs
  49. #    jlisp-1.03/lisp/all-syms.jl
  50. #    jlisp-1.03/lisp/autoload.jl
  51. #    jlisp-1.03/lisp/bind.jl
  52. #    jlisp-1.03/lisp/chkml.jl
  53. #    jlisp-1.03/lisp/cl.jl
  54. #    jlisp-1.03/lisp/cmdline.jl
  55. #    jlisp-1.03/lisp/debug.jl
  56. #    jlisp-1.03/lisp/expand.jl
  57. #    jlisp-1.03/lisp/format.jl
  58. #    jlisp-1.03/lisp/fs.jl
  59. #    jlisp-1.03/lisp/init.cf.jl
  60. #    jlisp-1.03/lisp/julia.jl
  61. #    jlisp-1.03/lisp/lib.jl
  62. #    jlisp-1.03/lisp/math.jl
  63. #    jlisp-1.03/lisp/mouse.jl
  64. #    jlisp-1.03/lisp/mrirc.cf.jl
  65. #    jlisp-1.03/lisp/mritool.jl
  66. #    jlisp-1.03/lisp/pred.jl
  67. #    jlisp-1.03/lisp/r4rs.jl
  68. #    jlisp-1.03/lisp/repl.jl
  69. #    jlisp-1.03/lisp/roman.jl
  70. #    jlisp-1.03/lisp/signal.jl
  71. #    jlisp-1.03/lisp/slib.jl
  72. #    jlisp-1.03/lisp/time.jl
  73. #    jlisp-1.03/lisp/unistd.jl
  74. #    jlisp-1.03/src/Makefile
  75. #    jlisp-1.03/src/align.c
  76. #    jlisp-1.03/src/alist.c
  77. #    jlisp-1.03/src/alloc.c
  78. #    jlisp-1.03/src/ball.c
  79. #    jlisp-1.03/src/debug.c
  80. #    jlisp-1.03/src/defproto.gen
  81. #    jlisp-1.03/src/dump-exech.c
  82. #    jlisp-1.03/src/error.c
  83. #    jlisp-1.03/src/eval.c
  84. #    jlisp-1.03/src/format.c
  85. #    jlisp-1.03/src/gc.c
  86. #    jlisp-1.03/src/hooks.c
  87. #    jlisp-1.03/src/init.c
  88. #    jlisp-1.03/src/jl_proto.h
  89. #    jlisp-1.03/src/jlconf.h
  90. #    jlisp-1.03/src/jlib.c
  91. #    jlisp-1.03/src/jlisp.c
  92. #    jlisp-1.03/src/jlisp.h
  93. #    jlisp-1.03/src/list.c
  94. #    jlisp-1.03/src/math.c
  95. #    jlisp-1.03/src/mdefproto.sed
  96. #    jlisp-1.03/src/mdefun.sed
  97. #    jlisp-1.03/src/mdefvar.sed
  98. #    jlisp-1.03/src/port.c
  99. #    jlisp-1.03/src/pred.c
  100. #    jlisp-1.03/src/print.c
  101. #    jlisp-1.03/src/reader.c
  102. #    jlisp-1.03/src/signals.c
  103. #    jlisp-1.03/src/string.c
  104. #    jlisp-1.03/src/symtab.c
  105. #    jlisp-1.03/src/unexec.c
  106. #    jlisp-1.03/src/unistd.c
  107. #    jlisp-1.03/src/weak.c
  108.  
  109. for x in  jlisp-1.03 jlisp-1.03/Doc jlisp-1.03/bin jlisp-1.03/etc jlisp-1.03/lisp jlisp-1.03/src ; do
  110.     if test ! -d $x ; then
  111.         echo "creating directory $x" ; mkdir $x
  112.     fi
  113. done
  114. if test -f jlisp-1.03/README -a "$1" != "-c" ; then
  115.     echo "will not overwrite jlisp-1.03/README"
  116. else
  117.     echo "    x - jlisp-1.03/README (995 bytes)"
  118.     sed 's/^X//' > jlisp-1.03/README << \CEST_TOUT
  119. X
  120. XREADME file for jlisp
  121. X=====================
  122. X
  123. Xjlisp is a lisp interpreter. It is heavily influenced from
  124. Xthe suchlikes of scheme, emacs-lisp, ...
  125. X
  126. XIt was designed to be easily used as an embedded interpreter
  127. X(which is what is was actually developed for)
  128. XIt is easily extended.
  129. X
  130. Xblah, blah, blah (see the Describble file for more)
  131. X
  132. XTo build:
  133. X========
  134. X
  135. XI have compiled this under SunOS and NetBSD, but there
  136. Xought be no trouble on elsewhats.
  137. X
  138. Xlook at the file src/jlconf.h, adjust if need be.
  139. Xedit the top-level Makefile as appropriate
  140. Xtype make
  141. Xtype make install
  142. Xtry it out, type ./jl
  143. Xsend in a bug report to weisberg@ee.rochester.edu
  144. X
  145. X
  146. Xdepending on your OS, you may get an error informing
  147. Xyou of a problem with re_comp and re_exec, if this is
  148. Xthe case, you have 3 choices:
  149. X
  150. X    get the GNU regex.c and regex.h and uncomment the
  151. X    REGEX line in src/MAKEFILE
  152. Xor
  153. X    delete the "match" code in src/string.c
  154. X    (but you will not be able to use the match function)
  155. Xor
  156. X    write your own re_comp and re_exec
  157. X
  158. X
  159. X
  160. CEST_TOUT
  161.     if test `wc -c < jlisp-1.03/README` -ne 995 ; then
  162.         echo "file jlisp-1.03/README has been corrupted (should be 995 bytes)"
  163.     fi
  164. fi
  165. if test -f jlisp-1.03/Acknowledgements -a "$1" != "-c" ; then
  166.     echo "will not overwrite jlisp-1.03/Acknowledgements"
  167. else
  168.     echo "    x - jlisp-1.03/Acknowledgements (417 bytes)"
  169.     sed 's/^X//' > jlisp-1.03/Acknowledgements << \CEST_TOUT
  170. X
  171. X
  172. XPortions of this distribution may (or may not) contain code developed by,
  173. Xderived from, copyrighted by,
  174. XContain words, phrases, symbols, or terms  copyrighted by, registered to,
  175. Xor trademarks of,
  176. XOr for some reason an acknowledgement felt neccessary for:
  177. X
  178. XUniversity of California, Berkeley and its contributors.
  179. XFree Software Foundation, Inc.
  180. XAT&T
  181. XSun MicroSystems Inc.
  182. XGeorge Carrette (siod)
  183. XAubrey Jaffer (scm)
  184. X
  185. CEST_TOUT
  186.     if test `wc -c < jlisp-1.03/Acknowledgements` -ne 417 ; then
  187.         echo "file jlisp-1.03/Acknowledgements has been corrupted (should be 417 bytes)"
  188.     fi
  189. fi
  190. if test -f jlisp-1.03/Describble -a "$1" != "-c" ; then
  191.     echo "will not overwrite jlisp-1.03/Describble"
  192. else
  193.     echo "    x - jlisp-1.03/Describble (2757 bytes)"
  194.     sed 's/^X//' > jlisp-1.03/Describble << \CEST_TOUT
  195. X
  196. Xjl is a Lisp derived interprter. It is heavily influenced
  197. Xby emacs-lisp, with noticable influences from the suchlikes
  198. Xof scheme, perl, c, ...
  199. X
  200. XDesigned to be used as an embedded interpreter, it is
  201. Xeasily extended and used with both C and C++.
  202. X(it was originally created for use with a large
  203. XC++/X11 based medical image analysis program)
  204. X
  205. XSome features:
  206. X
  207. XLike most lisps, it is dynamically scoped.
  208. X
  209. XHas non-local exits: catch, throw, unwind-protect.
  210. X
  211. XUNIX signal interface.
  212. X
  213. XRich set of i/o and system call interface.
  214. X
  215. XFile, pipe, and string I/O ports.
  216. X
  217. XA full math library.
  218. X
  219. XBuilt-in documentation (self-documenting, as they say)
  220. X
  221. XBuilt-in debugging support.
  222. X
  223. XMacros. including ' ` , ,@
  224. X
  225. XNumeric datatypes: integers, floats, doubles,
  226. X    [RSN bignums, and complex]
  227. X
  228. Xnumbers can be input/output in arbitrary radix
  229. X
  230. XMark and sweep GC.
  231. X
  232. X
  233. XNotes:
  234. X
  235. XAs in scheme, #f and () are distinct objects, and not eq.
  236. X
  237. XSymbol names may contain just about any characters except:
  238. X    ();# and whitespace
  239. X    . is permitted as the first character, but such symbols
  240. X    are reserved for internal use, and may cause unexpected results if used
  241. X
  242. Xsubstring takes start, length, not start, end
  243. X
  244. X
  245. XSome simple examples, to demonstrate the syntactical conventions
  246. X
  247. X(eq 'a 1)
  248. X=> #f
  249. X(equal "foo" "bar")
  250. X=> #f
  251. X(nullp foo)
  252. X=> #t
  253. X(intp 7)
  254. X=> #t
  255. X(set! a 1)
  256. X=> 1
  257. X(set-car! (cons 'foo 'bar) 'baz)
  258. X=> baz
  259. X; I am a comment
  260. X; defines may have an optional doctring
  261. X(define foo #('vector 'of "stuff"))
  262. X=> #<unspecified>
  263. X; lambda can handle two types of arglists:
  264. X(define foo "Documentaion for foo"
  265. X  (lambda (a b &optional c &rest d)
  266. X    (display a)))
  267. X=> #<unspecified>
  268. X(define bar (lambda arglist
  269. X  (display (car arglist))
  270. X  (bar (cdr arglist))))
  271. X
  272. X;or, more conviently, we can say:
  273. X(defun foo (a b &rest c)
  274. X  "A doc string"
  275. X  (if (boundp c)
  276. X    (foo (cdr c) a b (car c))))
  277. X
  278. X; macros are just like lambda, (but different)
  279. X(define foo "foo is macro!"
  280. X  (macro (a b &optional c)
  281. X    (if (boundp c)
  282. X      `(progn
  283. X          (set! c (+ a b))
  284. X          (display c))
  285. X      (display a))))
  286. X  
  287. X#| I am a comment that continues
  288. X   over several lines, followed by: |#
  289. X(defmac foo arglist "Another macro"
  290. X  (display arglist)
  291. X  arglist)
  292. X
  293. X(eval '(+ 1 2))
  294. X=> 3
  295. X
  296. X(catch 'eof
  297. X  (while #t
  298. X    (display (eval (read)))))
  299. X; the internals of read will throw 'eof at the appropriate time
  300. X
  301. X(read (open:read "file.jl"))
  302. X(getc (open:string "A string to read from"))
  303. X(putc (open:string "A string to write to") ?c)
  304. X(display foo (open:write "|sed s/foo/bar/"))
  305. X
  306. X(sqrt (+ (atanh 1.4) (atan2 x y)))
  307. X
  308. X(docstr foo)
  309. X=> "Another macro"
  310. X(debug-on-entry foo)
  311. X(cancel-debug-on-entry foo)
  312. X
  313. X#|
  314. X  the included libraries, the defun.list file,
  315. X  and builtin help (docstr symname) would be a good
  316. X  place to look for some more examples and help...
  317. X|#
  318. X
  319. X
  320. X
  321. X
  322. CEST_TOUT
  323.     if test `wc -c < jlisp-1.03/Describble` -ne 2757 ; then
  324.         echo "file jlisp-1.03/Describble has been corrupted (should be 2757 bytes)"
  325.     fi
  326. fi
  327. if test -f jlisp-1.03/Doc/Balls -a "$1" != "-c" ; then
  328.     echo "will not overwrite jlisp-1.03/Doc/Balls"
  329. else
  330.     echo "    x - jlisp-1.03/Doc/Balls (1066 bytes)"
  331.     sed 's/^X//' > jlisp-1.03/Doc/Balls << \CEST_TOUT
  332. X
  333. XBalls in JLisp
  334. X==============
  335. X
  336. X(what do you do with balls? catch and throw!...)
  337. X
  338. XNon-local exits are available uc]sing catch, throw, unwind-protect
  339. X
  340. X    (catch tag body...)
  341. X
  342. Xsets up a catch frame, and the body executed, if no throw
  343. Xis caught, its value is that of the body, if a throw
  344. Xis caught, the value given in the throw is returned
  345. X
  346. X    (throw tag [value])
  347. X
  348. Xjumps out of a catch frame with the matching tag (eqv)
  349. Xthe value given will be the value returned from the
  350. Xcatch, the default being #t
  351. X
  352. Xif no matching catch frame is found, throw will return #f
  353. X
  354. X    (unwind-protect now later...)
  355. X
  356. Xnow will be executed, and then later. if a throw causes
  357. Xan exit out of now, later will be executed anyway.
  358. Xit returns the result of now
  359. X
  360. X
  361. XThe internals will throw:
  362. X    'error        if an error is detected
  363. X    'eof        if an eof is read
  364. X
  365. X
  366. Xexample (untested):
  367. X
  368. X(if (catch 'party
  369. X      (unwind-protect
  370. X      (while (not (homep cows))
  371. X        (if (in-mood)
  372. X        (throw 'party)
  373. X          (stuff)))
  374. X    (display "Do me anyway!\n")
  375. X    (clean-up house)))
  376. X    (display "Caught a Party!\n")
  377. X  (display "No party.\n"))
  378. X
  379. X
  380. X
  381. X
  382. CEST_TOUT
  383.     if test `wc -c < jlisp-1.03/Doc/Balls` -ne 1066 ; then
  384.         echo "file jlisp-1.03/Doc/Balls has been corrupted (should be 1066 bytes)"
  385.     fi
  386. fi
  387. if test -f jlisp-1.03/Doc/Hooks -a "$1" != "-c" ; then
  388.     echo "will not overwrite jlisp-1.03/Doc/Hooks"
  389. else
  390.     echo "    x - jlisp-1.03/Doc/Hooks (313 bytes)"
  391.     sed 's/^X//' > jlisp-1.03/Doc/Hooks << \CEST_TOUT
  392. X
  393. XHooks in JLisp
  394. X==============
  395. X
  396. X
  397. Xas in emacs, we have hooks which will be run at
  398. Xparticular times
  399. X
  400. Xto add hooks:
  401. X
  402. X    (add-hooks 'foo-hooks thunk)
  403. X
  404. Xwhere thunk is a procedure requiring 0 arguments
  405. X
  406. Xand we run them by:
  407. X
  408. X    (run-hooks 'foo-hooks)
  409. X
  410. X
  411. XThe internals will use:
  412. X
  413. X    quit-hooks
  414. X    before-gc-hooks
  415. X    after-gc-hooks
  416. X
  417. CEST_TOUT
  418.     if test `wc -c < jlisp-1.03/Doc/Hooks` -ne 313 ; then
  419.         echo "file jlisp-1.03/Doc/Hooks has been corrupted (should be 313 bytes)"
  420.     fi
  421. fi
  422. if test -f jlisp-1.03/Doc/Ports -a "$1" != "-c" ; then
  423.     echo "will not overwrite jlisp-1.03/Doc/Ports"
  424. else
  425.     echo "    x - jlisp-1.03/Doc/Ports (694 bytes)"
  426.     sed 's/^X//' > jlisp-1.03/Doc/Ports << \CEST_TOUT
  427. X
  428. XPorts in JLisp
  429. X==============
  430. X
  431. Xports are the object we use for i/o
  432. X
  433. Xwe can open a file:
  434. X
  435. X    (open:read "filename")
  436. X    (open:write "foo.bar")
  437. X    (open:read/write "Glark.doc")
  438. X    (open:append "work.log")
  439. X
  440. Xor a pipe:
  441. X
  442. X    (open:read "| finger bob@host")
  443. X    (open:write "| mail bob@host")
  444. X
  445. Xor a string:
  446. X
  447. X    (open:string "A string to be read and written to")
  448. X
  449. Xi/o operations on a port:
  450. X
  451. X
  452. X    (read [port])
  453. X    (display [port])
  454. X    (write [port])        all read/write lisp forms
  455. X
  456. X    (getc port)
  457. X    (putc port char)
  458. X    (ungetc port char)    character at a time 
  459. X
  460. X    (flush port)
  461. X    (seek port offset)
  462. X    (tell port)        administrative tasks to ports
  463. X
  464. X
  465. Xports need not be expicitly closed (can't be actually)
  466. Xthey will be closed at exit or if GCed
  467. X
  468. CEST_TOUT
  469.     if test `wc -c < jlisp-1.03/Doc/Ports` -ne 694 ; then
  470.         echo "file jlisp-1.03/Doc/Ports has been corrupted (should be 694 bytes)"
  471.     fi
  472. fi
  473. if test -f jlisp-1.03/Doc/Signals -a "$1" != "-c" ; then
  474.     echo "will not overwrite jlisp-1.03/Doc/Signals"
  475. else
  476.     echo "    x - jlisp-1.03/Doc/Signals (432 bytes)"
  477.     sed 's/^X//' > jlisp-1.03/Doc/Signals << \CEST_TOUT
  478. X
  479. XSignal interface in JLisp
  480. X=========================
  481. X
  482. Xhandlers for all of the UNIX signals may be installed
  483. X(modulo any system restrictions)
  484. X
  485. X(install-signal-handler signo thunk)
  486. X
  487. Xsigno is the signal number, most of the common names
  488. Xare defined (SIGHUP, SIGINT, ...)
  489. X
  490. Xwhere thunk is a procedure (lambda, macro, ccode) requiring
  491. Xno arguments or may be:
  492. X
  493. X    (), SIG_IGN    to ignore the signal
  494. X    #t, SIG_DFL    use the system default handler
  495. X
  496. CEST_TOUT
  497.     if test `wc -c < jlisp-1.03/Doc/Signals` -ne 432 ; then
  498.         echo "file jlisp-1.03/Doc/Signals has been corrupted (should be 432 bytes)"
  499.     fi
  500. fi
  501. if test -f jlisp-1.03/Doc/numbers -a "$1" != "-c" ; then
  502.     echo "will not overwrite jlisp-1.03/Doc/numbers"
  503. else
  504.     echo "    x - jlisp-1.03/Doc/numbers (645 bytes)"
  505.     sed 's/^X//' > jlisp-1.03/Doc/numbers << \CEST_TOUT
  506. X
  507. XNumbers in Jlisp
  508. X=================
  509. X
  510. Xthe reader recognizes the following numeric formats:
  511. X
  512. X    #x12F0C            hexadecimal number
  513. X    #o377            octal number
  514. X    #b11010            binary number
  515. X    #d98765            decimal number
  516. X
  517. X    1234        a number the base determined by
  518. X            the current value of "%input-radix%"
  519. X
  520. X            %input-radix% may be set to any desired base
  521. X            in the range 2-36
  522. X
  523. X    1.23        a floating pt number, will also
  524. X            obey the base %input-radix%
  525. X
  526. X
  527. XOn output numbers will be output in the
  528. Xbase specified by "%output-radix%".
  529. X
  530. Xfloating pt numbers will have the form:
  531. X
  532. X    a.aaaa$eee
  533. X
  534. Xwhere the number is (a.aaaa * %output-radix% ** eee) (using %output-radix% based
  535. Xarithmetic)
  536. X
  537. X
  538. X
  539. X
  540. CEST_TOUT
  541.     if test `wc -c < jlisp-1.03/Doc/numbers` -ne 645 ; then
  542.         echo "file jlisp-1.03/Doc/numbers has been corrupted (should be 645 bytes)"
  543.     fi
  544. fi
  545. if test -f jlisp-1.03/Doc/strings -a "$1" != "-c" ; then
  546.     echo "will not overwrite jlisp-1.03/Doc/strings"
  547. else
  548.     echo "    x - jlisp-1.03/Doc/strings (512 bytes)"
  549.     sed 's/^X//' > jlisp-1.03/Doc/strings << \CEST_TOUT
  550. X
  551. XStrings & Characters in JLisp
  552. X================
  553. X
  554. XStrings are delimited by "
  555. X
  556. X    "I am a string"
  557. X
  558. Xstrings may contain special escaped characters preceded
  559. Xby a \
  560. X
  561. X    "Hello\32World\n"
  562. X
  563. X
  564. Xcharacters are read in as:
  565. X
  566. X    ?a        (the letter a)
  567. X
  568. Xchars may also conatin escaped characters:
  569. X
  570. X    ?\n        (newline)
  571. X
  572. X
  573. Xrecognized escapes are:
  574. X
  575. X    \n    newline
  576. X    \s    space
  577. X    \t    tab
  578. X    \r    return
  579. X    \b    backspace
  580. X    \f    form feed
  581. X    \v    vertical tab
  582. X    \a    bell
  583. X    \e    escape
  584. X    \0nnn    octal numbered char
  585. X    \xnnn    hexadecimal numbered char
  586. X    \nnn    decimal numbered char
  587. X
  588. X
  589. CEST_TOUT
  590.     if test `wc -c < jlisp-1.03/Doc/strings` -ne 512 ; then
  591.         echo "file jlisp-1.03/Doc/strings has been corrupted (should be 512 bytes)"
  592.     fi
  593. fi
  594. if test -f jlisp-1.03/Internals -a "$1" != "-c" ; then
  595.     echo "will not overwrite jlisp-1.03/Internals"
  596. else
  597.     echo "    x - jlisp-1.03/Internals (1424 bytes)"
  598.     sed 's/^X//' > jlisp-1.03/Internals << \CEST_TOUT
  599. X
  600. XObj:
  601. X..............................00    pointer to class1
  602. X.............................010    int
  603. X..........................000110    character
  604. X..........................001110    const sym
  605. X        ( #t #f () #<eof> #<unspecified> #<undefined> )
  606. X
  607. X..........................010110    (unused immediate bit patterns)
  608. X..........................011110    
  609. X..........................100110    
  610. X..........................101110    
  611. X..........................110110    
  612. X..........................111110    
  613. X
  614. X
  615. Xclass1:
  616. X
  617. X    car                cdr
  618. X...............................0  ...............................G    cons cell
  619. XppppppppppppppppppppxttttttttPG1  ................................
  620. X
  621. X    G = gc mark bit (GCBIT)
  622. X    P = gc protect bit (SDBIT)
  623. X    tttttttt = type (8bits)
  624. X    x = reserved for future use (=0)
  625. X    p = type dependant params (20bits)
  626. X
  627. Xtype:            cdr        params
  628. X
  629. Xfloat            float        (unused)
  630. Xdouble            double*        (unused)
  631. Xcomplex            complex*    (unused)
  632. Xstring            char*        length
  633. X                length will be <0 if it is a constant string
  634. X
  635. Xvector            Obj*        length
  636. Xenvvec            Obj*        length
  637. X    (same as a vector) contains chains of symboxes
  638. X
  639. Xbignum            short*        length
  640. Xsymbol            char*        length
  641. Xsymol box        SymBox*        (unused)
  642. Xfree cell        (next free cell)* (unused)
  643. Xc-code            Defun_Decl*    (unused)
  644. X
  645. Xcell box        Cell*        (unused)
  646. X    Cells in box:            
  647. X      [0]    num of cells        next box
  648. X      [1]    num free        next free
  649. X      [2]        first used cell
  650. X
  651. Xioport            FILE*        < subtype w r >
  652. Xclosure            (params . body)    <debugme>
  653. Xmacro            (params . body)    <debugme>
  654. X
  655. X
  656. CEST_TOUT
  657.     if test `wc -c < jlisp-1.03/Internals` -ne 1424 ; then
  658.         echo "file jlisp-1.03/Internals has been corrupted (should be 1424 bytes)"
  659.     fi
  660. fi
  661. if test -f jlisp-1.03/License -a "$1" != "-c" ; then
  662.     echo "will not overwrite jlisp-1.03/License"
  663. else
  664.     echo "    x - jlisp-1.03/License (818 bytes)"
  665.     sed 's/^X//' > jlisp-1.03/License << \CEST_TOUT
  666. XThis software is Copyright (c)  1994 Jeff Weisberg
  667. XPermission is granted to use, copy and distribute this software
  668. Xunder the following conditions:
  669. X
  670. X-    This is an alpha release. Do not expect much.
  671. X    Contact the author for a more recent version.
  672. X
  673. X-    This license covers the original software, as well as
  674. X    modified or derived works.
  675. X-    This is free software, no fee may be charged for this
  676. X    software, copies or derivations thereof.
  677. X-       This software may be distributed only in its original
  678. X    (unmodified) form and must include this file.
  679. X-    You may modify this software as you see fit, for personal
  680. X    use, but may not distribute the modified version.
  681. X-    This software is not to be used, for any purpose which
  682. X    may be considered illegal, immoral, or unethical.
  683. X-    This software is provided without warranty.
  684. CEST_TOUT
  685.     if test `wc -c < jlisp-1.03/License` -ne 818 ; then
  686.         echo "file jlisp-1.03/License has been corrupted (should be 818 bytes)"
  687.     fi
  688. fi
  689. if test -f jlisp-1.03/Makefile -a "$1" != "-c" ; then
  690.     echo "will not overwrite jlisp-1.03/Makefile"
  691. else
  692.     echo "    x - jlisp-1.03/Makefile (2594 bytes)"
  693.     sed 's/^X//' > jlisp-1.03/Makefile << \CEST_TOUT
  694. X
  695. X
  696. X    # $Id: Makefile,v 1.48 94/06/21 17:19:03 weisberg Exp Locker: weisberg $
  697. X
  698. Xjlversion = 1.03
  699. X
  700. Xprefix = /usr/local
  701. X
  702. X    # where the resultant binaries are installed
  703. Xbindir = $(prefix)/bin
  704. X
  705. Xlibdir = $(prefix)/lib
  706. X
  707. X    # where the lispcode will be
  708. Xlispdir = $(libdir)/jlisp/lisp
  709. X
  710. X    # where to place local lisp files
  711. Xlocallispdir = $(libdir)/jlisp/local-lisp
  712. X
  713. X    # where some helper files will be
  714. X    # and helpfiles, ...
  715. Xetcdir = $(libdir)/jlisp/etc
  716. X
  717. X    # the jlisp initialization code
  718. Xjlisp_init = $(lispdir)/init.jl
  719. X
  720. XBAKEXT = .bak
  721. X
  722. XINSTALL = install
  723. X
  724. XLISPOBJS = lisp/init.jl lisp/mrirc.jl
  725. X
  726. Xall: jl lispcode
  727. X
  728. Xlispcode: $(LISPOBJS)
  729. X
  730. Xjl: xxjl $(LISPOBJS)
  731. X    @echo "Dumping..."
  732. X    ./xxjl -e '(progn (unexec "jl" "xxjl") (quit))'
  733. X
  734. Xxxjl: _xxjl
  735. X_xxjl:
  736. X    cd src; $(MAKE) jl INIT_FILE="$(jlisp_init)" version=$(jlversion)
  737. X    ./bin/if-changed cp src/jl xxjl
  738. X
  739. Xlisp/init.jl: lisp/init.cf.jl configure.sed
  740. X    sed -f configure.sed lisp/init.cf.jl > lisp/init.jl
  741. X
  742. Xlisp/mrirc.jl: lisp/mrirc.cf.jl configure.sed
  743. X    sed -f configure.sed lisp/mrirc.cf.jl > lisp/mrirc.jl
  744. X
  745. Xjlisp.a: _jlispa
  746. X_jlispa:
  747. X    cd src; $(MAKE) jlisp.a STANDALONE=-DNOT_STAND_ALONE 
  748. X    ./bin/if-changed cp src/jlisp.a jlisp.a
  749. X
  750. Xinclude/defproto.h: src/defproto.h
  751. X    ./bin/if-changed cp src/defproto.h include/defproto.h
  752. X
  753. Xsrc/defproto.h:
  754. X    cd src; $(MAKE) defproto.h
  755. X
  756. Xconfigure.sed: 
  757. X    @-mv configure.sed configure.sed$(BAKEXT)
  758. X    @echo s@%SRCDIR%@.@g           >> configure.sed
  759. X    @echo s@%PREFIX%@$(prefix)@g   >> configure.sed
  760. X    @echo s@%BINDIR%@$(bindir)@g   >> configure.sed
  761. X    @echo s@%LIBDIR%@$(libdir)@g   >> configure.sed
  762. X    @echo s@%ETCDIR%@$(etcdir)@g   >> configure.sed
  763. X    @echo s@%LISPDIR%@$(lispdir)@g >> configure.sed
  764. X    @echo s@%LOCALLISP%@$(locallispdir)@g >> configure.sed
  765. X
  766. Xinstall: all install.dirs install.jl install.lisp 
  767. X
  768. Xinstall.dirs:
  769. X    -mkdir -p $(bindir) $(libdir) $(lispdir) $(locallispdir) $(etcdir)
  770. X
  771. Xinstall.jl: jl
  772. X    $(INSTALL) -m 555  jl        $(bindir)/jl
  773. X
  774. Xinstall.lisp: lispcode
  775. X    cp lisp/*.jl $(lispdir)
  776. X
  777. Xclean:
  778. X    -rm -f $(LISPOBJS) $(OBSLS) core a.out #*# include/cli-defvar.list include/cli-defun.list include/defproto.h
  779. X    cd src;  $(MAKE) clean
  780. X
  781. Xrealclean: clean
  782. X    -rm -f jl xxjl stamp *bak configure.sed
  783. X    cd src; $(MAKE) realclean
  784. X
  785. Xdepends:
  786. X    @echo making depends...
  787. X    cd src; $(MAKE) depends
  788. X
  789. XMakefile: stamp
  790. X    @echo making Makefile...
  791. X    @cp Makefile Makefile$(BAKEXT)
  792. X    @sed -n '1,/#END_[oO]F_MAKE/p' Makefile\
  793. X        | sed "s%^srcdir =.*\$$%srcdir = `pwd`%"  >Make.new
  794. X    @cat Make.new > Makefile
  795. X    @rm -f Make.new
  796. X
  797. Xstamp:
  798. X    touch stamp
  799. X
  800. Xdisk: realclean
  801. X    cd ..; tar cvf /dev/rfd0 jlisp-$(jlversion) 
  802. X
  803. X
  804. X# DO NOT remove following line!
  805. X#END_OF_MAKE
  806. X
  807. CEST_TOUT
  808.     if test `wc -c < jlisp-1.03/Makefile` -ne 2594 ; then
  809.         echo "file jlisp-1.03/Makefile has been corrupted (should be 2594 bytes)"
  810.     fi
  811. fi
  812. if test -f jlisp-1.03/ToDo -a "$1" != "-c" ; then
  813.     echo "will not overwrite jlisp-1.03/ToDo"
  814. else
  815.     echo "    x - jlisp-1.03/ToDo (112 bytes)"
  816.     sed 's/^X//' > jlisp-1.03/ToDo << \CEST_TOUT
  817. X
  818. X    IPC
  819. X    hashtables
  820. X    undefine ?
  821. X    logical fncs: ror rol
  822. X    bignums, complexnums
  823. X    OOP
  824. X
  825. X    finish format
  826. X        (~f ~e ~g)
  827. X
  828. X
  829. X
  830. CEST_TOUT
  831.     if test `wc -c < jlisp-1.03/ToDo` -ne 112 ; then
  832.         echo "file jlisp-1.03/ToDo has been corrupted (should be 112 bytes)"
  833.     fi
  834. fi
  835. if test -f jlisp-1.03/bin/if-changed -a "$1" != "-c" ; then
  836.     echo "will not overwrite jlisp-1.03/bin/if-changed"
  837. else
  838.     echo "    x - jlisp-1.03/bin/if-changed (88 bytes)"
  839.     sed 's/^X//' > jlisp-1.03/bin/if-changed << \CEST_TOUT
  840. X#! /bin/sh
  841. X
  842. Xexec 2> /dev/null
  843. X
  844. Xif cmp $2 $3; then
  845. X    echo $2 unchanged
  846. Xelse
  847. X    $1 $2 $3
  848. Xfi
  849. X
  850. CEST_TOUT
  851.     chmod +x jlisp-1.03/bin/if-changed
  852.     if test `wc -c < jlisp-1.03/bin/if-changed` -ne 88 ; then
  853.         echo "file jlisp-1.03/bin/if-changed has been corrupted (should be 88 bytes)"
  854.     fi
  855. fi
  856. if test -f jlisp-1.03/etc/example-.jlisprc -a "$1" != "-c" ; then
  857.     echo "will not overwrite jlisp-1.03/etc/example-.jlisprc"
  858. else
  859.     echo "    x - jlisp-1.03/etc/example-.jlisprc (314 bytes)"
  860.     sed 's/^X//' > jlisp-1.03/etc/example-.jlisprc << \CEST_TOUT
  861. X
  862. X;;;; an example .jlisprc file
  863. X
  864. X(set! load-path (append
  865. X                 (list (expand-filename "~/src/lisp"))
  866. X                 load-path))
  867. X(add-hook 'quit-hooks (lambda ()
  868. X                        (display "Bye Bye\n")))
  869. X(add-hook 'before-gc-hooks
  870. X          (lambda () (display "Garbage collecting...\n")))
  871. X
  872. CEST_TOUT
  873.     if test `wc -c < jlisp-1.03/etc/example-.jlisprc` -ne 314 ; then
  874.         echo "file jlisp-1.03/etc/example-.jlisprc has been corrupted (should be 314 bytes)"
  875.     fi
  876. fi
  877. if test -f jlisp-1.03/etc/example-emacs -a "$1" != "-c" ; then
  878.     echo "will not overwrite jlisp-1.03/etc/example-emacs"
  879. else
  880.     echo "    x - jlisp-1.03/etc/example-emacs (1755 bytes)"
  881.     sed 's/^X//' > jlisp-1.03/etc/example-emacs << \CEST_TOUT
  882. X
  883. X;;;; example emacs mode code for editing jlisp code
  884. X
  885. X(setq auto-mode-alist
  886. X      (append '(("\\.jl$"     . jeff-lisp-mode)
  887. X        ("/\\.jlisprc". jeff-lisp-mode))
  888. X          auto-mode-alist))
  889. X
  890. X
  891. X;;; jeff-lisp-mode is essentially emacs-lisp-mode with sugar on top...
  892. X
  893. X(defun jeff-lisp-mode ()
  894. X  "mode for editting jlisp code"
  895. X  (interactive)
  896. X  (emacs-lisp-mode)
  897. X  (setq mode-name "jeff-lisp")
  898. X  (setq major-mode 'jeff-lisp-mode)
  899. X    
  900. X  ;; get indent nice...
  901. X  (put 'do                'lisp-indent-hook 2)
  902. X  (put 'do*               'lisp-indent-hook 2)
  903. X  (put 'dolist            'lisp-indent-hook 1)
  904. X  (put 'dotimes           'lisp-indent-hook 1)
  905. X  (put 'case              'lisp-indent-hook 1)
  906. X  (put 'when              'lisp-indent-hook 1)
  907. X  (put 'unless            'lisp-indent-hook 1)
  908. X  (put 'while             'lisp-indent-hook 1)
  909. X  (put 'macro             'lisp-indent-hook 1)
  910. X  (put 'defmac            'lisp-indent-hook 'defun)
  911. X  
  912. X  (run-hooks 'jeff-lisp-mode-hook))
  913. X
  914. X;;; and of course it has to look nice hilit...
  915. X(hilit-set-mode-patterns
  916. X 'jeff-lisp-mode
  917. X '(
  918. X   (";.*" nil comment)
  919. X   ("#|" "|#" comment)
  920. X   (hilit-string-find ?\\ violetred-underline)
  921. X   ("^\\s *(def\\(un\\|mac\\)[ \t\n]" "\\()\\|nil\\)" defun)
  922. X   ("^\\s *(def\\(ine\\|var\\)" nil define)
  923. X   ("\\(#t\\|#f\\)" nil maroon)
  924. X   ("^\\s *(\\(provide\\|require\\|\\(auto\\)?load\\).*$" nil include)
  925. X   ("\\s *\\&\\(rest\\|optional\\)\\s *" nil keyword)
  926. X   ("(\\(let\\*?\\|cond\\|case\\|if\\|or\\|and\\|map\\(car\\|concat\\)\\|prog[n1*]?\\|while\\|lambda\\|macro\\|set\\([qf!]\\|-car\\|-cdr\\|s!\\)?\\|unwind-protect\\|catch\\|throw\\|error\\)[ \t\n]" 1 keyword)
  927. X   ("(\\(car\\|cdr\\|cons\\|nconc\\|list\\|vector\\|nth\\|eq\\|equal\\|eqv\\|eval\\|funcall\\|apply\\)[ \t\n]" 1 keyword)
  928. X   ))
  929. X
  930. X
  931. X
  932. CEST_TOUT
  933.     if test `wc -c < jlisp-1.03/etc/example-emacs` -ne 1755 ; then
  934.         echo "file jlisp-1.03/etc/example-emacs has been corrupted (should be 1755 bytes)"
  935.     fi
  936. fi
  937. if test -f jlisp-1.03/lisp/all-syms.jl -a "$1" != "-c" ; then
  938.     echo "will not overwrite jlisp-1.03/lisp/all-syms.jl"
  939. else
  940.     echo "    x - jlisp-1.03/lisp/all-syms.jl (1052 bytes)"
  941.     sed 's/^X//' > jlisp-1.03/lisp/all-syms.jl << \CEST_TOUT
  942. X
  943. X(defun all-syms ()
  944. X  ;; this is the deep-binding symtab version...
  945. X  (let* ((ce (current-enviornment))
  946. X     (sym-list ()))
  947. X
  948. X    (for-each (lambda (ev)
  949. X        ;; traverse the env vector
  950. X        (let ((i (length ev))
  951. X              (sc ()))
  952. X          (while (>= i 0)
  953. X            ;; follow symbox chains
  954. X            (set! sc (nth ev i))
  955. X            (while (nnullp sc)
  956. X              (set! sym-list (cons sc sym-list))
  957. X              (set! sc (symbox-chain-next sc)))
  958. X            (-- i))))
  959. X          ce)
  960. X    
  961. X  sym-list))
  962. X
  963. X(defun all-docs (sl)
  964. X  (let ((dl ()))
  965. X    (for-each (lambda (sym)
  966. X        (let ((ds (assq '.docstring (get-props sym))))
  967. X          (if ds
  968. X              (set! dl (acons sym (cdr ds) dl)))))
  969. X          sl)
  970. X    dl))
  971. X
  972. X(define *all-docs* #f)
  973. X
  974. X(defun appropos (huh)
  975. X  "(appropos keyword) find a function dealing with keyword"
  976. X  (let ((al ())
  977. X    (dl (or *all-docs* (set! *all-docs* (all-docs (all-syms))))))
  978. X
  979. X    (for-each (lambda (sd)
  980. X        (if (and (consp sd) (or (match huh (symbol->string (car sd)))
  981. X                    (match huh (cdr sd))))
  982. X            ;(set! al (cons sd al))))
  983. X            (format #t "~A ~A\n\n" (car sd) (cdr sd))))
  984. X          dl)
  985. X    al))
  986. X
  987. CEST_TOUT
  988.     if test `wc -c < jlisp-1.03/lisp/all-syms.jl` -ne 1052 ; then
  989.         echo "file jlisp-1.03/lisp/all-syms.jl has been corrupted (should be 1052 bytes)"
  990.     fi
  991. fi
  992. if test -f jlisp-1.03/lisp/autoload.jl -a "$1" != "-c" ; then
  993.     echo "will not overwrite jlisp-1.03/lisp/autoload.jl"
  994. else
  995.     echo "    x - jlisp-1.03/lisp/autoload.jl (1024 bytes)"
  996.     sed 's/^X//' > jlisp-1.03/lisp/autoload.jl << \CEST_TOUT
  997. X
  998. X;;;; Copyright (c) 1994 Jeff Weisberg
  999. X;;;; see the file "License"
  1000. X
  1001. X;;;; $Id: autoload.jl,v 1.9 94/08/11 15:50:39 weisberg Exp Locker: weisberg $
  1002. X
  1003. X(defmac autoload (func file &optional doc)
  1004. X  "(autoload function file [docstr]) declare function to be autoloaded from file
  1005. Xthe file will be automagically loaded in the event that the function is called
  1006. Xif func is already defined will do nothing"
  1007. X  (if (definedp func)
  1008. X      #f    ; already defined -- do nothing
  1009. X    (set! doc
  1010. X      (if (boundp doc)
  1011. X          (strcat "[Autoloaded] " doc)
  1012. X        "An undocumented, autoloaded function"))
  1013. X    `(defmac ,func argl
  1014. X       ,doc
  1015. X       (,'backquote
  1016. X    (progn
  1017. X      ;; we want the load to load into the env at the time of the autoload
  1018. X      ;; not when it is loaded...
  1019. X      (with-current-enviornment ',(cdr (current-enviornment))
  1020. X                    ;; current-env is of the autoload macro
  1021. X                    ;; cdr is calling env
  1022. X                    (load ,file))
  1023. X      (eval (cons ,func (,'quote (,'unquote argl)))))))))
  1024. X
  1025. X;(defmac autoload (func file &optional doc)
  1026. X ;  `(load ,file))
  1027. X
  1028. X
  1029. X
  1030. CEST_TOUT
  1031.     if test `wc -c < jlisp-1.03/lisp/autoload.jl` -ne 1024 ; then
  1032.         echo "file jlisp-1.03/lisp/autoload.jl has been corrupted (should be 1024 bytes)"
  1033.     fi
  1034. fi
  1035. if test -f jlisp-1.03/lisp/bind.jl -a "$1" != "-c" ; then
  1036.     echo "will not overwrite jlisp-1.03/lisp/bind.jl"
  1037. else
  1038.     echo "    x - jlisp-1.03/lisp/bind.jl (2494 bytes)"
  1039.     sed 's/^X//' > jlisp-1.03/lisp/bind.jl << \CEST_TOUT
  1040. X
  1041. X;;;; Copyright (c) 1994 Jeff Weisberg
  1042. X;;;; see the file "License"
  1043. X
  1044. X;;;; $Id: bind.jl,v 1.7 94/08/22 15:35:16 weisberg Exp Locker: weisberg $
  1045. X
  1046. X;;; just like the postscript function of the same name
  1047. X;;; goes thru' the function and looks up all calls it makes
  1048. X
  1049. X;; does not yet handle case, cond
  1050. X
  1051. X
  1052. X(defun bind:body ()
  1053. X  (while (nnullp body)
  1054. X    (set! form (car body))
  1055. X    (set! body (cdr body))
  1056. X    (set! newval (if (consp form)
  1057. X             (bind-form form deep)
  1058. X           form))
  1059. X    (set! newbody (append! newbody (cons newval ())))))
  1060. X
  1061. X(defun bind-form (body &optional deep)
  1062. X  (if (not (consp body))
  1063. X      body
  1064. X    (let* ((form (car body))
  1065. X       ;; bind car of list
  1066. X       
  1067. X       (newval (if (consp form)
  1068. X               (bind-form form deep)
  1069. X             (if (and (symbolp form) (definedp form))
  1070. X             (eval form)
  1071. X               form)))
  1072. X       
  1073. X       (newbody (cons 
  1074. X             (if (and (eq deep #t)
  1075. X                  (or (functionp newval) (macrop newval)))
  1076. X             ;; recurse into new function ?
  1077. X             (bind newval #t)
  1078. X               newval) ())))
  1079. X      (set! body (cdr body))
  1080. X      
  1081. X      (cond
  1082. X       ;; things to leave alone (for now...)
  1083. X       ((or (eq newval quote)
  1084. X        (eq newval backquote)
  1085. X        (eq newval case))        
  1086. X    (set! newbody (cons newval body)))
  1087. X
  1088. X       ;; bind let, let*
  1089. X       ((or (eq newval let)
  1090. X        (eq newval let*))
  1091. X    (let ((vars (car body))
  1092. X          (lbody (cdr body))
  1093. X          (newvars ()))
  1094. X      ;; do let vars
  1095. X      (while (nnullp vars)
  1096. X        (set! form (car vars))
  1097. X        (set! vars (cdr vars))
  1098. X        (if (nconsp form)
  1099. X        (set! newvars (append! newvars (cons form ())))
  1100. X          (set! newvars
  1101. X            (append! newvars
  1102. X                 (cons (list
  1103. X                    (car form)
  1104. X                    (car (bind-form (cdr form) deep)))
  1105. X                   ())))))
  1106. X      (set! newbody (append! newbody (cons newvars ())))
  1107. X      ;; do let body
  1108. X      (set! body lbody)
  1109. X      (bind:body)))
  1110. X       
  1111. X       ;; bind lambda, macro
  1112. X       ((or (eq newval lambda)
  1113. X        (eq newval macro))
  1114. X    (let ((arglist (car body))
  1115. X          (lbody (cdr body)))
  1116. X      (set! newbody (append! newbody (cons arglist ())))
  1117. X      (set! body lbody)
  1118. X      (bind:body)))
  1119. X       
  1120. X       (#t
  1121. X    (bind:body)))
  1122. X      newbody)))
  1123. X
  1124. X
  1125. X
  1126. X(defun bind (fnc &optional deep)
  1127. X  "(bind func [deep]) bind all function calls in func"
  1128. X
  1129. X  ;; currently bad things will happen if try to go deep on something recursive...
  1130. X  
  1131. X  (let* ((arglist (get-param-list fnc))
  1132. X     (body (get-body-list fnc))
  1133. X     (newbody (bind-form body deep))
  1134. X     (newfnc (cons (if (functionp fnc)
  1135. X               lambda
  1136. X             macro)
  1137. X               (cons arglist newbody))))
  1138. X    
  1139. X    ;; (print "Result: " newfnc ?\n)
  1140. X    (eval newfnc)))
  1141. X
  1142. X
  1143. X
  1144. X
  1145. CEST_TOUT
  1146.     if test `wc -c < jlisp-1.03/lisp/bind.jl` -ne 2494 ; then
  1147.         echo "file jlisp-1.03/lisp/bind.jl has been corrupted (should be 2494 bytes)"
  1148.     fi
  1149. fi
  1150. echo part00 done.
  1151. exit 0
  1152.  
  1153.  
  1154.