Initial Commit

This commit is contained in:
Emin Arslan 2025-01-21 14:20:13 +03:00
commit 06ef04aede
2 changed files with 49 additions and 0 deletions

45
messing-with-defun.lisp Normal file
View File

@ -0,0 +1,45 @@
;; This is just proof-of-concept.
;; This "library" is not meant to be seriously used - but it *can* be used
;;
;; The idea is this: what if you could, actually develop purely from the repl?
;; This idea comes from my (admittedly very briefly) playing with the interlisp medley
;; project. Essentially, you write things into the repl. Function definitions, packages,
;; whatever. Then you call, say, (save-definitions) or some function, and
;; everything you've defined gets saved into a file.
;; Obviously very possible, but I wanted to implement it myself.
;; whether this is a sane way to develop a program, or if this is desirable
;; in any way whatsoever, is left as an exercise for the reader.
(defpackage :program-saver
(:use :cl)
(:shadow :defun :defparameter :defvar))
(in-package :program-saver)
;; essentially, we shadow defun, defparameter etc.
;; and replace them with identical ones that add the definition
;; to a global list.
;; I should probably add some more stuff here -
;; everything is just saved as if they're all in the same file.
(defparameter *definitions* nil)
(defmacro defun (name lambda-list &body body)
(push (list 'defun name lambda-list body) *definitions*)
`(cl:defun ,name ,lambda-list ,@body))
(defmacro defvar (name val)
(push (list 'defvar name val) *definitions*)
`(cl:defvar ,name ,val))
(defmacro defparameter (name val)
(push (list 'defparameter name val) *definitions*)
`(cl:defparameter ,name ,val))
(cl:defun reset-defs ()
(setf *definitions* nil))
(cl:defun save-definitions (fname)
(with-open-file (out fname :direction :output)
(dolist (i (reverse *definitions*))
(print i out))))
; now just (use-package :program-saver)

4
messing-with-defun.lisp~ Normal file
View File

@ -0,0 +1,4 @@
(defpackage :my-test
(:use :cl)
(:shadow :defun))