Sorry, missed another one.

On Tue, Dec 27, 2011 at 2:24 PM, Nala Ginrut <nalagin...@gmail.com> wrote:

> A newbie Guiler asked me if there's something like "typeof" as "type" in
> Python or "typeof" in JS.
> I can't remember there's such a thing. But I think it'll provide
> some convenient for a newbie to learn Guile.
> Here's my patch.
> What you guys think?
>
From 6075ad414b8c11a17647beef46d9e2dad3f3e110 Mon Sep 17 00:00:00 2001
From: NalaGinrut <nalagin...@gmail.com>
Date: Tue, 27 Dec 2011 14:18:49 +0800
Subject: [PATCH 1/2] ADD type-of to boot-9.scm

---
 module/ice-9/boot-9.scm |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 03dad9b..43fce1c 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -3851,4 +3851,14 @@ module '(ice-9 q) '(make-q q-length))}."
 ;; `-Wunused-toplevel' warning works as expected.
 (eval-when (compile) (set-current-module the-root-module))
 
+(define (type-of x)
+  (cond 
+   ((eq? x *undefined*) '<undefined>)
+   ((null? x) '<object>)
+   ((boolean? x) '<boolean>)
+   ((number? x) '<number>)
+   ((string? x) '<string>)
+   ((procedure? x) '<function>)
+   (else '<scm>)))
+        
 ;;; boot-9.scm ends here
-- 
1.7.0.4

Reply via email to