[plt-scheme] Re: What is the type of the "hello_world" function in Typed Scheme?

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Oct 14 07:05:11 EDT 2008

On Oct 14, Benjamin L.Russell wrote:
> On Tue, 14 Oct 2008 10:26:47 +0100, "Noel Welsh"
> <noelwelsh at gmail.com> wrote:
> > Anyway, here's the answer:
> >
> >#lang typed-scheme
> >
> >(: hello-world Void)
> >(define hello-world
> >  (display "Hello, world"))
> A minor point: The result is identical, whether "\n" appears at the
> end of the displayed string, or not.  I got the same result with
> "printf" as well.  With "write," the "\n" is displayed as the escape
> sequence itself (rather than the newline indicated by the escape
> sequence) if specified.

This is due to the way that DrScheme shows its prompt -- always on a
new line.  (It wouldn't make sense for it to show the prompt on the
same line after some random output.)

> Do you know any way to display exactly the characters specified in the
> argument string, without automatically appending a newline at the end?

Because the newline is part of DrScheme's REPL presentation there is
no way to avoid the newline.  But if you add a second newline, you
will see an empty line.

> >(: hello-world-function (-> Void))
> >(define (hello-world-function)
> >  (display "Hello world."))
> I tried this one out, but it didn't print anything.  The same result
> occurred when "display" was substituted with "write," and with
> "printf," as well.
> Do you know how to rewrite this function in a way that its behavior is
> identical to "hello-world"; i.e., in a way that actually prints the
> argument string specified?

You still need to call the function:

  #lang typed-scheme
  (: hello-world-function (-> Void))
  (define (hello-world-function)
    (display "Hello world."))

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.