unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* GOOPS question
@ 2021-04-29 23:10 Damien Mattei
  2021-04-30  5:52 ` Atom X
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Damien Mattei @ 2021-04-29 23:10 UTC (permalink / raw)
  To: guile-user

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


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-04-29 23:10 GOOPS question Damien Mattei
@ 2021-04-30  5:52 ` Atom X
  2021-04-30  7:55 ` Mikael Djurfeldt
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: Atom X @ 2021-04-30  5:52 UTC (permalink / raw)
  To: guile-user

Hi Damien,

On April 29, 2021 7:10:12 PM EDT, 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
>

Regarding your immediate need for a growable vector type, Guile implements VLists <https://www.gnu.org/software/guile/manual/html_node/VLists.html>, which can take the place of standard lists, but also offer constant- time index referencing like vectors. VLists are functional data structures and are thus immutable, but this is natural for idiomatic Scheme code.

>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

-- Atom



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  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-04-30  7:57 ` Linus Björnstam
  2021-04-30 11:08 ` Mikael Djurfeldt
  3 siblings, 1 reply; 21+ messages in thread
From: Mikael Djurfeldt @ 2021-04-30  7:55 UTC (permalink / raw)
  To: Damien Mattei; +Cc: guile-user

[-- Attachment #1: Type: text/plain, Size: 1003 bytes --]

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
>

[-- Attachment #2: gvector.scm --]
[-- Type: text/x-scheme, Size: 1171 bytes --]

(define-module (oop gvector)
  #:use-module (oop goops)
  #:use-module ((guile)
		#:select (vector-length vector-ref vector-set!)
		#:prefix orig:)
  #:export (<gvector>)
  #:replace (vector-length vector-ref vector-set!))

;;; Constants

(define *initial-allocated-size* 8)

;;; Capture original bindings of vector getters and setters

(define-generic vector-length)

(define-method (vector-length (v <vector>))
  (orig:vector-length v))

(define-generic vector-set!)

(define-method (vector-set! (gv <vector>) (i <integer>) obj)
  (orig:vector-set! gv i obj))

(define-generic vector-ref)

(define-method (vector-ref (gv <vector>) (i <integer>))
  (orig:vector-ref gv i))

;;; The <gvector> class

(define-class <gvector> (<vector>)
  (v #:init-value (make-vector *initial-allocated-size*) #:getter v)
  (length #:init-value 0 #:getter vector-length))

(define (assert-size! gv i)
  (if (>= i (length gv))
      *unspecified*)) ; do nothing for now

(define-method (vector-set! (gv <gvector>) (i <integer>) obj)
  (assert-size! gv i)
  (vector-set! (v gv) i obj))

(define-method (vector-ref (gv <gvector>) (i <integer>))
  (assert-size! gv i)
  (vector-ref (v gv) i))

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-04-29 23:10 GOOPS question Damien Mattei
  2021-04-30  5:52 ` Atom X
  2021-04-30  7:55 ` Mikael Djurfeldt
@ 2021-04-30  7:57 ` Linus Björnstam
  2021-04-30  9:47   ` Damien Mattei
  2021-04-30 11:08 ` Mikael Djurfeldt
  3 siblings, 1 reply; 21+ messages in thread
From: Linus Björnstam @ 2021-04-30  7:57 UTC (permalink / raw)
  To: Damien Mattei, guile-user

This does not answer your question, but:

There was just a SRFI released for growable vectors. I don't know about any interest to have it included in guile, but the reference implentation is probably trivially portable: https://srfi.schemers.org/srfi-214/srfi-214.html



-- 
  Linus Björnstam

