<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 22 Sep 2013, at 18:44, Steve Haflich <<a href="mailto:shaflich@gmail.com">shaflich@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">As language lawyer, I must point out that the proposed definition of assure is not compatible with places that are multiple-valued.  check-type is required to be (because the ANS mentions no exception about it) although I'm sure lots of implementations get this wrong.</div></blockquote><div><br></div><div>Another good point. However, this seems to suggest that it's not possible to implement ASSURE portably if the goal is to cover multiple values as well. Or am I missing something?</div><div><br></div><div>Pascal</div><div><br></div><blockquote type="cite"><div dir="ltr"><div>On Sun, Sep 22, 2013 at 6:53 AM, Pascal Costanza <span dir="ltr"><<a href="mailto:pc@p-cos.net" target="_blank">pc@p-cos.net</a>></span> wrote:</div></div><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
It seems to me that ASSERT and CHECK-TYPE are not as convenient as they could be. In particular, ISLISP seems to have a better alternative in ASSURE.<br>
<br>
ASSURE is easy to define:<br>
<br>
(defmacro assure (type form)<br>
  (let ((object (copy-symbol 'object)))<br>
    `(let ((,object ,form))<br>
       (check-type ,object ,type)<br>
       ,object)))<br>
<br>
The important difference is that the value of form is returned, which allows using ASSURE inline in expressions:<br>
<br>
(1+ (assure number x))<br>
<br>
…in place of the more lengthy:<br>
<br>
(progn<br>
  (check-type x number)<br>
  (1+ x))<br>
<br>
Is ASSURE, or something similar, part of any utility library, like Alexandria or the likes?<br>
<br>
On an unrelated note, I recently came up with the following utility macro which I found very useful:<br>
<br>
(defmacro assocf (item alist &optional default &rest keys &key test test-not key)<br>
  (declare (ignore test test-not key))<br>
  (let ((it (copy-symbol 'it)) (cons (copy-symbol 'cons)))<br>
    `(let* ((,it ,item) (,cons (assoc ,it ,alist ,@keys)))<br>
       (unless ,cons<br>
         (setf ,cons (cons ,it ,default)<br>
               ,alist (cons ,cons ,alist)))<br>
       ,cons)))<br>
<br>
Again, is something like this already part of some utility library?<br>
<br>
<br>
Thanks,<br>
Pascal<br>
<br>
--<br>
Pascal Costanza<br>
The views expressed in this email are my own, and not those of my employer.<br>
<br>
<br>
<br>
<br>
</blockquote></div><br></div>
</blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div>--</div><div>Pascal Costanza</div><div>The views expressed in this email are my own, and not those of my employer.</div><div><br></div></span><br class="Apple-interchange-newline">

</div>

<br></body></html>