[plt-scheme] (typeof obj)

From: YC (yinso.chen at gmail.com)
Date: Mon Jun 11 01:49:30 EDT 2007

Agreed that it would be implementation dependent, but if the type info has
to be calculated every time on the fly it can be both inefficient and
incorrect (if all values are just bytes, it could satisfy more than one
disjointed types that lead to incorrect semantics), hence I venture that
Scheme value has type attached - but sure would love to be enlightened on
this point.

Regarding whether a list of number is a list or a list of numbers - I can
see that comes up with either predicates or type info, so don't see a
disadvantage one way or another, but predicate-based approach just makes
type dispatching more manual.

Anyhow - just wondering about the reason(s) not to provide type info - sure
love to know the historical design decisions ;)

Thanks,
yinso

On 6/10/07, Jos Koot <jos.koot at telefonica.net> wrote:
>
>  ----- Original Message -----
>
> *From:* YC <yinso.chen at gmail.com>
> *To:* Jos Koot <jos.koot at telefonica.net> ; PLT Scheme List<plt-scheme at list.cs.brown.edu>; Robert
> Nikander <nikander at nc.rr.com>
> *Sent:* Monday, June 11, 2007 12:47 AM
> *Subject:* Re: [plt-scheme] (typeof obj)
>
> This is something I wonder as well... given that internally Scheme *does
> know* about the type of a value, why isn't there a function that expose the
> information?  Type-based dispatching is after all a legitimate development
> technique.
>
> I am not sure whether or not Scheme *does know* THE type of a value. I am
> sure the PLT team has more knowledge of that. My way of looking at it is
> that there are predicates that know whether or not a value satisfies them.
> Furthermore there is the question how far you want to go in specifying the
> type. Is a list of numbers simply a list or is it 'a list of numbers'? The
> number of predicates you may think of is unlimited.
> Jos Koot
>
> Thanks,
> yinso
>
> On 6/10/07, Jos Koot <jos.koot at telefonica.net> wrote:
> >
> >
> > ----- Original Message -----
> > From: "Robert Nikander" <nikander at nc.rr.com>
> > To: "PLT Scheme List" < plt-scheme at list.cs.brown.edu>
> > Sent: Sunday, June 10, 2007 6:28 PM
> > Subject: [plt-scheme] (typeof obj)
> >
> >
> > > Is there a way to get a type-name symbol or type object for
> > any  scheme
> > > object?
> >
> > Of course there is a way, but you may not like it:
> >
> > (define (types-of x) (filter identity (map (lambda (predicate typename)
> > (and
> > (predicate x) type-name)) predicates type-names)))
> > (define predicates (list integer? procedure?, etc)
> > (define type-names '(integer procedure, etc))
> >
> > Of course the procedure returns a list of types, for a 1 is an integer,
> > a
> > rational, a real and a complex number.
> > You also can think of adapting procedure make-struct-type, such as to
> > add their
> > predicates and names to the lists.
> > Same for define-struct, let-struct ...
> > Same for classes.
> >
> > If you want only one type returned in stead of a list, two conditions
> > must be
> > met:
> > First: for every two types A and B either A and B disjunct or A a subset
> > of B or
> > B a subset of A.
> > Second: carefully compose the lists of predicates and their names.
> > Jos Koot
> >
> > >
> > > (type 1) => 'integer
> > >
> > > or
> > >
> > > (type 1) => #<type integer>
> > > (type (type x)) => #<type type>
> > >
> > >
> > > Rob
> > > _________________________________________________
> > >  For list-related administrative tasks:
> > >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > >
> >
> > _________________________________________________
> >   For list-related administrative tasks:
> >    http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070610/5c241440/attachment.html>

Posted on the users mailing list.