From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: Re: srfi-9 record type checking Date: Wed, 02 Aug 2006 10:42:07 +1000 Message-ID: <8764hckly8.fsf@zip.com.au> References: <873behlvnw.fsf@zip.com.au> <87k67sudbj.fsf@laas.fr> <87pshkfw42.fsf@ossau.uklinux.net> <87lks8rudq.fsf@laas.fr> <87fyiat1wd.fsf@ossau.uklinux.net> <878xo1zfb0.fsf@laas.fr> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1154563653 28741 80.91.229.2 (3 Aug 2006 00:07:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 3 Aug 2006 00:07:33 +0000 (UTC) Cc: Neil Jerram Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Aug 03 02:07:30 2006 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G8QkI-0004Lb-RR for guile-devel@m.gmane.org; Thu, 03 Aug 2006 02:07:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G8QkI-0000uc-B4 for guile-devel@m.gmane.org; Wed, 02 Aug 2006 20:07:26 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G8QkD-0000s4-Tp for guile-devel@gnu.org; Wed, 02 Aug 2006 20:07:21 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G8QkB-0000ob-Qs for guile-devel@gnu.org; Wed, 02 Aug 2006 20:07:21 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G8QkB-0000oP-Ix for guile-devel@gnu.org; Wed, 02 Aug 2006 20:07:19 -0400 Original-Received: from [61.8.0.84] (helo=mailout1.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G8QnO-0000tx-Li for guile-devel@gnu.org; Wed, 02 Aug 2006 20:10:39 -0400 Original-Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.2.162]) by mailout1.pacific.net.au (Postfix) with ESMTP id 0604532811D; Thu, 3 Aug 2006 10:06:55 +1000 (EST) Original-Received: from localhost (ppp23A1.dyn.pacific.net.au [61.8.35.161]) by mailproxy1.pacific.net.au (8.13.4/8.13.4/Debian-3sarge1) with ESMTP id k7306oY4010914; Thu, 3 Aug 2006 10:06:53 +1000 Original-Received: from gg by localhost with local (Exim 3.36 #1 (Debian)) id 1G84oK-0002NI-00; Wed, 02 Aug 2006 10:42:08 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:6016 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable ludovic.courtes@laas.fr (Ludovic Court=E8s) writes: > > Neil Jerram writes: >> >> So on balance I don't think we need to provide complete compatibility >> within Guile here. > > Right, I think you convinced me. :-) In absense of violent objections I made the change below. I didn't do the same in the 1.6 branch, there I only amended the srfi-9 implementation. Is the local-eval stuff supposed to minimize the amount of environment or whatever captured by the returned functions? Guessing that's so I put the type check in a helper function. --=-=-= Content-Disposition: inline; filename=boot-9.scm.records.diff --- boot-9.scm.~1.356.2.1.~ 2006-05-09 10:34:24.000000000 +1000 +++ boot-9.scm 2006-08-02 08:40:13.000000000 +1000 @@ -429,13 +429,20 @@ (define (record-predicate rtd) (lambda (obj) (and (struct? obj) (eq? rtd (struct-vtable obj))))) +(define (%record-type-check rtd obj) ;; private helper + (or (eq? rtd (record-type-descriptor obj)) + (scm-error 'wrong-type-arg "%record-type-check" + "Wrong type record (want `~S'): ~S" + (list (record-type-name rtd) obj) + #f))) + (define (record-accessor rtd field-name) (let* ((pos (list-index (record-type-fields rtd) field-name))) (if (not pos) (error 'no-such-field field-name)) (local-eval `(lambda (obj) - (and (eq? ',rtd (record-type-descriptor obj)) - (struct-ref obj ,pos))) + (%record-type-check ',rtd obj) + (struct-ref obj ,pos)) the-root-environment))) (define (record-modifier rtd field-name) @@ -443,8 +450,8 @@ (if (not pos) (error 'no-such-field field-name)) (local-eval `(lambda (obj val) - (and (eq? ',rtd (record-type-descriptor obj)) - (struct-set! obj ,pos val))) + (%record-type-check ',rtd obj) + (struct-set! obj ,pos val)) the-root-environment))) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel --=-=-=--