File: test.lisp

package info (click to toggle)
source-highlight 3.1.8-1.2~deb9u1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 10,224 kB
  • sloc: sh: 11,709; cpp: 10,226; ansic: 9,521; makefile: 1,902; lex: 1,200; yacc: 1,021; php: 213; perl: 211; awk: 98; erlang: 94; lisp: 90; java: 75; ruby: 69; python: 61; asm: 43; ada: 36; ml: 29; haskell: 27; xml: 23; cs: 11; sql: 8; tcl: 7; sed: 4
file content (40 lines) | stat: -rw-r--r-- 1,367 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
;;;; Test file for Lisp
;;;; A simple test file

(defpackage :foobar (:use :common-lisp-user :common-lisp))
  
(in-package :foobar)
(export '(new-obj mapobj parent call-if-exists ?call
	  call super super-if-exists ?super slot-val
	  slot-obj mset meth meth-func func-meth
	  this meth-owner meth-name
	  set-original-slot *foo-version*
	  *print-foo-objects-verbosely*))

(defconstant *foobar-version* 3 "Foobar's Version Number")

(defparameter *print-foobar-objects-verbosely* nil)

(defmacro definline (name &rest stuff)
  "Defines a function and declares it to be inlined"  ;; convenient, no?
  `(progn (declaim (inline ,name))
	  (defun ,name ,@stuff)))

(defstruct (foobar-object (:print-object print-foobar-object)) slots parent)

  (defun mapobj (func obj &optional (deeply nil))
    "Maps FUNC over all of the slots in OBJ.  FUNC must take THREE
arguments: (1) the object defining the slot, (2) the slot name.
That is, only one slot
is mapped for a given slot name.  nil is returned."
    (simple-error-check obj

;;; OTHER STUFF INSIDE A METHOD
;;; @  macro
;;;     Forms: @var               Expands to (slot-val 'var this)
;;;            @(meth ... )       Expands to (call 'meth this ... )
;;; @? macro
;;;     Form:  @?(meth ... )      Expands to (?call 'meth this ... )
;;; #@ macro
;;;     Form:  #@meth             Expands to (meth-func 'meth this)