On Fri, 30 Apr 2021, at 01:10, 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 <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
> 



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-04-30  7:57 ` Linus Björnstam
@ 2021-04-30  9:47   ` Damien Mattei
  2021-04-30 10:43     ` Mikael Djurfeldt
  0 siblings, 1 reply; 21+ messages in thread
From: Damien Mattei @ 2021-04-30  9:47 UTC (permalink / raw)
  To: guile-user

thank for your answer but my question was just about use of superclass....
SRFI implementation is too complex  for what i want to do now,
template is 1 dimension gvector, that's neolithic for me :-) and do not
explain use of superclass...
Damien

On Fri, Apr 30, 2021 at 9:57 AM Linus Björnstam <linus.internet@fastmail.se>
wrote:

> This does not answer your question, but:
>
> There was just a SRFI released for growable vectors. I don't know about
> any interest to have it included in guile, but the reference implentation
> is probably trivially portable:
> https://srfi.schemers.org/srfi-214/srfi-214.html
>
>
>
> --
>   Linus Björnstam
>
> On Fri, 30 Apr 2021, at 01:10, 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 <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
> >
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-04-30  9:47   ` Damien Mattei
@ 2021-04-30 10:43     ` Mikael Djurfeldt
  0 siblings, 0 replies; 21+ messages in thread
From: Mikael Djurfeldt @ 2021-04-30 10:43 UTC (permalink / raw)
  To: Damien Mattei; +Cc: guile-user

The superclass question is a matter of taste.

First note that in CLOS-like objects systems, such as GOOPS, methods are
not components of classes but it is rather the set of operations =
generics/methods around a type which define its behavior. Roughly speaking,
the only things directly tied to the class are the slots. In this regard
<array> is opaque---there are no accessible slots. Therefore, if using it
as a superclass, it won't add any slots to your instances apart and above
what you explicitly add in your class definition. So, you should think of
the role of <array> as a superclass more in terms of natural grouping, and
its role in selecting methods when you operate on the object using
generics, than anything else. The *only* functional effect of using <array>
as a superclass in this case is that methods taking an <array> argument
will also accept instances of <gvector> as an argument. (This does not
apply to *functions* now taking array as an argument.)

I would say that you could choose between having no explicit superclass and
having <array> as superclass. In your case there would not be any big
functional difference.

If you, in your last answer, by "template" refer to my answer, then you are
of course free to replace all <vector> stuff with the corresponding <array>
stuff.

In my example, I chose to use <vector> as superclass because I regarded
<gvector> to be a specialization. It is true that <vector> logically could
be regarded as a specialization of <gvector>, but you can't do anything
about that.

Best regards,
Mikael

On Fri, Apr 30, 2021 at 11:48 AM Damien Mattei <damien.mattei@gmail.com>
wrote:

> thank for your answer but my question was just about use of superclass....
> SRFI implementation is too complex  for what i want to do now,
> template is 1 dimension gvector, that's neolithic for me :-) and do not
> explain use of superclass...
> Damien
>
> On Fri, Apr 30, 2021 at 9:57 AM Linus Björnstam <
> linus.internet@fastmail.se>
> wrote:
>
> > This does not answer your question, but:
> >
> > There was just a SRFI released for growable vectors. I don't know about
> > any interest to have it included in guile, but the reference implentation
> > is probably trivially portable:
> > https://srfi.schemers.org/srfi-214/srfi-214.html
> >
> >
> >
> > --
> >   Linus Björnstam
> >
> > On Fri, 30 Apr 2021, at 01:10, 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 <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
> > >
> >
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-04-29 23:10 GOOPS question Damien Mattei
                   ` (2 preceding siblings ...)
  2021-04-30  7:57 ` Linus Björnstam
@ 2021-04-30 11:08 ` Mikael Djurfeldt
  2021-04-30 12:19   ` Stefan Israelsson Tampe
  3 siblings, 1 reply; 21+ messages in thread
From: Mikael Djurfeldt @ 2021-04-30 11:08 UTC (permalink / raw)
  To: Damien Mattei; +Cc: guile-user

On Fri, Apr 30, 2021 at 1:11 AM Damien Mattei <damien.mattei@gmail.com>
wrote:

> for example in the doc there is:
> (define-class <my-complex> (<number>) r i #:name "Complex")
>
> seems <number> superclass is of no use
>

Well, it certainly *is* of use in the sense that methods operating on
<number> will immediately start to also accept <my-complex> as an argument.
That might seem worrisome but is not if there is some agreement on which
operations should be implemented for all numbers. So, if you had previously
written an algorithm which operates on numbers, there's now a good chance
that it would also work for <my-complex> objects.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-04-30 11:08 ` Mikael Djurfeldt
@ 2021-04-30 12:19   ` Stefan Israelsson Tampe
  2021-04-30 14:50     ` Mikael Djurfeldt
  0 siblings, 1 reply; 21+ messages in thread
From: Stefan Israelsson Tampe @ 2021-04-30 12:19 UTC (permalink / raw)
  To: Mikael Djurfeldt; +Cc: guile-user

