Skip to content

Commit dbcf744

Browse files
committed
[int] some more minor refactorings
1 parent 83f918e commit dbcf744

File tree

7 files changed

+36
-37
lines changed

7 files changed

+36
-37
lines changed

polymorphic-functions-lite.asd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(asdf:defsystem "polymorphic-functions-lite"
22
:license "MIT"
3-
:version "0.5.0" ; beta
3+
:version "0.5.1" ; beta
44
:author "Shubhamkar Ayare (shubhamayare@yahoo.co.in)"
55
:description "Variant of polymorphic-functions with no support for static dispatch. This lets it have minimal dependencies."
66
:depends-on ("alexandria"

polymorphic-functions.asd

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(asdf:defsystem "polymorphic-functions"
22
:license "MIT"
3-
:version "0.5.0" ; beta
3+
:version "0.5.1" ; beta
44
:author "Shubhamkar Ayare (shubhamayare@yahoo.co.in)"
55
:description "Type based dispatch for Common Lisp"
66
:depends-on ("polymorphic-functions-lite"
@@ -14,10 +14,11 @@
1414
(:file "conditions" :depends-on ("polymorph-compiler-macro"))
1515
(:file "compiler-macro" :depends-on ("conditions"))
1616
#+sbcl
17-
(:file "sbcl-transform" :depends-on ("conditions"))
17+
(:file "sbcl-deftransform" :depends-on ("conditions"))
1818
(:file "dispatch" :depends-on ("conditions"
1919
"compiler-macro"
20-
#+sbcl "sbcl-transform"))
20+
#+sbcl
21+
"sbcl-deftransform"))
2122
(:file "misc-tests" :depends-on ("dispatch"))
2223
(:file "benchmark" :depends-on ("misc-tests")))
2324
:perform (test-op (o c)

src/ensure-type-form.lisp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,3 @@ as well as the type enhanced using TYPE."
172172
(values `(with-return-type ,type
173173
(block ,block-name (locally ,@body)))
174174
type)))
175-
176-

src/lambda-lists/base.lisp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,3 @@ of the following types:~% ~S~% ~S"
240240
proclaimation
241241
`(handler-bind ((warning #'muffle-warning))
242242
,proclaimation))))
243-

src/lambda-lists/parameters.lisp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -130,36 +130,6 @@
130130
normalized-list)))
131131
(nreverse normalized-list)))
132132

133-
(defun sort-untyped-lambda-list (untyped-lambda-list)
134-
"Sorts keyword arguments (if any) according to STRING<"
135-
(if (member '&key untyped-lambda-list)
136-
(let* ((key-position (position '&key untyped-lambda-list)))
137-
(append (subseq untyped-lambda-list 0 key-position)
138-
'(&key)
139-
(sort (subseq untyped-lambda-list (1+ key-position))
140-
#'string<
141-
:key (lambda (param)
142-
(if (and (listp param)
143-
(null (cddr param)))
144-
(car param)
145-
param)))))
146-
untyped-lambda-list))
147-
148-
(defun sort-typed-lambda-list (typed-lambda-list)
149-
"Sorts keyword arguments (if any) according to STRING<"
150-
(if (member '&key typed-lambda-list)
151-
(let ((key-position
152-
(position '&key
153-
typed-lambda-list)))
154-
(append (subseq typed-lambda-list
155-
0 key-position)
156-
'(&key)
157-
(sort (subseq typed-lambda-list
158-
(1+ key-position))
159-
#'string<
160-
:key #'caar)))
161-
typed-lambda-list))
162-
163133
(def-test normalize-typed-lambda-list (:suite lambda-list)
164134
(5am:is-true (equal '((a t))
165135
(normalize-typed-lambda-list '(a))))
@@ -196,6 +166,36 @@
196166
(is (equal '(a &key c) (untyped-lambda-list '((a number) &key ((c string))))))
197167
(is (equal '(a &rest args) (untyped-lambda-list '((a number) &rest args)))))
198168

169+
(defun sort-untyped-lambda-list (untyped-lambda-list)
170+
"Sorts keyword arguments (if any) according to STRING<"
171+
(if (member '&key untyped-lambda-list)
172+
(let* ((key-position (position '&key untyped-lambda-list)))
173+
(append (subseq untyped-lambda-list 0 key-position)
174+
'(&key)
175+
(sort (subseq untyped-lambda-list (1+ key-position))
176+
#'string<
177+
:key (lambda (param)
178+
(if (and (listp param)
179+
(null (cddr param)))
180+
(car param)
181+
param)))))
182+
untyped-lambda-list))
183+
184+
(defun sort-typed-lambda-list (typed-lambda-list)
185+
"Sorts keyword arguments (if any) according to STRING<"
186+
(if (member '&key typed-lambda-list)
187+
(let ((key-position
188+
(position '&key
189+
typed-lambda-list)))
190+
(append (subseq typed-lambda-list
191+
0 key-position)
192+
'(&key)
193+
(sort (subseq typed-lambda-list
194+
(1+ key-position))
195+
#'string<
196+
:key #'caar)))
197+
typed-lambda-list))
198+
199199
(declaim (ftype (function (list list) polymorph-parameters)
200200
make-polymorph-parameters-from-lambda-lists))
201201
(defun make-polymorph-parameters-from-lambda-lists (polymorphic-function-lambda-list

src/nonlite/ensure-type-form.lisp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(in-package :polymorphic-functions)
22

33
(defmacro with-return-type-in-env ((&key variable declare) return-type &body body)
4+
;; We put the &BODY only for good indentation
45
"Returns two values: a form that has ASSERTs with SIMPLE-TYPE-ERROR to check the type
56
as well as the type enhanced using TYPE."
67
(declare (optimize debug))

0 commit comments

Comments
 (0)