Permalink
Browse files

* change top-level syntax, started breeder

  • Loading branch information...
1 parent 6ef5a72 commit a72fd85b4f3c167f25dab4824151dc9aa121817b Alexander Kahl committed Nov 13, 2009
Showing with 80 additions and 35 deletions.
  1. +80 −35 src/target.lisp
View
@@ -60,7 +60,7 @@ all slot names/values as key/values from symbol list slots in object."
((name :reader name
:initarg :name
:initform (alexandria:required-argument :name))
- (dependencies :reader dependencies
+ (dependencies :accessor dependencies
:initarg :dependencies
:initform nil)
(env-slots :accessor env-slots
@@ -77,6 +77,8 @@ env-slots (list):
List of slots to lexically bind to the environment during an evolvable's
evolution"))
+;; (defmethod print-object... !
+
(defmethod initialize-instance :after ((evol evolvable) &rest initargs)
"Also register evolvable in the evol *environment*"
(declare (ignore initargs))
@@ -102,6 +104,37 @@ evolve."))
(defmethod evolve ((virt virtual)) t)
+;;; breeder class
+(defclass breeder (virtual)
+ ((of :reader :of
+ :initarg :of
+ :initform (alexandria:required-argument :of))
+ (spawn :reader :spawn
+ :initarg :spawn
+ :initform (alexandria:required-argument :spawn)))
+ (:documentation "Breeders are similar to virtuals but enable mass spawning of
+evolvables they auto-depend on so depending on a breeder saves from declaring
+lots of mutual evolvables manually.
+
+[slots]
+of (symbol):
+ The subtype of evolvable to breed.
+spawn (mixed):
+ Source of spawn evolvables. Can be a function or a list."))
+
+(defmethod initialize-instance :after ((breeder breeder) &rest initargs &key &allow-other-keys)
+ (let ((of (getf initargs :of))
+ (spawn (getf initargs :spawn))
+ (spawnargs (remove-from-plist initargs :name :of :spawn)))
+ (setf (dependencies breeder)
+ (mapcar #'(lambda (name)
+ (name
+ (apply #'make-instance of :name name spawnargs)))
+ (if (functionp spawn)
+ (funcall spawn)
+ spawn)))))
+
+
;;; definite class
(defclass definite (evolvable)
((rule :accessor rule
@@ -121,6 +154,41 @@ sourcefn (fn):
name"))
+;;; checkable class
+(defclass checkable (evolvable) ()
+ (:documentation "Evolvables derived from checkable provide a means to pre- and
+post-validate their evolution."))
+
+(defgeneric evolved-p (checkable)
+ (:documentation "Check that given evolution has been evolved properly"))
+
+(defmethod evolve :around ((evol checkable))
+ (or (evolved-p evol)
+ (call-next-method)))
+
+
+;;; file class
+(defclass file (checkable) ()
+ (:documentation "Files are targets that usually lead to evolution
+of... files. Their existence can easily be checked through their distinct
+pathnames."))
+
+(defmethod evolved-p ((file file))
+ (file-exists-p (cl-fad:pathname-as-file (name file))))
+
+
+;;; executable
+(defclass executable (file) ()
+ (:documentation "Executables are files that can be run on a machine's stack by
+either containing machince code themselves or referring to an interpreter for
+source code contained within. This class ensures its file is executable after
+creation."))
+
+(defmethod evolve :after ((exe executable))
+ (run-command (interpolate-commandline "chmod +x %@" :target (name exe))))
+
+
+;;;; Generic
;;; generic-transformator class
(defclass generic-transformator (definite)
((rule :accessor rule
@@ -136,6 +204,17 @@ honoring common quoting rules in line with Bourne shell syntax."))
:target (name trans) :sourcefn (sourcefn trans)))
+;;; generic class
+(defclass generic (generic-transformator file) ()
+ (:documentation "TODO"))
+
+
+;;; program class
+(defclass program (generic-transformator executable) ()
+ (:documentation "TODO"))
+
+
+;;;; Common Lisp Evolvables
;;; cl-transformator class
(defclass cl-transformator (definite)
((rule :accessor rule
@@ -156,40 +235,6 @@ Variable expansion is only performed against sourcefn's return forms."))
(name trans) *environment*))))
-;;; checkable class
-(defclass checkable (evolvable) ()
- (:documentation "Evolvables derived from checkable provide a means to pre- and
-post-validate their evolution."))
-
-(defgeneric evolved-p (checkable)
- (:documentation "Check that given evolution has been evolved properly"))
-
-(defmethod evolve :around ((evol checkable))
- (or (evolved-p evol)
- (call-next-method)))
-
-
-;;; file class
-(defclass file (checkable) ()
- (:documentation "Files are targets that usually lead to evolution
-of... files. Their existence can easily be checked through their distinct
-pathnames."))
-
-(defmethod evolved-p ((file file))
- (file-exists-p (cl-fad:pathname-as-file (name file))))
-
-
-;;; executable
-(defclass executable (file) ()
- (:documentation "Executables are files that can be run on a machine's stack by
-either containing machince code themselves or referring to an interpreter for
-source code contained within. This class ensures its file is executable after
-creation."))
-
-(defmethod evolve :after ((exe executable))
- (run-command (interpolate-commandline "chmod +x %@" :target (name exe))))
-
-
;;; cl-core class
(defclass cl-core (cl-transformator file)
((sourcefn :initform #'(lambda (rule)

0 comments on commit a72fd85

Please sign in to comment.