If performance is important, a goops solution can be slow in vector-ref and
vector-set! operations due
to two reasons. (I have pounder an implementation of resizable python lists
and here is my tips),

1. slot-ref/slot-set! is slow (I try to fix this using the much more
difficult struct-ref/struct-set!)
2. generic-method-dispatch is slow, I try to make a wrapper function in
which we short cut for
python/sheme internal types and if they do not match use the generic method.


On Fri, Apr 30, 2021 at 1:57 PM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

> On Fri, Apr 30, 2021 at 1:11 AM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
> > for example in the doc there is:
> > (define-class <my-complex> (<number>) r i #:name "Complex")
> >
> > seems <number> superclass is of no use
> >
>
> Well, it certainly *is* of use in the sense that methods operating on
> <number> will immediately start to also accept <my-complex> as an argument.
> That might seem worrisome but is not if there is some agreement on which
> operations should be implemented for all numbers. So, if you had previously
> written an algorithm which operates on numbers, there's now a good chance
> that it would also work for <my-complex> objects.
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-04-30 12:19   ` Stefan Israelsson Tampe
@ 2021-04-30 14:50     ` Mikael Djurfeldt
  2021-04-30 15:15       ` Mikael Djurfeldt
  0 siblings, 1 reply; 21+ messages in thread
From: Mikael Djurfeldt @ 2021-04-30 14:50 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: guile-user

Generic method dispatch is *supposed* to be fast. It was fast once upon a
time. We should fix that.

On Fri, Apr 30, 2021 at 2:19 PM Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:

> If performance is important, a goops solution can be slow in vector-ref
> and vector-set! operations due
> to two reasons. (I have pounder an implementation of resizable python
> lists and here is my tips),
>
> 1. slot-ref/slot-set! is slow (I try to fix this using the much more
> difficult struct-ref/struct-set!)
> 2. generic-method-dispatch is slow, I try to make a wrapper function in
> which we short cut for
> python/sheme internal types and if they do not match use the
> generic method.
>
>
> On Fri, Apr 30, 2021 at 1:57 PM Mikael Djurfeldt <mikael@djurfeldt.com>
> wrote:
>
>> On Fri, Apr 30, 2021 at 1:11 AM Damien Mattei <damien.mattei@gmail.com>
>> wrote:
>>
>> > for example in the doc there is:
>> > (define-class <my-complex> (<number>) r i #:name "Complex")
>> >
>> > seems <number> superclass is of no use
>> >
>>
>> Well, it certainly *is* of use in the sense that methods operating on
>> <number> will immediately start to also accept <my-complex> as an
>> argument.
>> That might seem worrisome but is not if there is some agreement on which
>> operations should be implemented for all numbers. So, if you had
>> previously
>> written an algorithm which operates on numbers, there's now a good chance
>> that it would also work for <my-complex> objects.
>>
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-04-30 14:50     ` Mikael Djurfeldt
@ 2021-04-30 15:15       ` Mikael Djurfeldt
  0 siblings, 0 replies; 21+ messages in thread
From: Mikael Djurfeldt @ 2021-04-30 15:15 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: guile-user

Preferably, the dispatch should be done as much as possible during compile
time such that it takes zero time during runtime.

On Fri, Apr 30, 2021 at 4:50 PM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

> Generic method dispatch is *supposed* to be fast. It was fast once upon a
> time. We should fix that.
>
> On Fri, Apr 30, 2021 at 2:19 PM Stefan Israelsson Tampe <
> stefan.itampe@gmail.com> wrote:
>
>> If performance is important, a goops solution can be slow in vector-ref
>> and vector-set! operations due
>> to two reasons. (I have pounder an implementation of resizable python
>> lists and here is my tips),
>>
>> 1. slot-ref/slot-set! is slow (I try to fix this using the much more
>> difficult struct-ref/struct-set!)
>> 2. generic-method-dispatch is slow, I try to make a wrapper function in
>> which we short cut for
>> python/sheme internal types and if they do not match use the
>> generic method.
>>
>>
>> On Fri, Apr 30, 2021 at 1:57 PM Mikael Djurfeldt <mikael@djurfeldt.com>
>> wrote:
>>
>>> On Fri, Apr 30, 2021 at 1:11 AM Damien Mattei <damien.mattei@gmail.com>
>>> wrote:
>>>
>>> > for example in the doc there is:
>>> > (define-class <my-complex> (<number>) r i #:name "Complex")
>>> >
>>> > seems <number> superclass is of no use
>>> >
>>>
>>> Well, it certainly *is* of use in the sense that methods operating on
>>> <number> will immediately start to also accept <my-complex> as an
>>> argument.
>>> That might seem worrisome but is not if there is some agreement on which
>>> operations should be implemented for all numbers. So, if you had
>>> previously
>>> written an algorithm which operates on numbers, there's now a good chance
>>> that it would also work for <my-complex> objects.
>>>
>>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  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:21     ` Mikael Djurfeldt
  0 siblings, 2 replies; 21+ messages in thread
From: Damien Mattei @ 2021-05-02  0:07 UTC (permalink / raw)
  To: guile-user

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
>>
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-05-02  0:07   ` Damien Mattei
@ 2021-05-02 10:14     ` Damien Mattei
  2021-05-02 10:26       ` Mikael Djurfeldt
                         ` (2 more replies)
  2021-05-02 10:21     ` Mikael Djurfeldt
  1 sibling, 3 replies; 21+ messages in thread
From: Damien Mattei @ 2021-05-02 10:14 UTC (permalink / raw)
  To: guile-user

i use now the good way to loadmodule:

scheme@(guile-user)> (set! %load-path (reverse (cons "." (reverse
%load-path))))

scheme@(guile-user)> %load-path

$1 = ("/usr/local/Cellar/guile/2.2.6/share/guile/2.2"
"/usr/local/Cellar/guile/2.2.6/share/guile/site/2.2"
"/usr/local/Cellar/guile/2.2.6/share/guile/site"
"/usr/local/Cellar/guile/2.2.6/share/guile" ".")

scheme@(guile-user)> (use-modules (gvector))

;;; note: source file ./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 ./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>:4:11: warning: possibly unbound variable `make'

<unnamed port>:4: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]>

