From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.user Subject: Re: access slot of a class Date: Tue, 21 Nov 2023 00:27:21 +0100 Message-ID: References: Reply-To: mikael@djurfeldt.com 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="20352"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user , Mikael Djurfeldt To: Damien Mattei Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Nov 21 00:28:04 2023 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 1r5DgQ-0004vF-I5 for guile-user@m.gmane-mx.org; Tue, 21 Nov 2023 00:28:02 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r5Dg2-0001sz-Rq; Mon, 20 Nov 2023 18:27:38 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r5Dg1-0001sB-EM for guile-user@gnu.org; Mon, 20 Nov 2023 18:27:37 -0500 Original-Received: from mail-vs1-f43.google.com ([209.85.217.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r5Dfz-0003GD-PO for guile-user@gnu.org; Mon, 20 Nov 2023 18:27:37 -0500 Original-Received: by mail-vs1-f43.google.com with SMTP id ada2fe7eead31-45fa1536e16so1388165137.0 for ; Mon, 20 Nov 2023 15:27:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700522854; x=1701127654; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6bX5O354YrD2k5rIvlTSQXWoer6rZHRX9PFIDRFnFfM=; b=AQS8jFbUH+yi7dFKe2Pz9xDvHLPk8n1jSonwgHrZDrQH2CcoHpExTNvIuhVYCWAJyU lszCYo/YWfsYjN7e1CSSxC0WILMCy6VHOLDlujQAFzlKtRRVCaRzOmpDK6OoW8bzLbfH x/+DI9Xdl9LJnGWnTTF8t9xjOxu8pWXUaRlqoaD8HquQ8nN4m+3Ye+A/7ke+s2DKbhCU cIvQIUtiUz6Sv7qqlFp8k88aQeaDcf8S0xOmTZuu3DDHjMtSnBPqWTGSzygr7IJtfdYT kzoNO5/AKsJUzl60i/OnHCNlm33TgWxnSg0FA1/at4wZJP0ftDqi6Hjqs4c5vMQMKbBD bYig== X-Gm-Message-State: AOJu0Yx+8VW5MHJ0KntrgsxIb0i2wKfp3wbfivbxzputbKjRSte9hmQl YVkB87Bfp8xhom102O886KhRS3gPnQvmuHmE+Q/R5l0/ X-Google-Smtp-Source: AGHT+IG2QEmz4TfRWVKI/wxhaLcgf/xkUgnmGZhwba56sBCXP4Q8EQNgzzd4fJlMPgA8saqVfiRY6liWjlj6M5L4CLs= X-Received: by 2002:a05:6102:20ce:b0:462:8f53:d218 with SMTP id i14-20020a05610220ce00b004628f53d218mr7964103vsr.4.1700522854180; Mon, 20 Nov 2023 15:27:34 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=209.85.217.43; envelope-from=mdjurfeldt@gmail.com; helo=mail-vs1-f43.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19316 Archived-At: Well, if you want to set a slot explicitly using the set! form, and this is a good way to access a slot, you can use an accessor (which internally is a pair of a getter and a setter): (define-class a () (x #:accessor x)) (define o (make a)) (set! (x o) 1) (x o) -> 1 I guess you already know that you can *also* reference this slot using: (slot-set! o 'x 2) (slot-ref o 'x) -> 2 I should add that the accessor way fits well with GOOPS' (and CLOS') basically rather simple concept of having objects and then generic functions operating on them (an accessor is a generic function). Generic functions, in turn, fit with how some Scheme procedures accept different types of arguments and can dispatch to different actions on them. Best regards, Mikael On Mon, Nov 20, 2023 at 10:33=E2=80=AFPM Damien Mattei wrote: > hi, > is there a way to access a slot of a class like other variable with set! = , > Racket,Kawa allow that, but it does not seem to be the case in Guile. > > regards, > damien >