Hello, I know this is more of just a pure Lisp question, but i cannot figure out how to get my Lisp program to use cl-ppcre without having to prefix the function calls with 'cl-ppcre'
My application is using ASDF to define and load itself:
(asdf:defsystem bank-match :description "Approximate bank matching" :author "Terrence M. Brannon" :maintainer "Terrence M. Brannon" :licence "Artistic" :version "1.0" :serial t :depends-on ("cl-ppcre") :components ( (:file "clean") ) )
(in-package :bank-match)
(defun crude-hacks (s) "crude hacks :)" (cl-ppcre:regex-replace "head\s*office" (cl-ppcre:regex-replace "due\s*from" (cl-ppcre:regex-replace "hapoalim\s*branch" s "hapoalim bank") " ") " ") )
-- Terrence Brannon - SID W049945 614-213-2475 (office) 614-213-3426 (fax) 818-359-0893 (cell)
----------------------------------------- This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates.
This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.
Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities.
Hi Terrance
When you define your bank-match package, you want to _use_ cl-ppcre. For example,
(defpackage #:bank-match (:use #:common-lisp #:cl-ppcre))
When you use package A in package B, then the exported symbols of A become available in B.
HTH,
On Jan 4, 2008, at 5:20 PM, terrence.x.brannon@jpmchase.com wrote:
Hello, I know this is more of just a pure Lisp question, but i cannot figure out how to get my Lisp program to use cl-ppcre without having to prefix the function calls with 'cl-ppcre'
My application is using ASDF to define and load itself:
(asdf:defsystem bank-match :description "Approximate bank matching" :author "Terrence M. Brannon" :maintainer "Terrence M. Brannon" :licence "Artistic" :version "1.0" :serial t :depends-on ("cl-ppcre") :components ( (:file "clean") ) )
(in-package :bank-match)
(defun crude-hacks (s) "crude hacks :)" (cl-ppcre:regex-replace "head\s*office" (cl-ppcre:regex-replace "due\s*from" (cl-ppcre:regex-replace "hapoalim\s*branch" s "hapoalim bank") " ") " ") )
-- Terrence Brannon - SID W049945 614-213-2475 (office) 614-213-3426 (fax) 818-359-0893 (cell)
This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities.
cl-ppcre-devel site list cl-ppcre-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-ppcre-devel
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM
terrence.x.brannon@jpmchase.com writes:
Hello, I know this is more of just a pure Lisp question, but i cannot figure out how to get my Lisp program to use cl-ppcre without having to prefix the function calls with 'cl-ppcre' My application is using ASDF to define and load itself:
(asdf:defsystem bank-match :description "Approximate bank matching" :author "Terrence M. Brannon" :maintainer "Terrence M. Brannon" :licence "Artistic" :version "1.0" :serial t :depends-on ("cl-ppcre") ...)
Append :cl-ppcre into the :use list of your DEFPACKAGE line. For instance:
(defpackage :test (:use :cl :cl-ppcre))
Regards.
On Fri, 4 Jan 2008 17:20:41 -0500, terrence.x.brannon@jpmchase.com wrote:
Hello, I know this is more of just a pure Lisp question, but i cannot figure out how to get my Lisp program to use cl-ppcre without having to prefix the function calls with 'cl-ppcre'
Your technical question was answered already, but I suspect (I may be wrong, of course) that you make the same mistake many Lisp newbies make - you're confusing packages and systems. A "package" is a first-class Lisp object defined in the ANSI standard. You can read about it here for example:
http://gigamonkeys.com/book/programming-in-the-large-packages-and-symbols.ht...
(Read the whole book if you haven't done so already.)
A "system" (that's a common usage of the name although there's no fixed definition for it) is something that's defined by a defsystem facility like ASDF - it's more or less a collection of source files plus instructions on how they are to be compiled.
Very often there's a system and a package of the same name, like it's the case for CL-PPCRE. That doesn't have to be the case, though. The names could be different, one system could define more than one package or no package at all, you can define a package without defining a system, etc.
HTH, Edi.
I'm partial to the book "Successful Lisp" but neither book covers ASDF. This tutorial was of great help in the past: http://common-lisp.net/~mmommer/asdf-howto.shtml
but it is not quite helping me enough here. In both Case 1 and Case 2 below, my .sbclrc does not change, yet Case 2 works just fine. I would like to be able to do an asdf load on bank-match and have it pull-in cl-ppcre, but as it stands I must manually load it first.
(setf asdf:*central-registry* '( ;; *default-pathname-defaults* ;;; #P"C:\cygwin\home\W049945\prg\lisp-asdf\series-2.2.9\" #P"C:\cygwin\home\W049945\prg\lisp-asdf\cl-ppcre-1.3.2\" #P"C:\cygwin\home\W049945\prg\redick\lisp\" #P"C:\etl\y.com\trunk\zan\approximate-matching\src\lisp\" ))
Case 1: attempt to load cl-ppcre via my defpackage: throw error 'The name "CL-PPCRE" does not designate any package.'
relevant source:
(defpackage :bank-match (:use :cl :asdf :cl-ppcre) )
(in-package :bank-match)
(asdf:defsystem bank-match :description "Approximate bank matching" :author "Terrence M. Brannon" :maintainer "Terrence M. Brannon" :licence "Artistic" :version "1.0" :serial t :components ( (:file "clean") ) )
(progn (declaim (optimize (debug 3) (safety 3))) (asdf:operate 'asdf:load-op 'bank-match))
Case 2: load cl-ppcre manually and then attempt to load my bank-match package using a simple asdf call => works just fine symbols: BANK-MATCH::OPTIMIZE, COMMON-LISP:OPTIMIZE
;;;; (asdf:operate 'asdf:load-op 'cl-ppcre) ... ; loading system definition from ; C:\cygwin\home\W049945\prg\lisp-asdf\cl-ppcre-1.3.2\cl-ppcre.asd into ; #<PACKAGE "ASDF0"> ; registering #<SYSTEM :CL-PPCRE {B1BA4C1}> as CL-PPCRE
;;;; (asdf:operate 'asdf:load-op 'bank-match) ... ; loading system definition from ; c:\etl\aml-ntdb-uat-02.ny.jpmorgan.com\trunk\zan\approximate-matching\src\lisp\bank-match.asd ; into #<PACKAGE "ASDF0"> ; registering #<SYSTEM BANK-MATCH {ABCC439}> as BANK-MATCH ;;;; (asdf:operate 'asdf:load-op 'cl-ppcre) ... ;;;; (asdf:operate 'asdf:load-op 'bank-match) ...
-- Terrence Brannon - SID W049945 614-213-2475 (office) 614-213-3426 (fax) 818-359-0893 (cell)
Edi Weitz edi@agharta.de Sent by: cl-ppcre-devel-bounces@common-lisp.net 01/04/2008 05:43 PM Please respond to General interest list about cl-ppcre cl-ppcre-devel@common-lisp.net
To General interest list about cl-ppcre cl-ppcre-devel@common-lisp.net cc
Subject Re: [cl-ppcre-devel] using cl-ppcre functions without package prefixes
On Fri, 4 Jan 2008 17:20:41 -0500, terrence.x.brannon@jpmchase.com wrote:
Hello, I know this is more of just a pure Lisp question, but i cannot figure out how to get my Lisp program to use cl-ppcre without having to prefix the function calls with 'cl-ppcre'
Your technical question was answered already, but I suspect (I may be wrong, of course) that you make the same mistake many Lisp newbies make - you're confusing packages and systems. A "package" is a first-class Lisp object defined in the ANSI standard. You can read about it here for example:
http://gigamonkeys.com/book/programming-in-the-large-packages-and-symbols.ht...
(Read the whole book if you haven't done so already.)
A "system" (that's a common usage of the name although there's no fixed definition for it) is something that's defined by a defsystem facility like ASDF - it's more or less a collection of source files plus instructions on how they are to be compiled.
Very often there's a system and a package of the same name, like it's the case for CL-PPCRE. That doesn't have to be the case, though. The names could be different, one system could define more than one package or no package at all, you can define a package without defining a system, etc.
HTH, Edi. _______________________________________________ cl-ppcre-devel site list cl-ppcre-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-ppcre-devel
----------------------------------------- This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates.
This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.
Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities.
I'm sure I'm not the first to build a shortcut to make calls to cl-ppcre a bit clearer. I wrote the function re-place() ... note how much clearer crude-hacks2 is compared to crude-hacks
(defun crude-hacks (s) "crude hacks :)" (cl-ppcre:regex-replace "head\s*office" (cl-ppcre:regex-replace "due\s*from" (cl-ppcre:regex-replace "hapoalim\s*branch" s "hapoalim bank") " ") " ") )
(defun re-replace (s replace-list) "input-string replace-list => output-string" (if (null replace-list) s (let* ((replace-expr (car replace-list)) (match (car replace-expr)) (replace (cadr replace-expr)) ) (cl-ppcre:regex-replace match (re-replace s (cdr replace-list)) replace))))
(defun crude-hacks2 (s) (re-replace s '( ("head\s*office" " ") ("due\s*from" " ") ("hapoalim\s*branch" "hapoalim bank") )))
-- Terrence Brannon - SID W049945 614-213-2475 (office) 614-213-3426 (fax) 818-359-0893 (cell)
----------------------------------------- This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates.
This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.
Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities.
On Thu, 10 Jan 2008 15:20:40 -0500, terrence.x.brannon@jpmchase.com wrote:
I would like to be able to do an asdf load on bank-match and have it pull-in cl-ppcre
Your system definition for BANK-MATCH must /depend/ on CL-PPCRE:
(asdf:defsystem :bank-match ... :depends-on (:cl-ppcre))
attempt to load cl-ppcre via my defpackage
One day I will write a website about this...
Systems (that's what third-party libraries like ASDF are about) and packages (first-class objects defined by the ANSI standard) are not the same thing, in fact they are orthogonal concepts. You cannot load anything with a DEFPACKAGE form.
Edi.
PS: Why was your email sent to cl-ppcre-devel-bounces@common-lisp.net?
cl-ppcre-devel@common-lisp.net