[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Does anyone have an applicable struct example
From: |
Tristan Colgate |
Subject: |
Re: Does anyone have an applicable struct example |
Date: |
Mon, 28 Jun 2010 11:06:16 +0100 |
I've had a further play and read around the source, and got things
working via goops atleast (still not sure how to use the applicable
structs directly).
The following code works....
(define-class <myclass> (<applicable-struct>) (a))
(make <myclass>)
(slot-set! $1 'procedure (lambda()(...)))
($1)
(slot-set! $1 'a 1)
etc...
This plays nice with write and display method overrides too (which is
what I was after).
On 25 June 2010 10:14, Tristan Colgate <address@hidden> wrote:
> Hi all,
>
> I'd like to make use of the applicable structs feature but am
> running into problems.
>
> From what I can gather from the release note that mentions it, the
> following should work,
> instead, I get a segfault.
>
> scheme@(guile-user)> (define <mything-vtable> (make-struct
> <applicable-struct-vtable> 0))
> scheme@(guile-user)> (define mything (make-struct <mything-vtable> 0
> (lambda()(display "some code")(newline))))
> Segmentation fault (core dumped)
>
> Looking around goops.scm I can see some classes for applicable structs
> that look a bit nicer, but these seem
> to use set-object-procedure! which isn't exported (and I can't find a
> definition)....
>
> scheme@(guile-user)> (use-modules (oop goops))
> scheme@(guile-user)> (define-class <myclass> (<applicable-struct>))
> scheme@(guile-user)> (make <myclass> #:procedure (lambda()(display
> "some code")(nelwine)))
> <stdin>:5:58: warning: possibly unbound variable `nelwine'
> Throw to key `unbound-variable':
> ERROR: In procedure module-lookup:
> ERROR: Unbound variable: set-object-procedure!
>
> I tried using a generic instead but it didn't make much difference.
>
> What am I doing wrong?
>
> --
> Tristan Colgate-McFarlane
> ----
> "You can get all your daily vitamins from 52 pints of guiness, and a
> glass of milk"
>
--
Tristan Colgate-McFarlane
----
"You can get all your daily vitamins from 52 pints of guiness, and a
glass of milk"