From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damien Mattei Newsgroups: gmane.lisp.guile.user Subject: Re: GOOPS question Date: Sat, 8 May 2021 23:11:30 +0200 Message-ID: References: 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="28440"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Jean-Paul Roy To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat May 08 23:12:19 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 1lfUFG-0007H0-MX for guile-user@m.gmane-mx.org; Sat, 08 May 2021 23:12:18 +0200 Original-Received: from localhost ([::1]:52528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfUFF-0002as-Pn for guile-user@m.gmane-mx.org; Sat, 08 May 2021 17:12:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfUEk-0002aa-Ry for guile-user@gnu.org; Sat, 08 May 2021 17:11:46 -0400 Original-Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]:46841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfUEh-0000jQ-HH for guile-user@gnu.org; Sat, 08 May 2021 17:11:46 -0400 Original-Received: by mail-io1-xd31.google.com with SMTP id o21so10858764iow.13 for ; Sat, 08 May 2021 14:11:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2RHeaFZk2zluC/7KZURgro+RDCpDEr2mvLW4igN6KmA=; b=WuWzdXPbRy2BNQxxeVfGUE3yPjHJtxHNTdEYCi6N3qMggkgMs3oGOwKnjTGh1nvs+O QwoWnsRLhB0dxbmEu0RYTANiVvRUZHU3OFEKduJcGBVUAT5f2wkBI6UGb/X/tVCVZ6/4 P7dsaORbYyN3APuVXKQFHq0aS9IjhU9rHhYNE9TNjD320ExDOy0S5m2UkwZjr7Ow4ZdG k9C5Im22WVLT2wV9VSSzl5giQDwy1IVuvBYPZb5vO0uS5aLiuR1T3Tbm4G+uYYGd/WpH Lmc+rs3/35kZjwlL6x8P6Vvzhzdk7lyGcyk835aiLpjne+cO1yb0H82MX57LvmQfKC0s m5Zg== 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:from:date :message-id:subject:to:cc; bh=2RHeaFZk2zluC/7KZURgro+RDCpDEr2mvLW4igN6KmA=; b=ospYcQ4EACtxZtPuHl82wJMLQv1XxXYXEGNBzIB0QH51LHZwNhLU0seFlvgYDVHPb0 h4a5S1HWEra93qNZK6m83/KLXv2tbNG9HVmIHuDGN4k+J9HUR/i5d7fjec5hiT0Nf/a0 PoPAeDO4u3PPrbl1GFspxf5MrY0s1MlAQ30GCNEc4UXZ/xVL+MVmTu6al7mbH9KN1TNM UmcuLfgcqSo7aJ1R9qef5YC0XjMFj1NfykL5uZinVrng+nq8pJfKLmH8C1oW+kpORM/r cLZuiOzvdyuMpRH3Cxie3ggfBUHQhMCyUM22sjVZByu77CXpDdrR+fENGbfVHMguGCVL ASNw== X-Gm-Message-State: AOAM531/rAB8hxMAaGWX6geacXziva4ZJ8lrs2Y2t7bb1U9IyaZTPScq NVyMhRk74Md7CUTyB90eQS+ZABi9mSdSOTOr91zBAM862YlnLg== X-Google-Smtp-Source: ABdhPJxhB3amVDFB7ipOfAMo0nFLmLsJhQPguAZFdrQuqNan9MfHLOoU6ZbF6XjJj0q9zgREBOWYj0Dsu322/IcKJnA= X-Received: by 2002:a5d:8c82:: with SMTP id g2mr12573647ion.34.1620508301496; Sat, 08 May 2021 14:11:41 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::d31; envelope-from=damien.mattei@gmail.com; helo=mail-io1-xd31.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:17518 Archived-At: 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-vec= tor.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)n= otation ((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:-bindings > 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 skre= v: > >> 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/matt= ei/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/matt= ei/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/matt= ei/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:2= 1:2: >> warning: possibly unbound variable `orig:vector-length' >> >> ;;; >> >> /Volumes/Mojave/Users/mattei/Dropbox/git/library-FunctProg/gvector.scm:2= 6:2: >> warning: possibly unbound variable `orig:vector-set!' >> >> ;;; >> >> /Volumes/Mojave/Users/mattei/Dropbox/git/library-FunctProg/gvector.scm:3= 1:2: >> warning: possibly unbound variable `orig:vector-ref' >> >> ;;; compiled >> >> /Users/mattei/.cache/guile/ccache/2.2-LE-8-3.A/Volumes/Mojave/Users/matt= ei/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 growabl= e >> >> 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 super >> >> class.... >> >> any advice welcome... >> >> >> >> Damien >> >> >> > >> >