I am using Allegro Common Lisp from Franz, Inc. I understand some
Scheme already, but have not used an interpreter for Lisp yet. This is
my first try.
I tried a sample program as follows:
(in-package: user)
(defun hello()
(write-string "Hello, World!"))
Then, on the terminal/command prompt, I did:
CL-USER(1): (compile-file "relative/path/to/myfile.lisp")
and it compiled successfully generating a .fasl file.
I understand that code above and know what's happening. I am following
the book 'Basic Lisp Techniques'.
Then, I loaded that file (say, it's called myfile.lisp, which got me a
myfile.fasl) like so:
CL-USER(2): (load "relative/path/to/myfile.lisp")
and it did load the file displaying a message to the effect.
Now, I am not sure how I'd execute the function hello. I tried saying:
CL-USER(3): (hello)
and it gives me the following error:
Error: attempt to call `HELLO' which is an undefined function.
[condition type: UNDEFINED-FUNCTION]
which, from the looks of it, I understand as the function hello() that
I wrote did not get into some symbol table or something and so the
interpreter can't find it.
What am I missing here?
"Sathyaish" <·········@gmail.com> writes:
> What am I missing here?
The things you wrote do not make sense. It looks as though you wrote
something similar, but not exactly the same, into your Lisp source
file and Lisp REPL. Try pasting the exact contents of the source file
and your exact REPL session; that will make it easier to find the
problem.
Zach
Sathyaish wrote:
> I am using Allegro Common Lisp from Franz, Inc. I understand some
> Scheme already, but have not used an interpreter for Lisp yet. This is
> my first try.
>
> I tried a sample program as follows:
>
> (in-package: user)
You probably want that to be (in-package :cl-user)
kt
>
> (defun hello()
> (write-string "Hello, World!"))
>
> Then, on the terminal/command prompt, I did:
>
> CL-USER(1): (compile-file "relative/path/to/myfile.lisp")
>
> and it compiled successfully generating a .fasl file.
>
> I understand that code above and know what's happening. I am following
> the book 'Basic Lisp Techniques'.
>
> Then, I loaded that file (say, it's called myfile.lisp, which got me a
> myfile.fasl) like so:
>
> CL-USER(2): (load "relative/path/to/myfile.lisp")
>
> and it did load the file displaying a message to the effect.
>
> Now, I am not sure how I'd execute the function hello. I tried saying:
>
> CL-USER(3): (hello)
>
> and it gives me the following error:
>
> Error: attempt to call `HELLO' which is an undefined function.
> [condition type: UNDEFINED-FUNCTION]
>
>
> which, from the looks of it, I understand as the function hello() that
> I wrote did not get into some symbol table or something and so the
> interpreter can't find it.
>
> What am I missing here?
>
--
Cells: http://common-lisp.net/project/cells/
"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
Ken Tilton wrote:
>
>
> Sathyaish wrote:
>
>> I am using Allegro Common Lisp from Franz, Inc. I understand some
>> Scheme already, but have not used an interpreter for Lisp yet. This is
>> my first try.
>>
>> I tried a sample program as follows:
>>
>> (in-package: user)
>
>
> You probably want that to be (in-package :cl-user)
No, I see that /is/ a nickname for cl-user on ACL.
After loading, when you think hello should be there, try this at the
repl: (apropos "HELLO")
Look for your function in the output. It might be in a different
package. If it is not there at all, you have not compiled/loaded what
you think you have.
kt
>
> kt
>
>>
>> (defun hello()
>> (write-string "Hello, World!"))
>>
>> Then, on the terminal/command prompt, I did:
>>
>> CL-USER(1): (compile-file "relative/path/to/myfile.lisp")
>>
>> and it compiled successfully generating a .fasl file.
>>
>> I understand that code above and know what's happening. I am following
>> the book 'Basic Lisp Techniques'.
>>
>> Then, I loaded that file (say, it's called myfile.lisp, which got me a
>> myfile.fasl) like so:
>>
>> CL-USER(2): (load "relative/path/to/myfile.lisp")
>>
>> and it did load the file displaying a message to the effect.
>>
>> Now, I am not sure how I'd execute the function hello. I tried saying:
>>
>> CL-USER(3): (hello)
>>
>> and it gives me the following error:
>>
>> Error: attempt to call `HELLO' which is an undefined function.
>> [condition type: UNDEFINED-FUNCTION]
>>
>>
>> which, from the looks of it, I understand as the function hello() that
>> I wrote did not get into some symbol table or something and so the
>> interpreter can't find it.
>>
>> What am I missing here?
>>
>
--
Cells: http://common-lisp.net/project/cells/
"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
Sathyaish wrote:
> What am I missing here?
Are you absolutely sure that you don't get any error messages whatsoever
when compiling and/or loading your program?
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
(message (Hello 'Sathyaish)
(you :wrote :on '(4 Dec 2006 08:54:19 -0800))
(
S> I tried a sample program as follows:
S> (in-package: user)
S> (defun hello()
S> (write-string "Hello, World!"))
if that's exactly what you wrote, you have a syntax error here.
i think the problem that in graphical allegro REPL's package is CG-USER, but
not CL-USER.
AllegroCL8.0 breaks into debugger suggesting restart call CL-USER::HELLO, so
it looks like you're not only one having this problem :).
you can switch repl's package:
CG-USER(5): (in-package :cl-user)
#<The COMMON-LISP-USER package>
CL-USER(6): (hello)
Hello, World!
"Hello, World!"
)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"People who lust for the Feel of keys on their fingertips (c) Inity")
Alex Mizrahi wrote:
> (message (Hello 'Sathyaish)
> (you :wrote :on '(4 Dec 2006 08:54:19 -0800))
> (
>
> S> I tried a sample program as follows:
>
> S> (in-package: user)
>
> S> (defun hello()
> S> (write-string "Hello, World!"))
>
> if that's exactly what you wrote, you have a syntax error here.
>
> i think the problem that in graphical allegro REPL's package is CG-USER, but
> not CL-USER.
But the post indicated they were being prompted with CL-USER as the
current package.
> CL-USER(1): (compile-file "relative/path/to/myfile.lisp")
...
> CL-USER(2): (load "relative/path/to/myfile.lisp")
...
> Now, I am not sure how I'd execute the function hello. I tried saying:
>
> CL-USER(3): (hello)
kt
--
Cells: http://common-lisp.net/project/cells/
"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
(message (Hello 'Ken)
(you :wrote :on '(Mon, 04 Dec 2006 14:10:15 -0500))
(
??>> i think the problem that in graphical allegro REPL's package is
??>> CG-USER, but not CL-USER.
KT> But the post indicated they were being prompted with CL-USER as the
KT> current package.
text of post was not copied from repl but typed from scratch (there is at
least one typo that makes file incompilable), so most likely OP thinks that
it's CL-USER so he typed CL-USER, but repl actually shows him CG-USER.
)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"People who lust for the Feel of keys on their fingertips (c) Inity")
Alex Mizrahi wrote:
> (message (Hello 'Ken)
> (you :wrote :on '(Mon, 04 Dec 2006 14:10:15 -0500))
> (
>
> ??>> i think the problem that in graphical allegro REPL's package is
> ??>> CG-USER, but not CL-USER.
>
> KT> But the post indicated they were being prompted with CL-USER as the
> KT> current package.
>
> text of post was not copied from repl but typed from scratch (there is at
> least one typo that makes file incompilable), so most likely OP thinks that
> it's CL-USER so he typed CL-USER, but repl actually shows him CG-USER.
>
> )
Clever, Watson, and a one-character mistake would be easy to miss. But
just because some part is typed does not mean everything is typed, and I
would be astonished if they typed the entire cl-user> prompt by hand
instead of a simple -> or >> or > or nothing at all. More telling is
that CG-USER would mean they are using the windows version, the only
platform with Common-graphics, and that is unlikely since they are
compiling and loading with lisp forms instead of the IDE available on
windows.
Over to you. :)
kt
--
Cells: http://common-lisp.net/project/cells/
"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
Ken Tilton wrote:
>
>
> Alex Mizrahi wrote:
>
>> (message (Hello 'Ken)
>> (you :wrote :on '(Mon, 04 Dec 2006 14:10:15 -0500))
>> (
>>
>> ??>> i think the problem that in graphical allegro REPL's package is
>> ??>> CG-USER, but not CL-USER.
>>
>> KT> But the post indicated they were being prompted with CL-USER as the
>> KT> current package.
>>
>> text of post was not copied from repl but typed from scratch (there is
>> at least one typo that makes file incompilable), so most likely OP
>> thinks that it's CL-USER so he typed CL-USER, but repl actually shows
>> him CG-USER.
>>
>> )
>
>
> Clever, Watson, and a one-character mistake would be easy to miss. But
> just because some part is typed does not mean everything is typed, and I
> would be astonished if they typed the entire cl-user> prompt by hand
> instead of a simple -> or >> or > or nothing at all. More telling is
> that CG-USER would mean they are using the windows version, the only
> platform with Common-graphics, and that is unlikely since they are
> compiling and loading with lisp forms instead of the IDE available on
> windows.
Oh, and the backtrace says "..undefined. Would you like to use
cl-user::hello instead?" (tho they might not have read the backtrace).
kt
--
Cells: http://common-lisp.net/project/cells/
"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
Thanks for your replies, friends. You were all right. The mistake was
that I'd typed cl-user in the source code file but the second time I
opened the Allegro CL IDE, the packaged had changed and the prompt was
CG-USER. Only later did I notice, upon your suggestion, that the
terminal read something to that affect, "changing package to
graphics...".
I changed my source file to use CG-USER then. Now I also know, from
reading last night and from your replies to this thread, that I could
also have changed the current package loaded by the interpreter by
saying, "(in-package CL-USER)" on the terminal prompt.
Just another question. All of you have been using the abbreviation REPL
with the qualifier 'Lisp' as Lisp REPL. I understand you are simply
referring to the read-eval-print-loop here and not any specific
implementation of Common Lisp. Is this correct?
"Sathyaish" <·········@gmail.com> writes:
> Just another question. All of you have been using the abbreviation REPL
> with the qualifier 'Lisp' as Lisp REPL. I understand you are simply
> referring to the read-eval-print-loop here and not any specific
> implementation of Common Lisp. Is this correct?
yes.
Pedro Kroger
Sathyaish wrote:
> Thanks for your replies, friends. You were all right. The mistake was
> that I'd typed cl-user in the source code file but the second time I
> opened the Allegro CL IDE, the packaged had changed and the prompt was
> CG-USER.
When you start ACL it asks you about using a project. Next time, say
"Create a new project". Well, OK, it's under the file menu, you do not
need to restart. It will ask for a project name. Answer "hello", after
navigating to a directory where you would like to keep all your projects.
Open hello.cl (using \recent\load file\hello.cl) and right-click on the
window and choose "add to project". It will offer to copy or move it to
your project directory. I suggest "move", who needs all these little
files lying around you might accidentally edit thinking you were editing
the right one?
In the project manager, click on the options tab and set the package to
cl-user and the init-fn to hello. If it does not echo as cl-user::hello
you did something wrong.
If you do plan to use their CG GUI, just start using that in your code
the way others use cl-user. If not, go to \tools\options\ide1 and change
the package to which the listener opens (to cl-user). also slide over to
the editor tab and set the editor to emacs mode. Slide over to the
project tab and set "open project action" to compile as needed and "run
proj action" to save and compile as needed.
Go back to hello.cl, change it to say "Thanks Kenny!", then without
saving or doing anything else just hit control-shift-r.
Look in the listener, confirm it all worked, and evaluate "You are
welcome" for me.
hth, kzo
--
Algebra: http://www.tilton-technology.com/LispNycAlgebra1.htm
"Well, I've wrestled with reality for thirty-five
years, Doctor, and I'm happy to state I finally
won out over it." -- Elwood P. Dowd
"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
Sathyaish wrote:
> "Yay! Thanks, Kenny!"
>
Awesome. Now whenever you cannot believe your eyes because you know
something is there, it may well be a package problem. so...
put the caret on hello. if you do not have the string handy, do what I
do: alt-comma to bring up the "find in files dialog and just type hello
but not not enter. then hit control-shift-a. this looks for any symbol
with hello anywhere in its name in any case in any package. if it finds
too many, in your case (you know you are looking for a function) you
could check "functions" to narrow the search. /not/ in your case, you
could check exported-only to narrow further (you did not export hello).
apropos is also a great way to find a function you merely suspect must
exist in CL by saying, say, if you are doing some hairy clos, (apropos
"slot").
Once you find the line in the output of apropos that is your function,
click on it and type control-alt-. (that's a full stop). You should now
be looking at your code for hello. alt-. alone would call up a
definitions dialogue you can paly with and use to remove methods.
then...
:)
kt
--
Algebra: http://www.tilton-technology.com/LispNycAlgebra1.htm
"Well, I've wrestled with reality for thirty-five
years, Doctor, and I'm happy to state I finally
won out over it." -- Elwood P. Dowd
"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
"Alex Mizrahi" <········@users.sourceforge.net> writes:
> text of post was not copied from repl but typed from scratch (there is at
> least one typo that makes file incompilable), so most likely OP thinks that
> it's CL-USER so he typed CL-USER, but repl actually shows him CG-USER.
Perhaps this would be a good time to remember DRIBBLE.
This is an underused function.
(dribble "some-file.dribble")
will save in the file "some-file.dribble" all the REPL input and
output, so you can easily copy-and-paste dribblings.
And with the cheap cost of nowadays disk storage, here is what I have
in my ~/.common.lisp (loaded from the various ~/.clisprc.lisp,
~/.sbclrc, etc):
(let ((path
(merge-pathnames
(make-pathname
:directory '(:relative "DRIBBLES")
:name (FLET ((IMPLEMENTATION-ID ()
(FLET ((FIRST-WORD (TEXT)
(LET ((POS (POSITION (CHARACTER " ") TEXT)))
(REMOVE (CHARACTER ".")
(IF POS (SUBSEQ TEXT 0 POS) TEXT)))))
(FORMAT NIL
"~A-~A-~A"
(FIRST-WORD (LISP-IMPLEMENTATION-TYPE))
(FIRST-WORD (LISP-IMPLEMENTATION-VERSION))
(FIRST-WORD (MACHINE-TYPE))))))
(multiple-value-bind (se mi ho da mo ye)
(decode-universal-time (get-universal-time))
(format nil "~4,'0D~2,'0D~2,'0DT~2,'0D~2,'0D~2,'0D-~A"
ye mo da ho mi se (implementation-id))))
:type "DRIBBLE"
:version nil
:defaults (user-homedir-pathname))
(user-homedir-pathname) nil)))
(ensure-directories-exist path)
(dribble path))
So I save all my lisp sessions.
--
__Pascal Bourguignon__ http://www.informatimago.com/
WARNING: This product attracts every other piece of matter in the
universe, including the products of other manufacturers, with a
force proportional to the product of the masses and inversely
proportional to the distance between them.
Sathyaish <·········@gmail.com> wrote:
+---------------
| Then, on the terminal/command prompt, I did:
| CL-USER(1): (compile-file "relative/path/to/myfile.lisp")
| and it compiled successfully generating a .fasl file.
...
| Then, I loaded that file (say, it's called myfile.lisp, which got me a
| myfile.fasl) like so:
| CL-USER(2): (load "relative/path/to/myfile.lisp")
+---------------
Are you sure you didn't mean to type this here?
(load "relative/path/to/myfile.fasl")
-Rob
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
> Are you sure you didn't mean to type this here?
> (load "relative/path/to/myfile.fasl")
Yes. I had typed that example into this forum by hand. In the actual
source, I specified the actual path on my machine.