Reputation: 337
Is it possible to use an uninitialized variable as a function argument? For an assignment, I have to use the CLOS to write a semantic network system, and my professor included a test function to test our output, and one of them specifies:
(print (def-concept Human))
,
which implies passing the argument Human to the function def-concept. When running this test function, I cannot get away from the error (in Allegro CL):
Error: Attempt to take the value of the unbound variable
HUMAN'.`
As this is the first function in the test, there is no initializing of any variables before this. Is there any way to get around passing an uninitialized variable as an argument of a function?
Thanks in advance.
Upvotes: 2
Views: 3303
Reputation: 58500
It is not possible to use an unitialized value as a function argument in a regular Common Lisp function call. Common Lisp uses eager evaluation: argument expressions are reduced to their values before the function call takes place.
I suspect maybe you don't exactly understand the structure of the homework assignment.
If def-concept
is a function which expects a value, and human
is not defined, you simply cannot test that function.
Perhaps you are expected to define the variable human
and then load the file containing (print (def-concept human))
.
Just because there is nothing prior to that form in the same file doesn't mean that no prior evaluation is possible. Other files can be loaded before that file, or forms evaluated in the listener.
Upvotes: 4