module <gvector> was not in %load-path
but yet another problem that does not exist outside module when simply
including files....

On Sun, May 2, 2021 at 2:07 AM Damien Mattei <damien.mattei@gmail.com>
wrote:

> 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
>>>
>>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-05-02  0:07   ` Damien Mattei
  2021-05-02 10:14     ` Damien Mattei
@ 2021-05-02 10:21     ` Mikael Djurfeldt
  1 sibling, 0 replies; 21+ messages in thread
From: Mikael Djurfeldt @ 2021-05-02 10:21 UTC (permalink / raw)
  To: Damien Mattei; +Cc: guile-user

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
> >>
> >
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  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
  2 siblings, 1 reply; 21+ messages in thread
From: Mikael Djurfeldt @ 2021-05-02 10:26 UTC (permalink / raw)
  To: Damien Mattei; +Cc: guile-user

make is exported by (oop goops), so yiu always need to do:

(use-modules (oop goops))

to use it.

Also, you should only use use-modules to load proper modules (starting with
define-module). If it is plain scheme code, use load.

Den sön 2 maj 2021 12:15Damien Mattei <damien.mattei@gmail.com> skrev:

> i use now the good way to loadmodule:
>
> scheme@(guile-user)> (set! %load-path (reverse (cons "." (reverse
> %load-path))))
>
> scheme@(guile-user)> %load-path
>
> $1 = ("/usr/local/Cellar/guile/2.2.6/share/guile/2.2"
> "/usr/local/Cellar/guile/2.2.6/share/guile/site/2.2"
> "/usr/local/Cellar/guile/2.2.6/share/guile/site"
> "/usr/local/Cellar/guile/2.2.6/share/guile" ".")
>
> scheme@(guile-user)> (use-modules (gvector))
>
> ;;; note: source file ./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 ./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>:4:11: warning: possibly unbound variable `make'
>
> <unnamed port>:4: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]>
>
> module <gvector> was not in %load-path
> but yet another problem that does not exist outside module when simply
> including files....
>
> On Sun, May 2, 2021 at 2:07 AM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
> > 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
> >>>
> >>
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-05-02 10:14     ` Damien Mattei
  2021-05-02 10:26       ` Mikael Djurfeldt
