Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Lisp > alists and pack...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 12474 of 13087
Post > Topic >>

alists and packages question

by Mirko.Vukovic@[EMAIL PROTECTED] May 13, 2008 at 09:19 AM

Hi,

I am trying to access elements of an alist from a "derived" package.
And I am succeeding, but in an ugly way.  What is the better way?
Here are the details.

I am defining an alist in one package, and I have a function to
retrieve its value.  I have ex****ted that function.

(defpackage :atomic-processes
  (:use :cl :my-utils :physics-constants)
  (:ex****t
....
   :rel-polarizability
   :polarizability))

(in-package :atomic-processes)
(defparameter *alpha-r*
  (list
   (cons 'H 4.5)
   (cons 'C 12.)
....
   (cons 'S-F6 30.))
  "Relative polarizabilities")

(defun rel-polarizability (id)
  (let ((res (cdr (assoc id
			 *alpha-r*))))
    (if (not res)
	(error "not found"))
	res)))

Now, I operate inside another package that uses :atomic-processes
Doing (rel-polarizability 'H) will return the error.  Instead I have
to do (rel-polarizability 'atomic-processes::h).

Is there some way around that?

I tried to build a new symbol as follows:
;; (defun rel-polarizability (id)
;;   (let* ((full-id (make-symbol
;; 		  (concatenate 'string
;; 			       "ATOMIC-PROCESSES::"
;; 			       (symbol-name id))))
;; 	 (res (cdr (assoc full-id
;; 			 *alpha-r*))))
;;     (if (not res)
;; 	(error (concatenate 'string (symbol-name full-id) " not found"))
;; 	res)))

but while it did build the symbol, it did not manage to return the
value.  Puzzled...

Thank you,

Mirko
 




 6 Posts in Topic:
alists and packages question
Mirko.Vukovic@[EMAIL PROT  2008-05-13 09:19:13 
Re: alists and packages question
Alberto Riva <ariva@[E  2008-05-13 13:21:25 
Re: alists and packages question
Mirko.Vukovic@[EMAIL PROT  2008-05-13 10:39:24 
Re: alists and packages question
David Golden <david.go  2008-05-13 18:55:22 
Re: alists and packages question
Mirko.Vukovic@[EMAIL PROT  2008-05-13 11:31:26 
Re: alists and packages question
tar@[EMAIL PROTECTED] (T  2008-05-13 16:16:15 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 18 23:06:29 CDT 2008.