[Bese-devel] declarations

Larry D'Anna smoof-ra at elder-gods.org
Mon Aug 1 18:50:33 UTC 2005


* Larry D'Anna (smoof-ra at elder-gods.org) [050727 11:13]:
> (sorry for sending this to you twice marco)
> 
> * Marco Baringer (mb at bese.it) [050727 01:26]:
> > Larry D'Anna <smoof-ra at elder-gods.org> writes:
> > 
> > > Marco: could you have walk-form not throw away declarations?  Or would
> > > you accept a patch to that effect?
> > 
> > no problem, where do you want me to put them? is a new slot on
> > implicit-progn enough or should be go all the way and store them along
> > with the variables/functions?
> 
> A new slot on implicit-progn is fine for what I'm doing.  Thanks!

Here's a patch.

       --larry 

-------------- next part --------------

New patches:

[initial support for remembering declarations
smoof-ra at elder-gods.org**20050801184329
 
 this patch adds a mixin called implicit-progn-with-declare-mixin and 
 uses it instead of implicit-progn-mixin in all the places that allow declares.
 It has slot which should contain a list of the declares at the top of the 
 implicit-progn.  This patch doesn't do anything clever with the declares, 
 it just creates declaration-form objects and points their source slots 
 at the original declares, however it would be easy to modify parse-declaration
 to generate more usefull declaration objects.
 
] {
hunk ./src/walk.lisp 117
+(defclass implicit-progn-with-declare-mixin (implicit-progn-mixin)
+  ((declares :accessor declares :initarg :declares)))
+
hunk ./src/walk.lisp 123
+(defmacro multiple-value-setf (places form)
+  (let ((names (loop for place in places collect (gensym))))
+    `(multiple-value-bind ,names ,form
+       ,@(loop for name in names for place in places if (null place) collect `(declare (ignore ,name)))
+	 (setf ,@(loop
+		    for name in names
+		    for place in places
+		    if place collect place
+		    if place collect name)))))
+
hunk ./src/walk.lisp 134
-  (let ((documentation nil))
+  (let ((documentation nil) 
+	(decl nil)
+	(decls nil))
hunk ./src/walk.lisp 138
-             (return-from split-body (values body env documentation))))
+             (return-from split-body (values body env documentation decls))))
hunk ./src/walk.lisp 147
-                            (setf env (parse-declaration dec env))))
+                            (multiple-value-setf (env decl) (parse-declaration dec env))
+			    (when decl
+			      (push decl decls))))
hunk ./src/walk.lisp 170
+(defclass declaration-form (form)
+  ())
+
hunk ./src/walk.lisp 204
-  environment)
+  (values environment declaration))
hunk ./src/walk.lisp 207
-  (multiple-value-bind (body env docstring)
+  (multiple-value-bind (body env docstring declarations)
hunk ./src/walk.lisp 212
-            docstring)))
+            docstring
+	    declarations)))
hunk ./src/walk.lisp 306
-(defclass lambda-function-form (function-form implicit-progn-mixin)
+(defclass lambda-function-form (function-form implicit-progn-with-declare-mixin)
hunk ./src/walk.lisp 363
-      (setf (body func) (walk-implict-progn func (cddr form) env :declare t))
+      (multiple-value-setf ((body func) nil (declares func)) (walk-implict-progn func (cddr form) env :declare t))
hunk ./src/walk.lisp 503
-(defclass function-binding-form (form binding-form-mixin implicit-progn-mixin)
+(defclass function-binding-form (form binding-form-mixin implicit-progn-with-declare-mixin)
hunk ./src/walk.lisp 522
-      (setf (body flet) (walk-implict-progn flet
-                                            body
-                                            (loop
-                                               with env = env
-                                               for (name . lambda) in (binds flet)
-                                               do (setf env (register env :flet name lambda))
-                                               finally (return env))
-                                            :declare t)))))
+      (multiple-value-setf ((body flet) nil (declares flet))
+			   (walk-implict-progn flet
+					       body
+					       (loop
+						  with env = env
+						  for (name . lambda) in (binds flet)
+						  do (setf env (register env :flet name lambda))
+						  finally (return env))
+					       :declare t)))))
hunk ./src/walk.lisp 562
-(defclass variable-binding-form (form binding-form-mixin implicit-progn-mixin)
+(defclass variable-binding-form (form binding-form-mixin implicit-progn-with-declare-mixin)
hunk ./src/walk.lisp 578
-    (setf (body let) (walk-implict-progn let (cddr form) env :declare t))))
+    (multiple-value-setf ((body let) nil (declares let)) (walk-implict-progn let (cddr form) env :declare t))))
hunk ./src/walk.lisp 588
-    (setf (binds let*) (nreverse (binds let*))
-          (body let*) (walk-implict-progn let* (cddr form) env :declare t))))
+    (setf (binds let*) (nreverse (binds let*)))
+    (multiple-value-setf ((body let*) nil (declares let*)) (walk-implict-progn let* (cddr form) env :declare t))))
hunk ./src/walk.lisp 593
-(defclass locally-form (form implicit-progn-mixin)
+(defclass locally-form (form implicit-progn-with-declare-mixin)
hunk ./src/walk.lisp 598
-    (setf (body locally) (walk-implict-progn locally (cdr form) env :declare t))))
+    (multiple-value-setf ((body locally) nil (declares locally)) (walk-implict-progn locally (cdr form) env :declare t))))
hunk ./src/walk.lisp 602
-(defclass macrolet-form (form binding-form-mixin implicit-progn-mixin)
+(defclass macrolet-form (form binding-form-mixin implicit-progn-with-declare-mixin)
hunk ./src/walk.lisp 612
-    (setf (binds macrolet) (nreverse (binds macrolet))
-          (body macrolet) (walk-implict-progn macrolet (cddr form) env :declare t))))
+    (setf (binds macrolet) (nreverse (binds macrolet)))
+    (multiple-value-setf ((body macrolet) nil (declares macrolet)) (walk-implict-progn macrolet (cddr form) env :declare t))))
hunk ./src/walk.lisp 685
-(defclass symbol-macrolet-form (form binding-form-mixin implicit-progn-mixin)
+(defclass symbol-macrolet-form (form binding-form-mixin implicit-progn-with-declare-mixin)
}

Context:

[Call the property :FEATURES, not FEATURES
Marco Baringer <mb at bese.it>**20050729103229] 
[Rename asdf property version to features, add "cps-interpreter"
Marco Baringer <mb at bese.it>**20050728120238] 
[dont need to register allow-other-keys because its not a binding
smoof-ra at elder-gods.org**20050727153603] 
[fixed type name mismatch for allow-other-keys-function-arguement-form
smoof-ra at elder-gods.org**20050727152456] 
[defmethod arguments should be ignorable, not ignore (openmcl warns whenever you ignore a specialized argument)
Marco Baringer <mb at bese.it>**20050726090308] 
[Typo in extract-argument-names
Marco Baringer <mb at bese.it>**20050726090256] 
[Fix generation of defmethod froms from defmethod/cc; added tests
Marco Baringer <mb at bese.it>**20050726085226] 
[Fix handling of optional arguments in apply-cps-lambda
Marco Baringer <mb at bese.it>**20050726085155] 
[More tests
Marco Baringer <mb at bese.it>**20050723133158] 
[Fix a bug in the handling of the case when LOOKUP finds a value for a name but the value is NIL
Marco Baringer <mb at bese.it>**20050723133106] 
[Export the symbol KALL
Marco Baringer <mb at bese.it>**20050723133052] 
[Change the test for constant-form'ness in walk.lisp
Marco Baringer <mb at bese.it>**20050723113019] 
[Extend the walker to handle #'(setf foo) function names
Marco Baringer <mb at bese.it>**20050723104431] 
[Fix bug in the lambda generated for method forms
Marco Baringer <mb at bese.it>**20050720144450] 
[Added ignore declarations to defun/cc and defmethod/cc to make the compiler happy
Marco Baringer <mb at bese.it>**20050720110112] 
[Temporarily comment out the log tests
Marco Baringer <mb at bese.it>**20050720092312] 
[Rename (optional|keyword|rest)-argument-form classes to include the -form suffix
Marco Baringer <mb at bese.it>**20050720092124] 
[Allow defun/cc defined functions te be called outside of a with-call/cc
Marco Baringer <mb at bese.it>**20050720091826] 
[Added support for &optional arguments in cps closures
Marco Baringer <mb at bese.it>**20050720091658] 
[Added defgeneric/cc
Marco Baringer <mb at bese.it>**20050719153441] 
[Move the error checking code for lambda arguments into apply, not lambda (in cps interpreter)
Marco Baringer <mb at bese.it>**20050719153121] 
[More cps tests
Marco Baringer <mb at bese.it>**20050719152327] 
[Fix openmcl's definition of lexical-variables to deal with ccl::definition-environment
Marco Baringer <mb at bese.it>**20050719152230] 
[Added support to the cps interpreter forl communicating with lexical variables
Marco Baringer <mb at bese.it>**20050707094608] 
[walk.lisp depends on lexenv.lisp
Marco Baringer <mb at bese.it>**20050707093140] 
[added support for walking local varibales in the lexical environment
Marco Baringer <mb at bese.it>**20050707093027
 
 this applies to all those variables defined the envorinment object
 grabbed via an &environment macro argument. 
 
] 
[mistyped #+openmcl in lexenv.lisp
Marco Baringer <mb at bese.it>**20050707092959] 
[added src/lexenv.lisp to arnesi.asd
Marco Baringer <mb at bese.it>**20050707091127] 
[Rename src/environment.lisp
Marco Baringer <mb at bese.it>**20050707091114] 
[Initial version of environment.lisp
Marco Baringer <mb at bese.it>**20050707091019] 
[Minor docstring fixup for with-call/cc
Marco Baringer <mb at bese.it>**20050707090619] 
[Big patch including all the cps interpreter stuff upto now
Marco Baringer <mb at bese.it>**20050707083739] 
[Fix bug in handling of defclass-struct's :predicate option
Marco Baringer <mb at bese.it>**20050706105324] 
[Initial Import
Marco Baringer <mb at bese.it>**20050706101657
 This import moves arnesi from arch to darcs. Nothing has actually changed since 
 bese-2004 at common-lisp.net/arnesi--dev--1.4--patch-14
] 
[added arch stuff to boring file
Marco Baringer <mb at bese.it>**20050706101630] 
[Setup boring file
Marco Baringer <mb at bese.it>**20050706100535] 
Patch bundle hash:
27538f2839b9eae10fc6c01ed7e15e455a4ffdfe


More information about the bese-devel mailing list