unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* GOOPS class printing
       [not found] <Yhaqls3Dj1k2r7dA.ref@spikycactus.com>
@ 2022-02-23 21:43 ` Mike Gran
  2022-02-23 21:48   ` Jan Wedekind
  2022-02-23 21:55   ` [EXT] " Thompson, David
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Gran @ 2022-02-23 21:43 UTC (permalink / raw)
  To: guile-user

Hello all-

If I define a GOOPS class like so...

   (use-modules (oop goops))
   (define-class <foo> ())
   <foo>
   
When it is printed, it has a long hex string in it

    $2 = #<<class> <foo> 7fa3d9a5bc80>

Is there a way to change how a class prints itself so that
it does not have a hex string?  So that it is just

   #<<class> <foo>>

or something similar?

Thanks,
Mike Gran



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

* Re: GOOPS class printing
  2022-02-23 21:43 ` GOOPS class printing Mike Gran
@ 2022-02-23 21:48   ` Jan Wedekind
  2022-02-23 21:55   ` [EXT] " Thompson, David
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Wedekind @ 2022-02-23 21:48 UTC (permalink / raw)
  To: guile-user, Mike Gran

You can define the write and display methods for a metaclass. Also see my article on inspection and metaclasses:

https://www.wedesoft.de/software/2014/03/02/oop-with-goops/

Kind regards
Jan

On 23 February 2022 21:43:50 GMT, Mike Gran <spk121@yahoo.com> wrote:
>Hello all-
>
>If I define a GOOPS class like so...
>
>   (use-modules (oop goops))
>   (define-class <foo> ())
>   <foo>
>   
>When it is printed, it has a long hex string in it
>
>    $2 = #<<class> <foo> 7fa3d9a5bc80>
>
>Is there a way to change how a class prints itself so that
>it does not have a hex string?  So that it is just
>
>   #<<class> <foo>>
>
>or something similar?
>
>Thanks,
>Mike Gran
>
>

-- 
Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.


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

* Re: [EXT] GOOPS class printing
  2022-02-23 21:43 ` GOOPS class printing Mike Gran
  2022-02-23 21:48   ` Jan Wedekind
@ 2022-02-23 21:55   ` Thompson, David
  1 sibling, 0 replies; 3+ messages in thread
From: Thompson, David @ 2022-02-23 21:55 UTC (permalink / raw)
  To: Mike Gran; +Cc: Guile User

Hi Mike,

On Wed, Feb 23, 2022 at 4:44 PM Mike Gran <spk121@yahoo.com> wrote:
>
> Hello all-
>
> If I define a GOOPS class like so...
>
>    (use-modules (oop goops))
>    (define-class <foo> ())
>    <foo>
>
> When it is printed, it has a long hex string in it
>
>     $2 = #<<class> <foo> 7fa3d9a5bc80>
>
> Is there a way to change how a class prints itself so that
> it does not have a hex string?  So that it is just
>
>    #<<class> <foo>>
>
> or something similar?

GOOPS turns several procedures into methods, such as 'write'.  I think
I've defined special write methods in the past for this purpose.  Here
is a basic and silly example:

scheme@(guile-user)> (define-class <foo> ())
scheme@(guile-user)> (make <foo>)
$33 = #<<foo> 55ddef3b0680>
scheme@(guile-user)> (define-method (write (foo <foo>) port)
                       (display "hello" port))
scheme@(guile-user)> (make <foo>)
$34 = hello

Hope that helps,

- Dave



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

end of thread, other threads:[~2022-02-23 21:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Yhaqls3Dj1k2r7dA.ref@spikycactus.com>
2022-02-23 21:43 ` GOOPS class printing Mike Gran
2022-02-23 21:48   ` Jan Wedekind
2022-02-23 21:55   ` [EXT] " Thompson, David

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