@ 2021-05-02 10:34       ` Damien Mattei
  2021-05-02 10:35       ` tomas
  2 siblings, 0 replies; 21+ messages in thread
From: Damien Mattei @ 2021-05-02 10:34 UTC (permalink / raw)
  To: guile-user

juste understood LOL :

scheme@(guile-user)> (use-modules (gvector))

scheme@(guile-user)> (use-modules (oop goops))

scheme@(guile-user)> (define c2 (make <gvector>))



needed to load all the modules by hand even if used already by gvector, in
gvector definition, confused....


On Sun, May 2, 2021 at 12:14 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> i use now the good way to loadmodule:
>
> scheme@(guile-user)> (set! %load-path (reverse (cons "." (reverse
> %load-path))))
>
> scheme@(guile-user)> %load-path
>
> $1 = ("/usr/local/Cellar/guile/2.2.6/share/guile/2.2"
> "/usr/local/Cellar/guile/2.2.6/share/guile/site/2.2"
> "/usr/local/Cellar/guile/2.2.6/share/guile/site"
> "/usr/local/Cellar/guile/2.2.6/share/guile" ".")
>
> scheme@(guile-user)> (use-modules (gvector))
>
> ;;; note: source file ./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 ./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>:4:11: warning: possibly unbound variable `make'
>
> <unnamed port>:4: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]>
>
> module <gvector> was not in %load-path
> but yet another problem that does not exist outside module when simply
> including files....
>
> On Sun, May 2, 2021 at 2:07 AM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
>> 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
>>>>
>>>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-05-02 10:14     ` Damien Mattei
  2021-05-02 10:26       ` Mikael Djurfeldt
  2021-05-02 10:34       ` Damien Mattei
@ 2021-05-02 10:35       ` tomas
  2 siblings, 0 replies; 21+ messages in thread
From: tomas @ 2021-05-02 10:35 UTC (permalink / raw)
  To: Damien Mattei; +Cc: guile-user

[-- Attachment #1: Type: text/plain, Size: 668 bytes --]

On Sun, May 02, 2021 at 12:14:37PM +0200, Damien Mattei wrote:
> i use now the good way to loadmodule:
> 
> scheme@(guile-user)> (set! %load-path (reverse (cons "." (reverse
> %load-path))))

Apart from what Mikael says: if you want to modify `%load-path', you
typically want to add your "special" directories at the front (same
pattern as in the shell path): your local things take precedence,
the rest of the world is default :)

So no need for that double reverse. Unless you have some very special
requirement, that is.

Best of all (see the docs) is to use the function `add-to-load-path'
which adds your directory to the front :)

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: GOOPS question
  2021-05-02 10:26       ` Mikael Djurfeldt
@ 2021-05-02 10:58         ` Damien Mattei
  0 siblings, 0 replies; 21+ messages in thread
From: Damien Mattei @ 2021-05-02 10:58 UTC (permalink / raw)
  To: mikael; +Cc: guile-user

hello Mike,
thanks you
our message crossed
i find the same deduction too

On Sun, May 2, 2021 at 12:26 PM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

> make is exported by (oop goops), so yiu always need to do:
>
> (use-modules (oop goops))
>
> to use it.
>
> Also, you should only use use-modules to load proper modules (starting
> with define-module). If it is plain scheme code, use load.
>
> Den sön 2 maj 2021 12:15Damien Mattei <damien.mattei@gmail.com> skrev:
>
>> i use now the good way to loadmodule:
>>
>> scheme@(guile-user)> (set! %load-path (reverse (cons "." (reverse
>> %load-path))))
>>
>> scheme@(guile-user)> %load-path
>>
>> $1 = ("/usr/local/Cellar/guile/2.2.6/share/guile/2.2"
>> "/usr/local/Cellar/guile/2.2.6/share/guile/site/2.2"
>> "/usr/local/Cellar/guile/2.2.6/share/guile/site"
>> "/usr/local/Cellar/guile/2.2.6/share/guile" ".")
>>
>> scheme@(guile-user)> (use-modules (gvector))
>>
>> ;;; note: source file ./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 ./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>:4:11: warning: possibly unbound variable `make'
>>
>> <unnamed port>:4: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]>
>>
>> module <gvector> was not in %load-path
>> but yet another problem that does not exist outside module when simply
>> including files....
>>
>> On Sun, May 2, 2021 at 2:07 AM Damien Mattei <damien.mattei@gmail.com>
>> wrote:
>>
>> > 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
>> >>>
>> >>
>>
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: goops question
       [not found] ` <87fzyu9iu0.fsf@zagadka.ping.de>
  2002-07-08 19:59   ` Dirk Herrmann
