From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Maciek Godek" Newsgroups: gmane.lisp.guile.user Subject: Getting a type of a variable Date: Fri, 18 Jul 2008 23:48:12 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1216417708 27469 80.91.229.12 (18 Jul 2008 21:48:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Jul 2008 21:48:28 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Jul 18 23:49:16 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KJxpC-0003hR-4f for guile-user@m.gmane.org; Fri, 18 Jul 2008 23:49:14 +0200 Original-Received: from localhost ([127.0.0.1]:45676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJxoJ-0000YH-CW for guile-user@m.gmane.org; Fri, 18 Jul 2008 17:48:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KJxoG-0000XF-44 for guile-user@gnu.org; Fri, 18 Jul 2008 17:48:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KJxoE-0000Vj-HQ for guile-user@gnu.org; Fri, 18 Jul 2008 17:48:15 -0400 Original-Received: from [199.232.76.173] (port=54517 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJxoE-0000Ve-CM for guile-user@gnu.org; Fri, 18 Jul 2008 17:48:14 -0400 Original-Received: from wf-out-1314.google.com ([209.85.200.173]:45936) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KJxoE-0005nq-2y for guile-user@gnu.org; Fri, 18 Jul 2008 17:48:14 -0400 Original-Received: by wf-out-1314.google.com with SMTP id 28so295271wfc.24 for ; Fri, 18 Jul 2008 14:48:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=bdU9jZ29v3xZJe1YsXK5uABwyF5lSu2Hea6nWQ8Uez8=; b=nKHwVB3RQxz2hPHtM8ImVseDRG3jz/ulaDm3e86tuwMD/UoKYHEo3kfQrGT24TLnrG IwgkYgbDAhJSWdW85SWk0AXAMEAhpLomaDlF5FMA3KZ8dLpsf4G89WZWPGr1IuOKTtBX jEtAHJcT+12Cvnt9NmENTIPPlfAJrscQorjJE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=lQRfGsBfO8fzVNBkRXl9Jd8qZT+kDwcnq3lGhDcmqLO57UnnPU2kS2qxbD2+0vEjjR q/gX8gyEOTftCQhLNNimHYwDOtkUUNGtu0/NWih4rkQxY+B1q8jsu+gC3b83NyfzIS6h OxXneEptvnkyYu3q1Dn/slE5VdpL/813gWenM= Original-Received: by 10.142.52.9 with SMTP id z9mr215117wfz.258.1216417692505; Fri, 18 Jul 2008 14:48:12 -0700 (PDT) Original-Received: by 10.142.133.13 with HTTP; Fri, 18 Jul 2008 14:48:12 -0700 (PDT) Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6675 Archived-At: 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