From: "Maciek Godek" <pstrychuj@gmail.com>
To: guile-user@gnu.org
Subject: Getting a type of a variable
Date: Fri, 18 Jul 2008 23:48:12 +0200 [thread overview]
Message-ID: <e2ceda030807181448j655c92edh74716db258351124@mail.gmail.com> (raw)
Hello,
I'm looking for an efficient way to check the
type of an SCM variable. I imagine that I
could write something like:
(define (type? x)
(cond ((integer? x) 'int)
(cond ((real? x) 'double)
...
)
and then convert guile symbol to C string, but that
would be terribly inefficient. (I could also use an integer
to refer to a type, but there's still this 'cond' clause)
The solution of my dreams is that it would turn out
that there's a function defined in the scm api:
scm_t_bits scm_get_type(SCM *var)
that returns a type tag and that there's a way to decipher
the contents of this return value, and that it is wisely
defined for all builtin types.
(I started to implement such thing by myself as a separate
module, but please inform me if it's already done)
Thanks in advance for help
next reply other threads:[~2008-07-18 21:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-18 21:48 Maciek Godek [this message]
2008-07-19 8:53 ` Getting a type of a variable Andy Wingo
2008-07-20 20:48 ` Ludovic Courtès
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=e2ceda030807181448j655c92edh74716db258351124@mail.gmail.com \
--to=pstrychuj@gmail.com \
--cc=guile-user@gnu.org \
/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).