unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Damien Mattei <damien.mattei@gmail.com>
To: guile-user <guile-user@gnu.org>
Cc: Jean-Paul Roy <jean-paul.roy@unice.fr>
Subject: Re: GOOPS question
Date: Sat, 8 May 2021 23:11:30 +0200	[thread overview]
Message-ID: <CADEOaddkOcpWCKrMFcUwwoQTqg4ii+HZq+yz3jFfTmpvBPKxBw@mail.gmail.com> (raw)
In-Reply-To: <CAA2XvwKhWLPP_wf+toC4bi6e3C=PMt-r9CPic1M7AfjS3YKQjw@mail.gmail.com>

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-vector.scm

it exports:
            <growable-vector>
   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 (←)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)
#<<growable-vector> 10bd85c80> is an instance of class <growable-vector>
Slots are:
     v = #(1 2 3 4 5 #<unspecified> #<unspecified> #<unspecified>
#<unspecified> #<unspecified> 7 #<unspecified> #<unspecified>
#<unspecified> #<unspecified> #<unspecified> #<unspecified> #<unspecified>
#<unspecified> #<unspecified>)
     end = 10
 {gva[7] ← 9}
 = 9
 {gva[7]}
= 9
 (vector-ref gva 7)
 = 9
 {gva[7] ← gva[3]}
 = 4
 {gva[7]}
 = 4
 {gva[37] ← gva[3]}
 = 4
 {gva[37]}
 = 4

Damien

On Sun, May 2, 2021 at 12:21 PM Mikael Djurfeldt <mikael@djurfeldt.com>
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ön 2 maj 2021 02:08Damien Mattei <damien.mattei@gmail.com> skrev:
>
>> 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/mattei/Dropbox/git/library-FunctProg/gvector.scm.go
>>
>> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
>>
>> ;;;       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/mattei/Dropbox/git/library-FunctProg/gvector.scm.go
>>
>> scheme@(guile-user)> (define c2 (make <gvector>))
>>
>> ;;; <stdin>:2:11: warning: possibly unbound variable `make'
>>
>> ;;; <stdin>:2:11: warning: possibly unbound variable `<gvector>'
>>
>> <unnamed port>: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/mattei/Dropbox/git/library-FunctProg/gvector.scm.go
>>
>> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
>>
>> ;;;       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/mattei/Dropbox/git/library-FunctProg/gvector.scm.go
>>
>> scheme@(guile-user)> (define c2 (make <gvector>))
>>
>> scheme@(guile-user)> c2
>>
>> $1 = #<<gvector> 109e82500>
>>
>> scheme@(guile-user)> (describe c2)
>>
>> #<<gvector> 109e82500> is an instance of class <gvector>
>>
>> Slots are:
>>
>>      v = #(#<unspecified> #<unspecified> #<unspecified> #<unspecified>
>> #<unspecified> #<unspecified> #<unspecified> #<unspecified>)
>>
>>      length = 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 <mikael@djurfeldt.com>
>> 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 <damien.mattei@gmail.com>
>> > 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 <my-complex> (<number>) r i #:name "Complex")
>> >>
>> >> seems <number> 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 growable
>> >> array ,so a subclass
>> >>
>> >> anyway if i write something ike that:
>> >> (define-class <gvector> (<array>) .....
>> >> how can i use the <array> object?
>> >>
>> >> i think perhaps i should not define a superclass or <object> as super
>> >> class....
>> >> any advice welcome...
>> >>
>> >> Damien
>> >>
>> >
>>
>


  reply	other threads:[~2021-05-08 21:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-29 23:10 GOOPS question Damien Mattei
2021-04-30  5:52 ` Atom X
2021-04-30  7:55 ` Mikael Djurfeldt
2021-05-02  0:07   ` Damien Mattei
2021-05-02 10:14     ` Damien Mattei
2021-05-02 10:26       ` Mikael Djurfeldt
2021-05-02 10:58         ` Damien Mattei
2021-05-02 10:34       ` Damien Mattei
2021-05-02 10:35       ` tomas
2021-05-02 10:21     ` Mikael Djurfeldt
2021-05-08 21:11       ` Damien Mattei [this message]
2021-05-10 12:22         ` Mikael Djurfeldt
2021-04-30  7:57 ` Linus Björnstam
2021-04-30  9:47   ` Damien Mattei
2021-04-30 10:43     ` Mikael Djurfeldt
2021-04-30 11:08 ` Mikael Djurfeldt
2021-04-30 12:19   ` Stefan Israelsson Tampe
2021-04-30 14:50     ` Mikael Djurfeldt
2021-04-30 15:15       ` Mikael Djurfeldt
     [not found] <Pine.GSO.4.05.10207071043010.9685-100000@sallust.ida.ing.tu-bs.de>
2002-07-08 18:26 ` goops question Marius Vollmer
     [not found] ` <87fzyu9iu0.fsf@zagadka.ping.de>
2002-07-08 19:59   ` Dirk Herrmann
2002-07-09 21:17   ` Neil Jerram
  -- strict thread matches above, loose matches on Subject: below --
2002-07-07  8:45 Dirk Herrmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADEOaddkOcpWCKrMFcUwwoQTqg4ii+HZq+yz3jFfTmpvBPKxBw@mail.gmail.com \
    --to=damien.mattei@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=jean-paul.roy@unice.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).