guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GOOPS question


From: Mikael Djurfeldt
Subject: Re: GOOPS question
Date: Sun, 2 May 2021 12:21:27 +0200

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 via email to

[Prev in Thread] Current Thread [Next in Thread]