diff options
authorGravatar Pouar <pouar@pouar.net>2020-07-14 15:03:29 -0500
committerGravatar Pouar <pouar@pouar.net>2020-07-14 17:56:43 -0500
commit352fab74c9dadf1e0361c256b4ea9c9e3e124439 (patch)
parentbug fixes (diff)
type declarations
3 files changed, 8 insertions, 2 deletions
diff --git a/core/libexec.lisp b/core/libexec.lisp
index 388bc89..4d04f14 100644
--- a/core/libexec.lisp
+++ b/core/libexec.lisp
@@ -185,6 +185,7 @@
(declaring fixnum for j upfrom 0)
(when (typep i type)
(collect j))))
+(declaim (ftype (function ((or list symbol)) (values boolean &optional)) finished-events unfinished-events))
(defunassert finished-events (events)
(events (or list symbol))
(iter (declaring (or list symbol) for event in (a:ensure-list events))
@@ -371,7 +372,7 @@
(let ((*query-io* (clim:frame-query-io frame)))
(read-char *query-io*))))))))
-(declaim (ftype (function ((or symbol list)) list) trigger-event))
+(declaim (ftype (function ((or symbol list)) (values list &optional)) trigger-event))
(defunassert trigger-event (event-ids)
(event-ids (or symbol list))
(iter (declaring symbol for event-id in (a:ensure-list event-ids))
diff --git a/core/structs.lisp b/core/structs.lisp
index 3c89ff5..53d29b3 100644
--- a/core/structs.lisp
+++ b/core/structs.lisp
@@ -1,10 +1,11 @@
;;;; -*- mode: Common-Lisp; sly-buffer-package: "yadfa"; coding: utf-8-unix; -*-
(in-package :yadfa)
+(declaim (inline make-action action-documentation action-lambda action-p))
(defstruct action
"An action for a prop or item"
(documentation nil :type (or null simple-string))
(lambda '(lambda (prop))
- :type (or list symbol function)))
+ :type coerced-function))
(defmethod documentation ((x action) (doc-type (eql t)))
(action-documentation x))
(defmethod describe-object ((object action) stream)
diff --git a/core/util.lisp b/core/util.lisp
index ccdbfb2..2814fae 100644
--- a/core/util.lisp
+++ b/core/util.lisp
@@ -15,8 +15,10 @@
(defmacro do-push (item &rest places)
(a:once-only (item)
`(progn ,@(loop for place in places collect `(push ,item ,place)))))
+(declaim (ftype (function (unsigned-byte sequence) sequence) remove-nth))
(defun remove-nth (n sequence)
(remove-if (constantly t) sequence :start n :count 1))
+(declaim (ftype (function (list t unsigned-byte) list)))
(defun insert (list value n)
(if (<= n 0)
(cons value list)
@@ -35,6 +37,7 @@ the result of calling @code{SUSTITUTE} with @var{OLD}, @var{NEW}, place, and the
"Modify-macro for @code{REMOVE-IF}. Sets place designated by the first argument to
the result of calling @code{REMOVE-IF} with @var{TEST}, place, and the @var{KEYWORD-ARGUMENTS}.")
+(declaim (ftype (function (real real) real) random-from-range))
(defun random-from-range (start end)
(+ start (random (+ 1 (- end start)))))
(defun type-specifier-p (type-specifier)
@@ -60,6 +63,7 @@ the result of calling @code{REMOVE-IF} with @var{TEST}, place, and the @var{KEYW
(and (listp type-specifier)
(typep (car type-specifier) '(and symbol (not keyword))))))
+(declaim (ftype (function (t) (or null function)) coerced-function-p))
(defun coerced-function-p (form)
"checks whether the type is a lambda expression or function"
(handler-case (coerce form 'function)