From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: Functional record =?utf-8?B?4oCcc2V0dGVyc+KAnQ==?= Date: Mon, 09 Apr 2012 11:55:47 -0700 Message-ID: <87ty0s91l8.fsf@pobox.com> References: <871unxhi74.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1333997761 6974 80.91.229.3 (9 Apr 2012 18:56:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 9 Apr 2012 18:56:01 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Apr 09 20:56:01 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SHJku-0000Wo-NA for guile-devel@m.gmane.org; Mon, 09 Apr 2012 20:56:00 +0200 Original-Received: from localhost ([::1]:48988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SHJku-0004Qx-5l for guile-devel@m.gmane.org; Mon, 09 Apr 2012 14:56:00 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SHJkr-0004Qa-EK for guile-devel@gnu.org; Mon, 09 Apr 2012 14:55:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SHJkp-0005y4-Bs for guile-devel@gnu.org; Mon, 09 Apr 2012 14:55:57 -0400 Original-Received: from a-pb-sasl-sd.pobox.com ([74.115.168.62]:64237 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SHJkp-0005xU-2p; Mon, 09 Apr 2012 14:55:55 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 6FA9793D1; Mon, 9 Apr 2012 14:55:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=vcDl/PPU32oj Qefoan93FbA3Eus=; b=A6FKRe1Y9VdtqKgh3b21Ab8fR1U9eETyVX8eYfl4KsOv eUxIL9nse8JfgjqPkmvbbW6Fezn590kw8Ioh5haK+xVQpvrt2mW4zJtp85EItMyh UjPeuT3Nh+AGKoWgI/NFYMT6ibqZ8L22RUlpBg9sYoCb2aFAuuORAOKOrdKgYpM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=TGS88i NZAP8Z0tU+0lZ1h9YkfxKdawcxlF1zuFnB76Vz3v79Cai4h+ro+BwEvpQjssDcJe N8aUDN65iERWb5gkr79b+nDMIEESM59jX46XN24sKh2Gx+QBdU7I8FShhJx0wX6a iqTIguTcWAks1Xe2RRDvd5iDO5Elazn8xKr6g= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 68A7A93D0; Mon, 9 Apr 2012 14:55:51 -0400 (EDT) Original-Received: from badger (unknown [173.8.133.100]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id C812F93CE; Mon, 9 Apr 2012 14:55:50 -0400 (EDT) In-Reply-To: <871unxhi74.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Mon, 09 Apr 2012 02:17:35 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) X-Pobox-Relay-ID: A0409464-8275-11E1-BF97-B1B0728A0A4D-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 74.115.168.62 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:14232 Archived-At: On Sun 08 Apr 2012 17:17, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > I=E2=80=99d like to apply these patches and associated documentation in > stable-2.0. Thoughts? Looks great to me. A couple of thoughts: > + (define-inlinable (modifier s val) > + (if (eq? (struct-vtable s) #,type-name) > + (struct-set! s index val) > + (throw 'wrong-type-arg 'modifier > + "Wrong type argument: ~S" (list s) > + (list s))))))))) Any better abstraction here? It can be a big win to just pass the vtable to some function, because you avoid emitting code and constants. (It will be nice to start to elide some of these checks in the optimizer...) E.g. (throw-bad-struct s 'modifier). Same for the getter. ("Getter" and "setter" are better names IMO, because of other uses of the name "accessor" in Guile.) Perhaps not germane to your patch, but hey :) > (syntax-case x () > - ((_ type-name constructor-spec predicate-name field-spec ...) > + ((_ immutable? type-name constructor-spec predicate-name > + field-spec ...) I realize this is an internal macro, but it would be nice to support keywords (#:immutable), possibly without arguments... > +;; Import (srfi srfi-9)'s private module, so we can use the private > +;; `%define-record-type' macro. > +(eval-when (compile eval load) > + (module-use! (current-module) (resolve-module '(srfi srfi-9)))) Why not just use (@@ (srfi srfi-9) %define-record-type) ? > (%define-record-type)[functional-accessors]: Mimic `define-inlinable', > but add support for (ACCESSOR obj val), when `%reveal-setter' allows > it. This is confusing naming. Functional setters? Surely getters are already functional. I find the set-fields interface a bit strange, FWIW. Are you happy with it, or do you think it could be better? If you think it's really the thing to do, OK. OK those were more comments than I intended! Peace, Andy --=20 http://wingolog.org/