[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting a type of a variable

From: Maciek Godek
Subject: Getting a type of a variable
Date: Fri, 18 Jul 2008 23:48:12 +0200

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]