From: Logan Lee
Subject: void function error when calling a function
Date: 
Message-ID: <87sle3cjcg.fsf@laptop.at.pyenos>
;; Code
(defun setProblem (ProblemTitle ProblemDesc)
  "Sets values for Problem"
  (setq Problem (ProblemTitle ProblemDesc))
  (message Problem)
)

(setProblem "SampleProblem" "This is a test")

;; Debugger Error Message
Debugger entered--Lisp error: (void-function ProblemTitle)
  (ProblemTitle ProblemDesc)
  (setq Problem (ProblemTitle ProblemDesc))
  setProblem("SampleProblem" "This is a test")
  eval((setProblem "SampleProblem" "This is a test"))
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp)

How do I fix this?
-- 
### Author "Logan Lee" ###
### HomePage http://beam.to/pyenos ###

From: Thomas A. Russ
Subject: Re: void function error when calling a function
Date: 
Message-ID: <ymi64ayex0j.fsf@sevak.isi.edu>
Logan Lee <········@uts.edu.au> writes:

> ;; Code
> (defun setProblem (ProblemTitle ProblemDesc)
>   "Sets values for Problem"
>   (setq Problem (ProblemTitle ProblemDesc))
>   (message Problem)
> )
> 
> (setProblem "SampleProblem" "This is a test")

The problem is that the code 

   (setq Problem (ProblemTitle ProblemDesc))

tells Lisp that it should call the function named ProblemTitle with
ProblemDesc as its argument.  Since there is no such function, you get
an error message.

Now, a couple of style notes:
  Generally, Lisp systems are set up to uppercase all of the input that
they read.  That means that although you may freely write mixed-case
names and identifiers, they will not print that way when lisp prints
them.  That has led to the convention of using hyphens to separate name
components and not case changes.  Thus a more lisp-like way to name
things would be:

   (defun set-problem (problem-title problem-desc) ...)

  Secondly, it is also generally not a good idea to use SETQ on
variables that have not been introduced in some way already.  You should
either use LET to bind a local variable, or declare globally visible
special variables using DEFVAR or DEFPARAMETER.  Also note that by
convention, special variables start and end with the asterisk (*)
character:

    (defparameter *program* nil)

-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Logan Lee
Subject: Re: void function error when calling a function
Date: 
Message-ID: <87odorcifu.fsf@laptop.at.pyenos>
I have modified the code a follows and this one works:

;; Code
(defun setProblem (ProblemTitle ProblemDesc)
  "Sets values for Problem"
  (setq Problem (concat ProblemTitle "\n" ProblemDesc))
  (message Problem)
)

(setProblem "SampleProblem" "This is a test")
-- 
### Author "Logan Lee" ###
### HomePage http://beam.to/pyenos ###
From: Thomas A. Russ
Subject: Re: void function error when calling a function
Date: 
Message-ID: <ymi1wlmewvy.fsf@sevak.isi.edu>
Logan Lee <········@uts.edu.au> writes:

> I have modified the code a follows and this one works:
> 
> ;; Code
> (defun setProblem (ProblemTitle ProblemDesc)
>   "Sets values for Problem"
>   (setq Problem (concat ProblemTitle "\n" ProblemDesc))
>   (message Problem)
> )
> 
> (setProblem "SampleProblem" "This is a test")

OK, this will work, since you are now using an existing function.  In
general, though, you would be more likely, in lisp style, to want to use
LIST instead of CONCAT in your code.

Also, you need to realize that "\n" will just result in the character
"n" being in the string.  It will not be a newline character.  In Lisp,
strings do not have to be on a single line, so if you want a newline
character, then you just write the string

"
"

where the line break is inside the string.


-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: John Thingstad
Subject: Re: void function error when calling a function
Date: 
Message-ID: <op.tmkj68qfpqzri1@pandora.upc.no>
On Mon, 22 Jan 2007 14:14:13 +0100, Logan Lee <········@uts.edu.au> wrote:

> I have modified the code a follows and this one works:
>
> ;; Code
> (defun setProblem (ProblemTitle ProblemDesc)
>   "Sets values for Problem"
>   (setq Problem (concat ProblemTitle "\n" ProblemDesc))
>   (message Problem)
> )
>
> (setProblem "SampleProblem" "This is a test")

Don't know where concat came from..
How about:

(format nil "~A~%~A" ProblemTitle ProblemDesc)

1.
Camel-case is not a good thing.
By default Lisp is not case sensitive.
set-problem, problem-title, problem-decription

2.
End parentesis on last line. Don't put parentesis on seperate lines.
This messes up the standerd indentation convention and makes working
the code (and sometimes reading it) more difficult.

3.
Use setf rather than setq.
It is more modern and general. Besides setq behaves wierd for special  
variables..

4.
Functional is better. Avoid external variables if you can.
Global variables shold be surronded by asterix like this: *my-global-var*
to set them off.

example:

(defun problem (title description)
   (let ((problem (format nil "~A~%~A" title description)))
     (message problem)
     problem))

(setf *problem* (problem "SampleProblem" "This is a Test.")

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: Pascal Bourguignon
Subject: Re: void function error when calling a function
Date: 
Message-ID: <87k5zenaw5.fsf@thalassa.informatimago.com>
"John Thingstad" <··············@chello.no> writes:

> On Mon, 22 Jan 2007 14:14:13 +0100, Logan Lee <········@uts.edu.au> wrote:
>
>> I have modified the code a follows and this one works:
>>
>> ;; Code
>> (defun setProblem (ProblemTitle ProblemDesc)
>>   "Sets values for Problem"
>>   (setq Problem (concat ProblemTitle "\n" ProblemDesc))
>>   (message Problem)
>> )
>>
>> (setProblem "SampleProblem" "This is a test")
>
> Don't know where concat came from..

emacs lisp.

> How about:
>
> (format nil "~A~%~A" ProblemTitle ProblemDesc)
>
> 1.
> Camel-case is not a good thing.
> By default Lisp is not case sensitive.
> set-problem, problem-title, problem-decription

emacs lisp is case sensitive thought.

> 2.
> End parentesis on last line. Don't put parentesis on seperate lines.
> This messes up the standerd indentation convention and makes working
> the code (and sometimes reading it) more difficult.
>
> 3.
> Use setf rather than setq.
> It is more modern and general. Besides setq behaves wierd for special
> variables..

You'd need to (require 'cl) first, in emacs lisp.

> 4.
> Functional is better. Avoid external variables if you can.
> Global variables shold be surronded by asterix like this: *my-global-var*
> to set them off.
>
> example:
>
> (defun problem (title description)
>   (let ((problem (format nil "~A~%~A" title description)))
>     (message problem)
>     problem))
>
> (setf *problem* (problem "SampleProblem" "This is a Test.")


emacs lisp questions are best asked on news:gnu.emacs.help


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"I have challenged the entire quality assurance team to a Bat-Leth
contest.  They will not concern us again."
From: John Thingstad
Subject: Re: void function error when calling a function
Date: 
Message-ID: <op.tmkkxrdepqzri1@pandora.upc.no>
On Mon, 22 Jan 2007 20:01:46 +0100, Pascal Bourguignon  
<···@informatimago.com> wrote:

>>
>> Don't know where concat came from..
>
> emacs lisp.

Oops! Missed that!

> emacs lisp questions are best asked on news:gnu.emacs.help

or comp.emacs

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/