mlang pushed a commit to branch externals/chess
in repository elpa.
commit 95d1decf4ca8e3830a50c5095ae7ff69bd577e3f
Author: Mario Lang
Date: Tue Jun 24 01:01:39 2014 +0200
Remove obsolete arguments and use more cl-check-type.
* chess-ply.el (chess-ply-p): New function.
Change `cl-assert' to `cl-check-type' based on this predicate.
(chess-ply-final-p): Only call `chess-ply-any-keyword' if we actually
found a preceding ply.
(chess-ply--add): Remove obsolte and unused arguments RANK-ADJ and
FILE-ADJ.
(chess-legal-plies): Adjust for `chess-ply--add' argument removal.
---
ChangeLog| 10 ++
chess-ply.el | 99 +
2 files changed, 60 insertions(+), 49 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6d042ec..e5b9a71 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2014-06-24 Mario Lang
+
+ * chess-ply.el (chess-ply-p): New function.
+ Change `cl-assert' to `cl-check-type' based on this predicate.
+ (chess-ply-final-p): Only call `chess-ply-any-keyword' if we actually
+ found a preceding ply.
+ (chess-ply--add): Remove obsolte and unused arguments RANK-ADJ and
+ FILE-ADJ.
+ (chess-legal-plies): Adjust for `chess-ply--add' argument removal.
+
2014-06-19 Eli Zaretskii
* chess.texi: Proofread and fix the manual. All the Next, Prev,
diff --git a/chess-ply.el b/chess-ply.el
index fd5dc21..46cba39 100644
--- a/chess-ply.el
+++ b/chess-ply.el
@@ -67,26 +67,29 @@
"Routines for manipulating chess plies."
:group 'chess)
+(defsubst chess-ply-p (ply)
+ (and (consp ply) (chess-pos-p (car ply
+
(defsubst chess-ply-pos (ply)
"Returns the base position associated with PLY."
- (cl-assert (listp ply))
+ (cl-check-type ply chess-ply)
(car ply))
(defsubst chess-ply-set-pos (ply position)
"Set the base position of PLY."
- (cl-assert (listp ply))
- (cl-assert (vectorp position))
+ (cl-check-type ply chess-ply)
+ (cl-check-type position chess-pos)
(setcar ply position))
(gv-define-simple-setter chess-ply-pos chess-ply-set-pos)
(defsubst chess-ply-changes (ply)
- (cl-assert (listp ply))
+ (cl-check-type ply chess-ply)
(cdr ply))
(defsubst chess-ply-set-changes (ply changes)
- (cl-assert (listp ply))
- (cl-assert (listp changes))
+ (cl-check-type ply chess-ply)
+ (cl-check-type changes list)
(setcdr ply changes))
(gv-define-simple-setter chess-ply-changes chess-ply-set-changes)
@@ -94,7 +97,7 @@
(defun chess-ply-any-keyword (ply &rest keywords)
"Return non-nil if PLY contains at least one of KEYWORDS."
(declare (side-effect-free t))
- (cl-assert (listp ply))
+ (cl-check-type ply chess-ply)
(catch 'found
(dolist (keyword keywords)
(if (memq keyword (chess-ply-changes ply))
@@ -102,14 +105,14 @@
(defun chess-ply-keyword (ply keyword)
(declare (side-effect-free t))
- (cl-assert (listp ply))
- (cl-assert (symbolp keyword))
+ (cl-check-type ply chess-ply)
+ (cl-check-type keyword symbol)
(let ((item (memq keyword (chess-ply-changes ply
(and item (if (not (cdr item)) t (cadr item)
(defun chess-ply-set-keyword (ply keyword &optional value)
- (cl-assert (listp ply))
- (cl-assert (symbolp keyword))
+ (cl-check-type ply chess-ply)
+ (cl-check-type keyword symbol)
(let* ((changes (chess-ply-changes ply))
(item (memq keyword changes)))
(if item
@@ -124,21 +127,21 @@
(defsubst chess-ply-source (ply)
"Returns the source square index value of PLY."
- (cl-assert (listp ply))
+ (cl-check-type ply chess-ply)
(let ((changes (chess-ply-changes ply)))
(and (listp changes) (not (symbolp (car changes)))
(car changes
(defsubst chess-ply-target (ply)
"Returns the target square index value of PLY."
- (cl-assert (listp ply))
+ (cl-check-type ply chess-ply)
(let ((changes (chess-ply-changes ply)))
(and (listp changes) (not (symbolp (car changes)))
(cadr changes
(defsubst chess-ply-next-pos (ply)
"Return the position that results from executing PLY."
- (cl-assert (listp ply))
+ (cl-check-type ply chess-ply)
(or (chess-ply-keyword ply :next-pos)
(let ((position (apply 'chess-pos-move
(chess-pos-copy (chess-ply-pos ply))
@@ -148,7 +151,7 @@
(defun chess-ply-castling-changes (position &optional long king-index)
"Create castling changes; this function supports Fischer Random castling."
- (cl-assert (vectorp position))
+ (cl-check-type position chess-pos)
(let* ((color (chess-pos-side-to-move position))
(king (or king-index (chess-pos-king-index position color)))
(rook (chess-pos-can-castle position (if color
@@ -174,7 +177,7 @@
(defvar chess-ply-checking-mate nil)
(defsubst chess-ply-create* (position)
- (cl-assert (vectorp position))
+ (cl-check-type position chess-pos)
(list position))
(defun chess-ply-create (posit