[plt-scheme] (typeof obj)

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

Wow - some great responses on the thread - I have some more questions to
chime in and hopefully it's not too late ;)

On 6/11/07, Chongkai Zhu <czhu at cs.utah.edu> wrote:
> Yes, at the C level, MzScheme knows the type tag. But, on the Scheme
> level, everything is suppose to be transparent.

If scheme's type is really supposed to be transparent, I would venture that
it isn't - because if it is, then I shouldn't have to test for types to call
the right procedures, or write separate procedures that essentially do the
same thing for different types (i.e. no built-in generic programming).

On 6/11/07, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
> > What is the type of ADD1?  What is the type of CALL/CC?  How
> > about of (lambda (x) x)?  Or
> >   (let ([x 3])
> >     (lambda (y)
> >       (when (= (random 2) 0)
> >           (set! x y))
> >      x))
> > ?

Shouldn't mzscheme know the answer to these questions?  It seems possible
within Haskell or Ocaml to infer the types - below is my attempt but I
probably have the syntax wrong.

add1 is int -> int
(lambda (x) x) is any -> any
I don't understand enough about call/cc so I won't attempt ;)
(let ((x 3)) (lambda (y) (when (= (random 2) 0) (set! x y)) x)) can be void
-> (any -> (union int any))

And the contract system does allow such specifications manually - running
(add1 "a") returns a run-time type mismatch error.

> PS: In general, when asking questions about "every object" in
> >     a language like Scheme, it's imperative to remember the
> >    higher-order values also.

Does this mean that Scheme doesn't know about the higher order value
itself?  This might be where my gap is - from my perspective as a user, I am
used to having the language platform knows about the types of the values,
and externally observing scheme's behavior - it does know.

On 6/11/07, Jos Koot <jos.koot at telefonica.net> wrote:
> It appears to me that there is even no agreement about what the type of a
> would have to be, let alone the question when two types are the same ;)
> take notice that (as a fan of PLT) I am quite content with PLT's system of
> predicates, those for structs and object-classes included.

I am also a fan and my reason to ask these questions is to understand how
scheme's way work better (or worse, but I hope it's the former :P) than say
C# or Python's way.  My current feeling is that Scheme's type system
requires explicit handling where I am used to handling implicitly.  Perhaps
as shown in the thread
http://www.cs.brown.edu/pipermail/plt-scheme/2007-May/018457.html this
approach allows for type research and experimentations at the expense of
normal programming - and if this is a conscious design decision, that's fine
- I am just trying to understand ;)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070611/af933557/attachment.html>

Posted on the users mailing list.