From: Irma
Subject: error in type symbol
Date: 
Message-ID: <3988f2c5$1@naylor.cs.rmit.edu.au>
Hi...
I've got a problem in making an instance of a class.

code :

(defclass Agreement()
  ((Agreement-Name :initarg :Agreement-Name
                   :accessor Agreement-Name)
   (Place :initarg :Place
          :accesssor Place)))

(setf names (concatenate 'string "jack" "-" "bill"))

and then when i do (to make an object with the same name as the variable
'names' and name the agreement as the value of 'names')

(set names (make-instance 'Agreement
              :Agreement-Name names
              :Place "World"))

it comes up with an error like this :

> Error: value "jack-bill" is not of the expected type SYMBOL.
> While executing: CCL::%SYMBOL->SYMPTR
> Type Command-. to abort.
See the Restarts menu item for further choices.

Can anyone help?? by the way I'm using MCL 4.3

Thanks in advance

--
***********************************
   {}   Irma Sumera
  /^\   ·······@cs.rmit.edu.au
    /   3rd year Computer Science
   /    
   \..
***********************************

From: Frode Vatvedt Fjeld
Subject: Re: error in type symbol
Date: 
Message-ID: <2hg0omyi5c.fsf@dslab7.cs.uit.no>
·······@cs.rmit.edu.au (Irma) writes:

> (setf names (concatenate 'string "jack" "-" "bill"))

If you at this point try (type-of name), you will see that it is a
string.
 
> and then when i do (to make an object with the same name as the
> variable 'names' and name the agreement as the value of 'names')
> 
> (set names (make-instance 'Agreement
>               :Agreement-Name names
>               :Place "World"))

SET takes a _symbol_ as its first argument. What you are trying to do
is probably to make a symbol which is named <name> (i.e. the string
you created above). You can do this with (intern name) or (make-symbol
name), depending on whether you want an interned symbol or not. The
difference is that two interned symbols with the same name (and same
package) are always identical (eq), whereas MAKE-SYMBOL will always
create a new object.

For example:

 (set (intern names)
    (make-instance 'Agreement
               :Agreement-Name names
               :Place "World"))


I don't think it's considered good style in general to create
"variables" like this. Maybe you should consider other
storage-structures, like a hash-table or lists.

-- 
Frode Vatvedt Fjeld
From: Irma
Subject: Re: error in type symbol
Date: 
Message-ID: <39891af6@naylor.cs.rmit.edu.au>
i tried it again using both the intern and make-symbol function.

> (set (intern names)
>    (make-instance 'Agreement
>               :Agreement-Name names
>               :Place "World"))

after that when i try to check the type of jack-bill (which suppose to be
an instance of class Agreement) i got an error.

? names
"jack-bill"
? jack-bill
> Error: Unbound variable: JACK-BILL
> While executing: "Unknown"
? "jack-bill"
"jack-bill"

i thought after typing the make-instance command, the jack-bill suppose to
be an instance of class Agreement. what is the problem here??

thanks again!
--
***********************************
   {}   Irma Sumera
  /^\   ·······@cs.rmit.edu.au
    /   3rd year Computer Science
   /    
   \..
***********************************
From: Keke Abe
Subject: Re: error in type symbol
Date: 
Message-ID: <nomore-0408000207420001@solg4.keke.org>
In article <········@naylor.cs.rmit.edu.au>, ·······@cs.rmit.edu.au (Irma) wrote:

> ? names
> "jack-bill"
> ? jack-bill
> > Error: Unbound variable: JACK-BILL
> > While executing: "Unknown"
> ? "jack-bill"
> "jack-bill"
> 
> i thought after typing the make-instance command, the jack-bill suppose to
> be an instance of class Agreement. what is the problem here??
> 

Consider to implement functions like:

   (defun create-agreement (name)
     "create a new instance of class agreement for name"
      ....)

   (defun find-agreement (name)
     "returns the agreement for name"
      ....)

so you can do:

? (create-agreement "jack-bill")
#<AGREEMENT #x7C04A5E>
? (find-agreement "jack-bill")
#<AGREEMENT #x7C04A5E>
? (find-agreement "joe")
NIL
?
 
instead of:

? jack-bill
#<AGREEMENT #x7C04A5E>

Using a symbol to map a person's name to an object just doesn't
seem right.


regards,
abe

-- 
keke at mac com
From: Wolfhard Bu�
Subject: Re: error in type symbol
Date: 
Message-ID: <m37l9yn5zq.fsf@minka.katzen.ol>
jack-bill is the problem.
Try |jack-bill|.

-wb
From: Frode Vatvedt Fjeld
Subject: Re: error in type symbol
Date: 
Message-ID: <2hbszaychj.fsf@dslab7.cs.uit.no>
·······@cs.rmit.edu.au (Irma) writes:

> ? names
> "jack-bill"
> ? jack-bill
> > Error: Unbound variable: JACK-BILL
> > While executing: "Unknown"
> ? "jack-bill"
> "jack-bill"
> 
> i thought after typing the make-instance command, the jack-bill
> suppose to be an instance of class Agreement. what is the problem
> here??

As you can see from the error message, CL will upcase the name of
symbols as it reads them in (while INTERN function will
not). "JACK-BILL" and "jack-bill" are two different names, and hence
correspond to two different symbols. Consider this behavior:

? (symbol-name 'jack-bill)
"JACK-BILL"

? (symbol-name 'Jack-Bill)
"JACK-BILL"

? (eq 'jack-bill 'Jack-Bill)
T

? (symbol-name '|jack-bill|)
"jack-bill"

? (eq 'jack-bill '|jack-bill|)
nil

You can either force CL to read a lower-case symbol by typing a
vertical bar-character before and after the symbol-name like this:

? |jack-bill|

..or you can make sure your original variable's name is uppercased
like this:

 (set (intern (string-upcase names))
    (make-instance 'Agreement
               :Agreement-Name names
               :Place "World"))

-- 
Frode Vatvedt Fjeld
From: Paul Foley
Subject: Re: error in type symbol
Date: 
Message-ID: <m2r9863l6n.fsf@mycroft.actrix.gen.nz>
On 3 Aug 2000 14:19:17 +1000, Irma  wrote:

> (setf names (concatenate 'string "jack" "-" "bill"))

> and then when i do (to make an object with the same name as the variable
> 'names' and name the agreement as the value of 'names')

> (set names (make-instance 'Agreement
>               :Agreement-Name names
>               :Place "World"))

1) NAMES is a string, not a symbol.  You want to use INTERN to make a
symbol named "jack-bill" (note that that's not the same as the symbol
you'd get if you typed "jack-bill" without the quotes -- that would be
JACK-BILL...)

2) You almost certainly don't want to do it this way at all.

-- 
Whenever you find that you are on the side of the majority, it is time
to reform.                                                -- Mark Twain

(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(··@) "actrix.gen.nz>"))