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

From: Benjamin L.Russell (DekuDekuplex at Yahoo.com)
Date: Tue Oct 14 06:39:41 EDT 2008

On Tue, 14 Oct 2008 10:26:47 +0100, "Noel Welsh"
<noelwelsh at gmail.com> wrote:

>On Tue, Oct 14, 2008 at 8:11 AM, Benjamin L. Russell
><DekuDekuplex at yahoo.com> wrote:
>> As an experiment, I would like to write the "hello_world" function in
>> Typed Scheme, but am having difficulty with the type annotation.
>Scheme style is hello-world, not hello_world.

Oops!  You're right!  You got me there.... :-P

> 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.

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

>(: 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?

-- Benjamin L. Russell

Posted on the users mailing list.