This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Newbie problem - defun

3 posts · 3585 views

Following is from my CCL REPL:
? (defun my-half (x)
  (* (x 0.5)))

;Compiler warnings :
;   In MY-HALF: Undefined function X
;   In MY-HALF: Unused lexical variable X
MY-HALF
? (my-half 8)
> Error: Undefined function X called with arguments (0.5) .
> While executing: MY-HALF, in process Listener(4).
> Type cmd-/ to continue, cmd-. to abort, cmd-\ for a list of available restarts.
> If continued: Retry applying X to (0.5).
> Type :? for other options.
1 > q
? 
I'm obviously missing something REALLY basic, but I just don't see it:(

Thanx - Charlie

Re: Newbie problem - defun

In Lisp, the first token after an opening parenthesis, '(', is generally a function or macro.

In your example, you wrote "(* (x 0.5))". By default, there is no function named "x". You meant to write "(* x 0.5)".

Common issue when you're starting.

In Common Lisp, the variable "x" can have both a function value and a normal value.
In Scheme, the system would have complained that the value 8 was not a function.

Re: Newbie problem - defun

Nuntius,

That was it.

Thanx - Charlie