From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Blake Shaw Newsgroups: gmane.lisp.guile.user Subject: boiler plate class generation, writing fresh variables with macros Date: Fri, 22 Jul 2022 09:43:20 +0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15017"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri Jul 22 11:43:58 2022 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oEpCP-0003ld-LJ for guile-user@m.gmane-mx.org; Fri, 22 Jul 2022 11:43:57 +0200 Original-Received: from localhost ([::1]:54356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEpCO-0002cq-1d for guile-user@m.gmane-mx.org; Fri, 22 Jul 2022 05:43:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEpC5-0002cZ-Er for guile-user@gnu.org; Fri, 22 Jul 2022 05:43:37 -0400 Original-Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]:42709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEpC3-00089u-Dv for guile-user@gnu.org; Fri, 22 Jul 2022 05:43:37 -0400 Original-Received: by mail-ej1-x632.google.com with SMTP id sz17so7646966ejc.9 for ; Fri, 22 Jul 2022 02:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sweatshoppe-org.20210112.gappssmtp.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=YYAEwFqdUisBTIFhwRsp4xFP0+O0hLW1Wy96ch/iuXs=; b=jH3hljdlb9Vu6bUYtbf7BXfi12/8lbn/HCbO0maOB1JFgHuaA1sTAdmGV1nXCcm2X1 13lpAVpaPa/X0pq/CdoIKPIpfTAHS+Lbgw6VP4rfbTaM/eObnH84kibxqOiiTosuOQT4 5WK79LwOkG588JNlkvP6OxkcmyiERLtjSsaguSk81V0J1xAqRAc4kZoxQEa8zsWlrmus AELFF1j80m/jsa5YbEPQC0fc9HmnrX38ZryDdCq8qM26J8hI+UijJrWZy+6Du65gqpXY 6VMwaxvewXEw8r3jwrzURGlT3QPOp/vFYnHsYvIBstZCJ2Zlp4+3PwoZIMY0cQ7wFGSt RBTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=YYAEwFqdUisBTIFhwRsp4xFP0+O0hLW1Wy96ch/iuXs=; b=c4EXb3QFhE+W8kQlDORvtistl7qCLIazXkk6IK1EVcmgEHcsGZHWWgifFkBkV977Kz RnH5UJkfqQE77ODTei9qu0vmYXwu96wjXA+Mq7PzZxnInuYmPAqC62EHw1J+3/Qp5Wym tw6rrvWdpIvo5sdoB19EfifzTJMq15RbDRs2iOBTQE3LyALhGXBwJO/CzhIf/JlELdOM cBjeY1iBTRuvrO5BXTA1yUo2OQnjqp3a/m1lXFVkqdR6/9DGQre6rwp+CanvblmgOy54 B+3SKUfT+bK5mhP+744DeTRKOku4q4qGkVzsVpKb9LeGA+rlv0vc92g5YeguMmGP0jgj eNkw== X-Gm-Message-State: AJIora+fKmnarqjuecX+4b6rU3I5ZjTW+V6JL9skYT81YVhq6zZJEfbp 4nk8m6boBvvM8zR4hfkZ+jqXcLWba/GrmYd0DwGkfhYUXm54xw== X-Google-Smtp-Source: AGRyM1uM37OJYVoQcLMWBaTkibpHgClEe3qFpJcKC/afrNW3s8oNfnM68bkGjAnYVQRea+bjuu+9fv35eIZtg5jGeBU= X-Received: by 2002:a17:907:3e11:b0:72b:49d1:2054 with SMTP id hp17-20020a1709073e1100b0072b49d12054mr2552440ejc.78.1658483012031; Fri, 22 Jul 2022 02:43:32 -0700 (PDT) Received-SPF: none client-ip=2a00:1450:4864:20::632; envelope-from=blake@sweatshoppe.org; helo=mail-ej1-x632.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:18446 Archived-At: Hiya guilers, Right now I am working on a window manager extension system in Guile and GOOPs, and I want to eliminate the boilerplate for generating class slots, with a syntax-case macro like: #+begin_example scheme (define-syntax slot-machine (=CE=BB (form) (syntax-case form () ((_ category quality value) #'(let* ((sym (symbol-append category '- quality)) (set-sym! (symbol-append 'set- sym '!)) (get-sym (symbol-append 'get- sym)) (acc-sym (symbol-append 'acc- sym))) (quasiquote (,sym #:init-value value #:setter ,set-sym! #:getter ,get-sym #:accessor ,acc-sym)))))) #+end_example With this I can evaluate (slot-machine 'inner 'color "green") resulting in what looks like an acceptable slot definition: =3D> (inner-color #:init-value "#BF3D52" #:setter set-inner-color! #:getter get-inner-color #:accessor acc-inner-color) Indeed, if I define a class with this slot definition in place (ie manually/without calling the macro), it works fine: #+begin_example scheme (define-class () (inner-color #:init-value "#BF3D52" #:setter set-inner-color! #:getter get-inner-color #:accessor acc-inner-color)) (describe ) =3D> is a class. It's an instance of Superclasses are: Directs slots are: inner-color (No direct subclass) Class Precedence List is: Class direct methods are: Method #< ( ) 7f7b27e10ac0> Generic: setter:acc-inner-color Specializers: Method #< () 7f7b27e10b00> Generic: acc-inner-color Specializers: Method #< ( ) 7f7b27e10b40> Generic: set-inner-color! Specializers: Method #< () 7f7b27e10b80> Generic: get-inner-color Specializers: #+end_example But if I try to use `slot-machine` inside a class definition i'm out of luck: (define-class () (slot-machine 'inner 'color "green")) =3D> While compiling expression: Syntax error: socket:7257:0: source expression failed to match any pattern in form (define-class-pre-definition ((quote inner) (quote color) "green")) I have tried to remedy this ina number of ways, using datum->syntax, quasisyntax/unsyntax, make-variable and by defining a new syntax-case macro to define classes, all without luck. This is actually a recurring theme with my experience with Guile, working on a project, needing to generate boilerplate, and then being unable to find a result, so I figured its time I reach out to figure out what I'm doing wrong in this situation. Thanks for your help! Best, Blake