unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* How can I define a new method for display?
@ 2013-04-17 20:25 Tobias Brandt
  2013-04-17 21:03 ` Panicz Maciej Godek
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Brandt @ 2013-04-17 20:25 UTC (permalink / raw)
  To: guile-user

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

Hi guys,

according to the documentation, when GOOPS is loaded, 'display' becomes a
generic function.

To wit:

scheme@(guile-user)> (use-modules (oop goops))
scheme@(guile-user)> (class-of display)
$1 = #<<procedure-class> <primitive-generic> 2cfa3c0>

But adding a new method has no effect:

scheme@(guile-user)> (define-class <foo> ())
scheme@(guile-user)> (define-method (display (self <foo>)) (display "foo"))
scheme@(guile-user)> (display (make <foo>)) (newline)
#<<foo> 2f428f0>

Also, applying functions like 'generic-function-methods' to 'display' gives
a type error:

>scheme@(guile-user)> (generic-function-methods display)
ERROR: In procedure generic-function-methods:
ERROR: In procedure generic-function-methods: Wrong type argument in
position 1 (expecting generic function): #<procedure display (_ #:optional
_)>


What am I doing wrong?

Cheers,
Tobias

[-- Attachment #2: Type: text/html, Size: 1470 bytes --]

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

* Re: How can I define a new method for display?
  2013-04-17 20:25 How can I define a new method for display? Tobias Brandt
@ 2013-04-17 21:03 ` Panicz Maciej Godek
  2013-04-17 21:15   ` Tobias Brandt
  0 siblings, 1 reply; 3+ messages in thread
From: Panicz Maciej Godek @ 2013-04-17 21:03 UTC (permalink / raw)
  To: Tobias Brandt; +Cc: guile-user@gnu.org

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

Howdie!

2013/4/17 Tobias Brandt <tob.brandt@gmail.com>

> Hi guys,
>
> according to the documentation, when GOOPS is loaded, 'display' becomes a
> generic function.
>
> To wit:
>
> scheme@(guile-user)> (use-modules (oop goops))
> scheme@(guile-user)> (class-of display)
> $1 = #<<procedure-class> <primitive-generic> 2cfa3c0>
>
> But adding a new method has no effect:
>
> scheme@(guile-user)> (define-class <foo> ())
> scheme@(guile-user)> (define-method (display (self <foo>)) (display
> "foo"))
> scheme@(guile-user)> (display (make <foo>)) (newline)
> #<<foo> 2f428f0>
>
>
You should (define-method (display (self <foo>) port) ...)

Best regards

[-- Attachment #2: Type: text/html, Size: 1368 bytes --]

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

* Re: How can I define a new method for display?
  2013-04-17 21:03 ` Panicz Maciej Godek
@ 2013-04-17 21:15   ` Tobias Brandt
  0 siblings, 0 replies; 3+ messages in thread
From: Tobias Brandt @ 2013-04-17 21:15 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: guile-user@gnu.org

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

Now I feel stupid. Thanks!


On 17 April 2013 23:03, Panicz Maciej Godek <godek.maciek@gmail.com> wrote:

> Howdie!
>
> 2013/4/17 Tobias Brandt <tob.brandt@gmail.com>
>
>> Hi guys,
>>
>> according to the documentation, when GOOPS is loaded, 'display' becomes a
>> generic function.
>>
>> To wit:
>>
>> scheme@(guile-user)> (use-modules (oop goops))
>> scheme@(guile-user)> (class-of display)
>> $1 = #<<procedure-class> <primitive-generic> 2cfa3c0>
>>
>> But adding a new method has no effect:
>>
>> scheme@(guile-user)> (define-class <foo> ())
>> scheme@(guile-user)> (define-method (display (self <foo>)) (display
>> "foo"))
>> scheme@(guile-user)> (display (make <foo>)) (newline)
>> #<<foo> 2f428f0>
>>
>>
> You should (define-method (display (self <foo>) port) ...)
>
> Best regards
>
>

[-- Attachment #2: Type: text/html, Size: 1778 bytes --]

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

end of thread, other threads:[~2013-04-17 21:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-17 20:25 How can I define a new method for display? Tobias Brandt
2013-04-17 21:03 ` Panicz Maciej Godek
2013-04-17 21:15   ` Tobias Brandt

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