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: GOOPS question Date: Mon, 10 May 2021 14:22:41 +0200 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="11023"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Jean-Paul Roy , guile-user To: Damien Mattei Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Mon May 10 14:23:13 2021 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 1lg4wK-0002iu-5U for guile-user@m.gmane-mx.org; Mon, 10 May 2021 14:23:12 +0200 Original-Received: from localhost ([::1]:41344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lg4wJ-0004hG-7E for guile-user@m.gmane-mx.org; Mon, 10 May 2021 08:23:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lg4w7-0004h2-OS for guile-user@gnu.org; Mon, 10 May 2021 08:22:59 -0400 Original-Received: from mail-vs1-f46.google.com ([209.85.217.46]:42568) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lg4w4-0001Si-DI for guile-user@gnu.org; Mon, 10 May 2021 08:22:58 -0400 Original-Received: by mail-vs1-f46.google.com with SMTP id 66so8270184vsk.9 for ; Mon, 10 May 2021 05:22:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=BqKAnrq8AG4b8rpR4CpoOHnH+A8vKydERUwQiYE26qM=; b=S3bxaiinFYF8+Rm7pBqx7gqHnU1utSIEOk2pLQD+0ZZtLozV5rhWOnHIoJFMbUyjZK srDjErlAJLGtQF3RvbzcDrx3WDShkXqphFQXll6FMKNCddu9jaBehtVIwYpPVcUlpH57 fSRXO7zSMr4Kf/6rsE7UYNhzVNJeYPHO4YNVXqgohvpVXwseXl1mcW8OWqxlXDA+uHvU dhZWziU/m6LaC7f3S0DD1bwocek5yyBQ13HOX0QTu+kITRfdkm13st8DrGThf957E8vh 70af2HU7XnJtfghMPbHbSEtwsK33IcoS2thhNR5QCzKBsDSj3kViKvjKOLhaIakeISQJ xFHg== X-Gm-Message-State: AOAM533YB3Sz8wa6fL0vhA8uGQ/6CncY73ISUqH2jFKwMU5LMiM9AVAY 2Iyi+BMSFvp9h6H1xLX9k9VT18kxFiEZXuArTxQ= X-Google-Smtp-Source: ABdhPJx/MTCQB1NoAgNMkPgQqGk14Los4YAVjtOvgUGm9Xx/TwW8JQgyOiybsyM9cyjTRnap2AwEoZkCBQVMp50oixU= X-Received: by 2002:a05:6102:21c5:: with SMTP id r5mr19553839vsg.4.1620649374357; Mon, 10 May 2021 05:22:54 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=209.85.217.46; envelope-from=mdjurfeldt@gmail.com; helo=mail-vs1-f46.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.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, 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 autolearn=no autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 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:17521 Archived-At: Thanks! (Of course, if the code doesn't depend on your Scheme+ but is written in code only depending on the Guile distribution, and if it doesn't print out logging information when resizing vectors, then it would be more generally useful.) Best regards, Mikael On Sat, May 8, 2021 at 11:11 PM Damien Mattei wrote: > finally finished this Growable Vector class for 1 dimension Vectors, i > will update all for multidimensional arrays > (probably for rectangle arrays and vectors of vectors of different > dimension) but i do not need all this in near future. > > it is usable with: > (use-modules (growable-vector)) > > the code of the Class is here: > > https://github.com/damien-mattei/library-FunctProg/blob/master/growable-v= ector.scm > > it exports: > > growable-vector? > ;;growable-vector-get-v > growable-vector-v > make-growable-vector > growable-vector > list->growable-vector > growable-vector-resize > ;;growable-vector-set-v! > > and replace: > > vector-length vector-ref vector-set! vector->list > > it is fully compatible with my Scheme+ that use infix notation and > brackets optionally for array and vector indexing and setting and arrow ( > =E2=86=90)notation ((include "guile/array.scm") > (include "let.scm")), here is example of use: > > (define gva (growable-vector 1 2 3 4 5)) > (vector-set! gva 10 7) > (describe gva) > #< 10bd85c80> is an instance of class > Slots are: > v =3D #(1 2 3 4 5 # # # > # # 7 # # > # # # # # > # #) > end =3D 10 > {gva[7] =E2=86=90 9} > =3D 9 > {gva[7]} > =3D 9 > (vector-ref gva 7) > =3D 9 > {gva[7] =E2=86=90 gva[3]} > =3D 4 > {gva[7]} > =3D 4 > {gva[37] =E2=86=90 gva[3]} > =3D 4 > {gva[37]} > =3D 4 > > Damien > > On Sun, May 2, 2021 at 12:21 PM Mikael Djurfeldt > wrote: > >> My template file creates the module (oop gvector). (Probably a bad name >> for this module, btw.) >> >> If you load it using load, you will still be in the (guile-user) module, >> so you won't see its bindings. To see them, you can do: >> >> (use-modules (oop gvector)) >> >> after having loaded the module using load. >> >> Alternatively, you could put oop/gvector.scm somewhere on your >> %load-path, in which case you don't need to explicitly load the module >> before calling use-modules. >> >> If you remove the module part, you will need to get at the orig:-binding= s >> in some other way. >> >> Finally, note that I by accident used the wrong accessor in assert-size! >> It should be vector-length. >> >> Den s=C3=B6n 2 maj 2021 02:08Damien Mattei skr= ev: >> >>> seems your template isn't working: >>> >>> scheme@(guile-user)> (load "gvector.scm") >>> >>> ;;; note: source file >>> /Volumes/Mojave/Users/mattei/Dropbox/git/library-FunctProg/gvector.scm >>> >>> ;;; newer than compiled >>> >>> /Users/mattei/.cache/guile/ccache/2.2-LE-8-3.A/Volumes/Mojave/Users/mat= tei/Dropbox/git/library-FunctProg/gvector.scm.go >>> >>> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 >>> >>> ;;; or pass the --no-auto-compile argument to disable. >>> >>> ;;; compiling >>> /Volumes/Mojave/Users/mattei/Dropbox/git/library-FunctProg/gvector.scm >>> >>> ;;; compiled >>> >>> /Users/mattei/.cache/guile/ccache/2.2-LE-8-3.A/Volumes/Mojave/Users/mat= tei/Dropbox/git/library-FunctProg/gvector.scm.go >>> >>> scheme@(guile-user)> (define c2 (make )) >>> >>> ;;; :2:11: warning: possibly unbound variable `make' >>> >>> ;;; :2:11: warning: possibly unbound variable `' >>> >>> :2:0: In procedure module-lookup: Unbound variable: make >>> >>> >>> Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. >>> >>> scheme@(guile-user) [1]> ,bt >>> >>> In current input: >>> >>> 2:0 0 (_) >>> >>> but things go well if i remove module part and add: >>> >>> (use-modules (oop goops) >>> (oop goops describe)) >>> >>> scheme@(guile-user)> (load "gvector.scm") >>> >>> ;;; note: source file >>> /Volumes/Mojave/Users/mattei/Dropbox/git/library-FunctProg/gvector.scm >>> >>> ;;; newer than compiled >>> >>> /Users/mattei/.cache/guile/ccache/2.2-LE-8-3.A/Volumes/Mojave/Users/mat= tei/Dropbox/git/library-FunctProg/gvector.scm.go >>> >>> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 >>> >>> ;;; or pass the --no-auto-compile argument to disable. >>> >>> ;;; compiling >>> /Volumes/Mojave/Users/mattei/Dropbox/git/library-FunctProg/gvector.scm >>> >>> ;;; >>> >>> /Volumes/Mojave/Users/mattei/Dropbox/git/library-FunctProg/gvector.scm:= 21:2: >>> warning: possibly unbound variable `orig:vector-length' >>> >>> ;;; >>> >>> /Volumes/Mojave/Users/mattei/Dropbox/git/library-FunctProg/gvector.scm:= 26:2: >>> warning: possibly unbound variable `orig:vector-set!' >>> >>> ;;; >>> >>> /Volumes/Mojave/Users/mattei/Dropbox/git/library-FunctProg/gvector.scm:= 31:2: >>> warning: possibly unbound variable `orig:vector-ref' >>> >>> ;;; compiled >>> >>> /Users/mattei/.cache/guile/ccache/2.2-LE-8-3.A/Volumes/Mojave/Users/mat= tei/Dropbox/git/library-FunctProg/gvector.scm.go >>> >>> scheme@(guile-user)> (define c2 (make )) >>> >>> scheme@(guile-user)> c2 >>> >>> $1 =3D #< 109e82500> >>> >>> scheme@(guile-user)> (describe c2) >>> >>> #< 109e82500> is an instance of class >>> >>> Slots are: >>> >>> v =3D #(# # # # >>> # # # #) >>> >>> length =3D 0 >>> >>> probably a module issue.... but i never use them with this Scheme >>> otherwise things go well (in other file ....) >>> Damien >>> >>> On Fri, Apr 30, 2021 at 9:55 AM Mikael Djurfeldt >>> wrote: >>> >>> > Hi! >>> > >>> > I attach a template which you could build on. Please post your class >>> when >>> > you're done. :) >>> > >>> > Best regards, >>> > Mikael >>> > >>> > On Fri, Apr 30, 2021 at 1:11 AM Damien Mattei >> > >>> > wrote: >>> > >>> >> hi, >>> >> i want to create a growable vector class in Guile, >>> >> such as std::vector or python list, >>> >> first i do not know if it exist already? seems not >>> >> >>> >> i want to use GOOPS but i do not understand how the superclass could >>> be >>> >> accessed,used, instanciate... >>> >> for example in the doc there is: >>> >> (define-class () r i #:name "Complex") >>> >> >>> >> seems superclass is of no use >>> >> >>> >> for my growable vector i would like to use array as superclass? >>> >> but perhaps should it be just a slot as array are a subset of growab= le >>> >> array ,so a subclass >>> >> >>> >> anyway if i write something ike that: >>> >> (define-class () ..... >>> >> how can i use the object? >>> >> >>> >> i think perhaps i should not define a superclass or as supe= r >>> >> class.... >>> >> any advice welcome... >>> >> >>> >> Damien >>> >> >>> > >>> >>