From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by sourceware.org (Postfix) with ESMTPS id 6A4D73858C33 for ; Mon, 16 Oct 2023 16:43:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A4D73858C33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6A4D73858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::236 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697474588; cv=none; b=ctMyn9YnffjRh4Y1KaJHrn72PqhfuM8Z3Jb4o/fHYbAIoVuqv1suw2Skj1jdNhLUVjdy9JStipqRciistMHOrAgiU2W5ekBIhKDaD53sTVH2b8/6FOzlmhpDD9BFTqsP03oa8usiezLte/vobsuhoH5qrw7oJdiVY67EWPUvIzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697474588; c=relaxed/simple; bh=u00oY/cOYmdMn4Qcq1v3uUw095D7F629aN+GGADYsQc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YooK0jsCfCSYE4f/ZR8igLo8+Ib3NBw4/5G2HvvvPQsYQe6O7PHzOYO15L93fbF8JlE8HfRzhSVRm21rlIITH9bSmwrfqgZW0qEVqJ+Z/PuuSIkbCqstJJrY2okEE39l2FoMQFwO5V5CsUEYr9KGZ/XowTRN5OL0IHR/MYRzJy8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3b2b1b25547so2029932b6e.3 for ; Mon, 16 Oct 2023 09:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697474585; x=1698079385; darn=sourceware.org; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=joRgisLwjZYHF3QusaHbY/7SURmM04Cj7HH40tQ0w/Y=; b=FNh+Rlv6wnZHxJ1PNAixGi0HM4b2kK6WKVIvEAs7EiwwZUyOYSbM4wvw4XlL7GPk9G X5TBIf9v0thbPX0O0zP1hk45d++fEov1Ssf1a4Mhi2kYqKACEG3OFMjD/sPJZTIr/8sP 6uqqRLb+g+vATaIxBLQjZIqKMMF7I0tF7ji2hmO8u5C1VnxE41iaGjbY+RwDN84E8J9D 94pdy/7NzE9zrhefN4sfQUMQjYZs85fuycWPmkyif7aiM8YyHQlezJjdoh30t1Tmbi61 erRo63Ow8OsWFNOb1U7f1wV2KkGiqmNUzIgAR/rh5J8lToKcqU7awyBNtgPuVbfuSW6s u4UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697474585; x=1698079385; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=joRgisLwjZYHF3QusaHbY/7SURmM04Cj7HH40tQ0w/Y=; b=GWSiwqJLx/x0o+HRKHgX4aXffT+TEtTx5Os0JnXqqnC1XcjWvXrk5G7oYpp665liPH J31qmI/muLVojij6oS4K0nuBLzoYdyMGP7G7GKAqkW60VshpnrPd28thZoCLe0FGf5va zfQJher+q5m0Pof1p21wcBlIOCh5ALCfGaD0TAQYSEqii2/f/bSRjKrlkE2JHKUkTpf8 cxMFXgaVu9FZ1O7SeRSl+Sm0CLvxX2oO5cdU9toULTkfT3tB3aq8xadg4mwH+772bvW/ YZuV6P53v0n21KxRc8aLOI/bUewB4ULPw7ljhsoiz63AFu5kHWmf1XMQrDE1Dwt/8h4n eooQ== X-Gm-Message-State: AOJu0Yy8CTfblACqHEChmkPoGyZqiPIiC4K56gxVsOFeVlajjqImvXDy mDpgOaU8hI7kLbK221dSfb67rcw0AdI= X-Google-Smtp-Source: AGHT+IFAbs5+pHE/yWBjT5LiIkpwIF5oc0fhq3MFWFC3hZI1ra6vXmAfNxEg0+0CVpSbjEQQSEJvyg== X-Received: by 2002:a54:4812:0:b0:3ad:c497:1336 with SMTP id j18-20020a544812000000b003adc4971336mr37371657oij.16.1697474585619; Mon, 16 Oct 2023 09:43:05 -0700 (PDT) Received: from L440 (fixed-189-203-133-112.totalplay.net. [189.203.133.112]) by smtp.gmail.com with ESMTPSA id r24-20020a056808211800b003af732a2054sm1924585oiw.57.2023.10.16.09.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:43:05 -0700 (PDT) Received: by L440 (Postfix, from userid 1000) id 5E5E81287DC7; Mon, 16 Oct 2023 10:43:03 -0600 (CST) From: Alcides Flores To: Damien Mattei Cc: =?utf-8?B?4byIzrvOus61zq/OtM63z4I=?= FP , kawa mailing list Subject: Re: accessor, getter setter for kawa class References: Date: Mon, 16 Oct 2023 10:43:03 -0600 In-Reply-To: (Damien Mattei's message of "Mon, 16 Oct 2023 15:30:55 +0200") Message-ID: <87fs2ajz6w.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --=-=-= Content-Type: multipart/alternative; boundary="==-=-=" --==-=-= Content-Type: text/plain *Hello Damien.* Thanks for pointing them out and remembering me of those ones. I guess I misunderstood the meaning of the "predefined" word as mentioned before. Well, yes indeed the /generic/ accessor & mutator procedures (=slot-ref,slot-set!=) work very well with public fields, which is the default access modifier in Kawa anyway. But AFAIK they don't work with private or protected fields, as it is the case when using Java frameworks or libraries that usually follow a more "traditional"/Java-like OOP-Style in which fields are almost allways private/protected and hence require proper accessors/mutators. Therefore if your use case is not like this, they should work and serve you well. #+begin_src scheme ;; Defining a class with a private field (define-simple-class MyKlass () (v::vector #:access 'private) ((*init* (vparm::vector)) (set! v vparm))) ;; Trying to access the private field throws exception (! m1 (MyKlass #(1 2 3))) (slot-ref m1 'v) java.lang.RuntimeException: no such field v in my-klass at gnu.kawa.reflect.SlotGet.getSlotValue(SlotGet.java:188) at atInteractiveLevel-3.run(tty:3) at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:290) at kawa.Shell.run(Shell.java:300) at kawa.Shell.run(Shell.java:183) at kawa.repl.processArgs(repl.java:724) at kawa.repl.main(repl.java:830) #+end_src *Greetings.* --==-=-=-- --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 Alcides Flores. Lunae, oct 16 2023, Damien Mattei scripsit: > hello =E1=BC=88=CE=BB=CE=BA=CE=B5=CE=AF=CE=B4=CE=B7=CF=82 > > in fact, as written in the manual , a lot of Guile GOOPS procedure are > ported to Kawa, like slot-ref and this give this code: > > (define (matrix-v M) > (slot-ref M 'v)) > > to have the same getter than in Guile or Racket for a matrix class: > > (define-simple-class matrix () > > (v::vector) > > ((*init* (vParam::vector)) > (set! v vParam)) > > ) > > (matrix-v M) > #(#(0 1 2) #(1 2 3)) > > > On Mon, Oct 16, 2023 at 1:41=E2=80=AFPM =E1=BC=88=CE=BB=CE=BA=CE=B5=CE=AF= =CE=B4=CE=B7=CF=82 FP wrote: >> >> Hi Damien. >> >> AFAIK, there aren't such predefinded accesors in Kawa classes. >> >> To achieve the same goal I usually do one of the following: >> >> a) Leave the field as public and use it directly. >> >> b) Define a parent class (abstract or not) in Java and use Lombok annota= tions (@Getter, @Setter, @Data, etc) >> >> Greetings. >> >> El lun., 16 de octubre de 2023 6:19, Damien Mattei via Kawa escribi=C3=B3: >>> >>> are there predefined getter or setter for a field of a kawa class? --=-=-=--