@ 2002-07-09 21:17   ` Neil Jerram
  1 sibling, 0 replies; 21+ messages in thread
From: Neil Jerram @ 2002-07-09 21:17 UTC (permalink / raw)
  Cc: Dirk Herrmann, guile-devel, guile-user

>>>>> "Marius" == Marius Vollmer <mvo@zagadka.ping.de> writes:

    Marius> Dirk Herrmann <dirk@sallust.ida.ing.tu-bs.de> writes:
    >> "define-class, define-generic and define-accessor can only be used at the
    >> top level"

    Marius> I'm not calling myself an expert here, but I would say
    Marius> that it is very valid to use 'define-class' inside some
    Marius> lexical scope.  Just think of utility structs that are
    Marius> only used in one function.

Agreed, and it seems reasonable to me to use lexical generics (and so
accessors) as well.

        Neil


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: goops question
       [not found] ` <87fzyu9iu0.fsf@zagadka.ping.de>
@ 2002-07-08 19:59   ` Dirk Herrmann
  2002-07-09 21:17   ` Neil Jerram
  1 sibling, 0 replies; 21+ messages in thread
From: Dirk Herrmann @ 2002-07-08 19:59 UTC (permalink / raw)
  Cc: guile-devel, guile-user

On 8 Jul 2002, Marius Vollmer wrote:

> Dirk Herrmann <dirk@sallust.ida.ing.tu-bs.de> writes:
> 
> > "define-class, define-generic and define-accessor can only be used at the
> > top level"
> 
> I'm not calling myself an expert here, but I would say that it is very
> valid to use 'define-class' inside some lexical scope.  Just think of
> utility structs that are only used in one function.

Surprisingly, define-class is the only one of the three where in the code
it is explicitly checked that it is only executed on the top level.  For
this reason, the definition of define-class could really easily converted
to use an mmacro instead of a macro.

For define-generic and define-accessor things are different:  In the code
there is no explicit check for asserting execution on the top level.
However, I was not able to make define-generic work in a lexical scope:  I
always get 'bad define placement' as a result - although I don't
understand it.

However, if it was granted that define-class, define-generic and
define-accessor are all three just used on the top level, they can simply
be converted to use an mmacro instead of a macro:  just exchange the call
to procedure->macro by a call to procedure->memoizing macro, and you are
done.

Thus, I would like people to confirm that it is actually not possible to
use define-class, define-generic and define-accessor other than at the top
level.  If someone can give us an counterexample, things will be more
difficult.

Best regards
Dirk Herrmann


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: goops question
       [not found] <Pine.GSO.4.05.10207071043010.9685-100000@sallust.ida.ing.tu-bs.de>
@ 2002-07-08 18:26 ` Marius Vollmer
       [not found] ` <87fzyu9iu0.fsf@zagadka.ping.de>
  1 sibling, 0 replies; 21+ messages in thread
From: Marius Vollmer @ 2002-07-08 18:26 UTC (permalink / raw)
  Cc: guile-devel, guile-user

Dirk Herrmann <dirk@sallust.ida.ing.tu-bs.de> writes:

> "define-class, define-generic and define-accessor can only be used at the
> top level"

I'm not calling myself an expert here, but I would say that it is very
valid to use 'define-class' inside some lexical scope.  Just think of
utility structs that are only used in one function.

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 21+ messages in thread

* goops question
@ 2002-07-07  8:45 Dirk Herrmann
  0 siblings, 0 replies; 21+ messages in thread
From: Dirk Herrmann @ 2002-07-07  8:45 UTC (permalink / raw)


Hi,

can some of the goops experts please confirm:

"define-class, define-generic and define-accessor can only be used at the
top level"

Best regards, 
Dirk Herrmann


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-05-02 10:58 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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-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

unofficial mirror of guile-user@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-user/0 guile-user/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-user guile-user/ https://yhetil.org/guile-user \
		guile-user@gnu.org
	public-inbox-index guile-user

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.user
	nntp://news.gmane.io/gmane.lisp.guile.user


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git