[plt-scheme] (typeof obj)

From: Robby Findler (robby at cs.uchicago.edu)
Date: Mon Jun 11 10:13:52 EDT 2007

On 6/11/07, Robert Nikander <nikander at nc.rr.com> wrote:
> On Jun 11, 2007, at 9:27 AM, Shriram Krishnamurthi wrote:
> > So you don't really want the type at all: you just want the run-time
> > tag on a value.  (That's what *you* want -- is that what the OP
> > wants?)  I don't find that very useful.  What you want you can write
> > just as well in Scheme:
> >
> > (define (run-time-tag-of v)
> >  (cond
> >    [(number? v) 'number]
> >    [(string? v) 'string]
> >    ...
> >    [(procedure? v) 'procedure]))
> When I originally asked the question I wanted write something like:
> (lambda (object-from-library)
>     (printf "What is it? Answer: ~a ~a" object-from-library (run-time-
> type object-from-library))
>     ...
> Many languages have something like `run-time-type' so I thought there
> might be a similar thing in PLT.  In python it is `type(obj)' and C#
> it is `obj.GetType()'.  And from what Jos Koot said in a previous
> post, the equivalent in PLT would be a procedure that, given any
> Scheme_Object, returns the Scheme_Type.  I'm assuming that
> Scheme_Type is a Scheme_Object.  Is it?  In Python and C#, the type
> objects are objects.
> The value of this to me is more about debugging, and exploring and
> understanding the system, and I wasn't thinking about whether a `run-
> time-type' procedure fit in well with good type theory.  Maybe it
> doesn't, but I don't see a problem.
> The problem I have with your example above is that it won't work as
> new types are added.

Structs are the way to add new types to mzscheme :)

> I don't see a problem with structs, because I imagine type objects
> for different structs would be different type objects and not eq?.
> But type objects would probably have a property `name' that was a
> symbol, which could be eq? to the names of other type objects.
> Rob
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.