From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tobias Brandt Newsgroups: gmane.lisp.guile.user Subject: Re: Mixing syntax-rule and indentifier-syntax Date: Wed, 18 Jan 2012 00:26:56 +0100 Message-ID: References: <87aa5mhu6r.fsf@Kagami.home> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1326842832 19792 80.91.229.12 (17 Jan 2012 23:27:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 17 Jan 2012 23:27:12 +0000 (UTC) Cc: guile-user@gnu.org To: Ian Price Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Jan 18 00:27:08 2012 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RnIQl-0001DO-Nz for guile-user@m.gmane.org; Wed, 18 Jan 2012 00:27:07 +0100 Original-Received: from localhost ([::1]:35849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RnIQl-0007xl-38 for guile-user@m.gmane.org; Tue, 17 Jan 2012 18:27:07 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:59278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RnIQg-0007xM-K7 for guile-user@gnu.org; Tue, 17 Jan 2012 18:27:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RnIQb-0000gs-TD for guile-user@gnu.org; Tue, 17 Jan 2012 18:27:02 -0500 Original-Received: from mail-tul01m020-f169.google.com ([209.85.214.169]:49084) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RnIQb-0000gY-Mt for guile-user@gnu.org; Tue, 17 Jan 2012 18:26:57 -0500 Original-Received: by obbta7 with SMTP id ta7so4088663obb.0 for ; Tue, 17 Jan 2012 15:26:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=NhBgqglq+2Gbe6bDYi+Vq0KqXIWdJi1ymTGaOddvNQc=; b=UKTIstx82uJavRWwcRicJiCEOSQfe5ksEVNqX/BseRVJvhR/QTxesPftTCsh4Tcad6 swgkgXH1Mk0B/jy3XKFAAXkwnkJQjGyL7/qriL3tNAlPNoMm8kfaRD2bfdVAAphEl0pe 2Nyoo80UFpzj7u4pUx+hCtJalQP94FmG0ertE= Original-Received: by 10.182.147.106 with SMTP id tj10mr17012711obb.12.1326842816574; Tue, 17 Jan 2012 15:26:56 -0800 (PST) Original-Received: by 10.60.49.197 with HTTP; Tue, 17 Jan 2012 15:26:56 -0800 (PST) In-Reply-To: <87aa5mhu6r.fsf@Kagami.home> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.169 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9157 Archived-At: > 0. I'm sure there is another way, but my mind blanks at the moment After you got me started, I was able to simplify and generalize it a bit. (-> is a GOOPS generic accessor I defined elsewhere. It works with vectors, arrays, strings, etc ...) (define-syntax with-accessors=A0 (lambda (stx)=A0 =A0 (syntax-case stx () =A0 ((_ (id ...) exp ...)=A0 =A0 =A0 =A0#`(begin=A0 =A0 =A0 =A0 =A0 =A0#,@(= let (;; checks if arg is in the list of identifiers (id ...) (in-list? (lambda (arg)=A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 (exists (lambda (x) (bound-identifier=3D? x arg)) =A0 =A0 =A0 =A0 #'(id ...)))))=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; transform = each expression in exp ...=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (map (lambda (clause) (syntax-case clause (set!)=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0;; setter =A0 =A0 =A0 =A0 =A0 =A0 =A0((set! (arg idx ...) val) (in-list? #'arg)=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 #'((set= ter ->) arg idx ... val))=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; getter=A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0((arg idx ...)=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (in-list? #'arg= ) =A0 =A0 #'(-> arg idx ...))=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0(id #'id))) =A0 =A0 =A0 =A0 =A0#'(exp ...))))))))