unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Thompson, David" <dthompson2@worcester.edu>
To: Mike Gran <spk121@yahoo.com>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: [EXT] GOOPS class printing
Date: Wed, 23 Feb 2022 16:55:00 -0500	[thread overview]
Message-ID: <CAJ=Rwfb01NiLw+W2JVWTxuMe_CxZ4umCiBuQZHCJQv4PWR5=cA@mail.gmail.com> (raw)
In-Reply-To: <Yhaqls3Dj1k2r7dA@spikycactus.com>

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



      parent reply	other threads:[~2022-02-23 21:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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   ` Thompson, David [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJ=Rwfb01NiLw+W2JVWTxuMe_CxZ4umCiBuQZHCJQv4PWR5=cA@mail.gmail.com' \
    --to=dthompson2@worcester.edu \
    --cc=guile-user@gnu.org \
    --cc=spk121@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).