From: Rogue Noir
Subject: The "Illegal Function Object" that won't go away
Date: 
Message-ID: <tF19b.2851$XX1.1317@newssvr29.news.prodigy.com>
How would I fix the following code?  I hear you need funcall or function but
I don't know how to implement those:

(setq dummy (make-test :value (- 1 (random 2.0))))

From: Paul F. Dietz
Subject: Re: The "Illegal Function Object" that won't go away
Date: 
Message-ID: <5uGcnQZaMZ27JfmiXTWJlg@dls.net>
Rogue Noir wrote:
> How would I fix the following code?  I hear you need funcall or function but
> I don't know how to implement those:
> 
> (setq dummy (make-test :value (- 1 (random 2.0))))

I would *guess* TEST is a structure type with field VALUE that
has type FUNCTION, in which case you're initializing that field
with a value of the wrong type, but you haven't given us enough
information.

	Paul
From: Rogue Noir
Subject: Re: The "Illegal Function Object" that won't go away
Date: 
Message-ID: <Pd39b.2856$Dz2.2356@newssvr29.news.prodigy.com>
I never specified any type for 'value' so I'm now hoping the default is what
I want..

I'm very new to LISP..  basically what I want to do is to assign a random
number to the field 'value' in that structure.

"Paul F. Dietz" <·····@dls.net> wrote in message
···························@dls.net...
> Rogue Noir wrote:
> > How would I fix the following code?  I hear you need funcall or function
but
> > I don't know how to implement those:
> >
> > (setq dummy (make-test :value (- 1 (random 2.0))))
>
> I would *guess* TEST is a structure type with field VALUE that
> has type FUNCTION, in which case you're initializing that field
> with a value of the wrong type, but you haven't given us enough
> information.
>
> Paul
>
>
From: Paul F. Dietz
Subject: Re: The "Illegal Function Object" that won't go away
Date: 
Message-ID: <yIycnaPvdJ1KWfmiXTWJhA@dls.net>
Rogue Noir wrote:
> I never specified any type for 'value' so I'm now hoping the default is what
> I want..
> 
> I'm very new to LISP..  basically what I want to do is to assign a random
> number to the field 'value' in that structure.

Did you define the structure type TEST somewhere?  Show us the defstruct form.

	Paul
From: Rogue Noir
Subject: Re: The "Illegal Function Object" that won't go away
Date: 
Message-ID: <WU39b.2860$jR2.47@newssvr29.news.prodigy.com>
Actually, even running the following gives the same error message:

(setq tmp (- 1 (random 2.0)))

This is done in the body of another function


"Paul F. Dietz" <·····@dls.net> wrote in message
···························@dls.net...
> Rogue Noir wrote:
> > I never specified any type for 'value' so I'm now hoping the default is
what
> > I want..
> >
> > I'm very new to LISP..  basically what I want to do is to assign a
random
> > number to the field 'value' in that structure.
>
> Did you define the structure type TEST somewhere?  Show us the defstruct
form.
>
> Paul
>
>
From: Paul F. Dietz
Subject: Re: The "Illegal Function Object" that won't go away
Date: 
Message-ID: <MYidnTvgUKbUUvmiU-KYuA@dls.net>
Rogue Noir wrote:
> Actually, even running the following gives the same error message:
> 
> (setq tmp (- 1 (random 2.0)))
> 
> This is done in the body of another function


That code is legal, so I have no clue what you are doing wrong.

	Paul
From: Rogue Noir
Subject: Re: The "Illegal Function Object" that won't go away
Date: 
Message-ID: <SJ49b.2865$q83.1829@newssvr29.news.prodigy.com>
Thanks anyways..  I've found a way around it now...

Sorry to bother you with another question, is there a way to have LISP (i'm
using alisp) to display the line # where an error occured (like done in
C/C++)?

