Hello World in Lisp

Started by
4 comments, last by Samith 20 years, 1 month ago
I''m using Corman Lisp as my compiler/interpretter/LISP thing, and I want to make a hello world program, like....an actually executable and everything. Basically, my problem is that I don''t know how to compile. This is what my source code looks like:

(defun main ()
    (print (''hello)))

(main)

(save-application "hello.exe" ''main)
Pretty simple looking, but it doesn''t work at all. Well, maybe it does, and I just can''t tell. Anyway, what''s happening is I''m getting a huge 1.1mb exe that does nothing. I run it (from the command line, just to make sure it''s not starting up and then closing faster than I can see it) and it does....well....nothing! So if anyone knows what I''m doing wrong, your help would be great, thanks.
Advertisement
I''ve never done an .exe with Lisp, but I question: why do you have (main)? Isn''t that like calling main during the start-up phase?

Anyway, you would need to open up a window or a console to actually see something, I believe. I don''t know how to do that, but there are ways to access the Win32 API from Lisp. You can call any C function, in fact. Look at the help.

If you want a simpler deal, write your Hello World to a file instead.

Cédric
(print "hello world")


That should be sufficient for lisp.

You can expect a large executable.

Also- why don''t you get clisp?
Its the standard.

I would expect compiling syntax would be....

c:>lisp -o hello.lsp
(compiling messages if errors/warnings)
c:>

Might be -c or something, but it should approximate that.

Anyway: in future, ask lisp questions in the AI forum- they speak with a lishp over there.
~V'lionBugle4d
I suspect the problem is that you're not passing enough parameters to the (save-application) function.
quote:Corman Lisp documentation
SAVE-APPLICATION application-name start-function [function] &key (console nil) (static nil)
(emphasis mine)

I think you probably just need to put true in for the console parameter.
I'm only getting this from the docs though, not from experience, so I might be wrong.

quote:Original post by Vlion
Anyway: in future, ask lisp questions in the AI forum- they speak with a lishp over there.

Actually, it's probably better to ask AI questions in the AI forum, and lisp questions in the general programming forum. That way, the names of the forums will actually be related to their content.

John B

[edited by - JohnBSmall on February 28, 2004 9:30:37 PM]
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
I''m not a LISP expert, BUT one rule of thumb for LISP ==

1) YOU CAN NEVER HAVE TOO MANY PARENTHESIS ( ( ) )!

Dam you Lisp and your evil ways!

Also, Hello World is not what Lisp is really about ... Learn List Comprehension

"Arguing on the Internet is like winning in the Special Olympics, in the end, you''''re still retarded"
"Arguing on the Internet is like winning in the Special Olympics, in the end, you''re still retarded"
(defun main ()    (print "Hello World!")    (force-output))(save-application  "d:\\1\\hello" ''main :console t :static t)


It took me a while until I found the force-output function in some examples in the corman lisp program directory.

The original post has a few errors. First, you should have written (print ''hello). By writing (''hello) you try to call the hello symbol as a function - which is wrong. Also you don''t need to execute the function main - third line - (main).

I added the :console t key parameter to say that I want a console app and the :static t one to make sure no Corman Lisp dll is required to run the program. There''s also a path for the resulting exe file - you may want to change that.

This topic is closed to new replies.

Advertisement