unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Getting a type of a variable
@ 2008-07-18 21:48 Maciek Godek
  2008-07-19  8:53 ` Andy Wingo
  2008-07-20 20:48 ` Ludovic Courtès
  0 siblings, 2 replies; 3+ messages in thread
From: Maciek Godek @ 2008-07-18 21:48 UTC (permalink / raw)
  To: guile-user

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




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

end of thread, other threads:[~2008-07-20 20:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-18 21:48 Getting a type of a variable Maciek Godek
2008-07-19  8:53 ` Andy Wingo
2008-07-20 20:48 ` Ludovic Courtès

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