"Paul F. Dietz" <·····@dls.net> wrote in message
···························@dls.net...
> Rogue Noir wrote:
> > Actually, even running the following gives the same error message:
> >
> > (setq tmp (- 1 (random 2.0)))
> >
> > This is done in the body of another function
>
>
> That code is legal, so I have no clue what you are doing wrong.
>
> Paul
>
From: Paul F. Dietz
Subject: Re: The "Illegal Function Object" that won't go away
Date: 
Message-ID: <J0KdnbokpeK0fPmiU-KYvg@dls.net>
Rogue Noir wrote:
> Thanks anyways..  I've found a way around it now...
> 
> Sorry to bother you with another question, is there a way to have LISP (i'm
> using alisp) to display the line # where an error occured (like done in
> C/C++)?


It's not usually easy to do that, since the lisp compiler is best thought
of as operating on a series of S-expressions, not on text (although the
S-expressions may have a mapping to locations in a text file stored in
a hash table).  In some cases, it's not even possible, since the code
being compiled or executed may not ever have been present (as source)
in a text file:

    (funcall (compile nil <form that constructs a lambda expression>) ...)

	Paul
From: Steven M. Haflich
Subject: Re: The "Illegal Function Object" that won't go away
Date: 
Message-ID: <ag99b.2899$nz4.432@newssvr29.news.prodigy.com>
Paul F. Dietz wrote:

> Rogue Noir wrote:
> 
>> Actually, even running the following gives the same error message:
>>
>> (setq tmp (- 1 (random 2.0)))
>>
>> This is done in the body of another function
> 
> That code is legal, so I have no clue what you are doing wrong.

That code is not legal.  It has no defined semantics, and given your interest
in conformace, I am surprised to see this claim it _is_ legal.

Absent a proclamation that tmp is a special variable, this code is
not legal and has no defined semantics.

I suppose this message would be a troll if I didn't put a :-) somewhere
in it...
From: Paul F. Dietz
Subject: Re: The "Illegal Function Object" that won't go away
Date: 
Message-ID: <2jWdnbR8t44jv_iiXTWJkg@dls.net>
Steven M. Haflich wrote:

> That code is not legal.  It has no defined semantics, and given your 
> interest
> in conformace, I am surprised to see this claim it _is_ legal.
> 
> Absent a proclamation that tmp is a special variable, this code is
> not legal and has no defined semantics.
> 
> I suppose this message would be a troll if I didn't put a :-) somewhere
> in it...


Heh.  He did say it was within a function, so I assumed tmp was bound
there.

	Paul
From: Brian Downing
Subject: Re: The "Illegal Function Object" that won't go away
Date: 
Message-ID: <MM79b.443899$YN5.300566@sccrnsc01>
In article <·················@newssvr29.news.prodigy.com>,
Rogue Noir <·····@Noir.com> wrote:
> Actually, even running the following gives the same error message:
> 
> (setq tmp (- 1 (random 2.0)))

(I'm assuming you're using a Common Lisp here.)

Have you defined what tmp is?  You can't just setq a variable that hasn't
been defined and expect reasonable results.

If you want a "global" variable, you should use something like:

(defparameter *tmp* <initial-value>)  ;; fill in <initial-value>
;; do stuff here.
(setf *tmp* (- 1 (random 2.0)))

(It is CL convention to name special variables like *this*.)

If you want a local variable you could use something like this:

(let ((tmp <initial-value>))  ;; again fill in <initial-value>
  ;; do stuff here.
  (setf tmp (- 1 (random 2.0)))
  ;; do stuff here.
  )

However if you're only going to assign a variable one value, do not
use setf.  Just bind it to the proper initial value and use it.

(let ((tmp (- 1 (random 2.0))))
  (if (< tmp 0)
    (format t "Negative: ~A~%" tmp)
    (format t "Positive: ~A~%" tmp)))

No setf required.

In the future, try posting at least a whole function so people know 
what you're trying to accomplish.  Lots of people here can show you
how to write your code in a better style, using more CL features,
but they need to know what you're doing.

-bcd