[Openmcl-devel] CCL Win32 confuses equally named functions

Bill St. Clair wws at clozure.com
Mon Jun 8 07:33:12 PDT 2015


Wimpie,

Your code behaved as it did because your USE of the ENCRYPTION package by
the DIRECTOR package, as Hans surmised, caused the GENERATE-KEY definition
in the DIRECTOR package to overwrite the definition in the ENCRYPTION
package, since DIRECTOR:GENERATE-KEY is the same symbol as
ENCRYPTION:GENERATE-KEY.

How your code ever "worked" I don't know, but since you said it did, I
tried it in 64-bit Darwin, x8664 Linux, 32-bit ARM Linux, and both 32-bit
and 64-bit Windows. Same error on all platforms: "In the call to
GENERATE-KEY with arguments (NEW-USER NEW-PASSWD *LIBRARY-KEYS-DIR*), 3
arguments were provided, but at most 2 are accepted". To behave otherwise
would be a bug in the package system.

-Bill

On Mon, Jun 8, 2015 at 8:09 AM, Wimpie Nortje <wimpie at selectiveshare.com>
wrote:

>  Thanks, I will do that.
>
> --
> Wimpie Nortje
> Strongroom - Host-proof notepad
> Selective Share - Encryption-as-a-Service
> https://www.selectiveshare.com
> <https://www.selectiveshare.com/?pk_campaign=email-sig>
>
>
> On Mon, Jun 8, 2015, at 02:05 PM, Hans Hübner wrote:
>
> Wimpie,
>
> the problem is caused by:
>
> (defpackage #:director
>   (:use    #:cl
>            #:encryption)
>   (:export #:generate-key))
>
> I would recommend not :USEing the #:encryption package and instead qualify
> all external symbols.
>
> -Hans
>
> 2015-06-08 8:00 GMT-04:00 Wimpie Nortje <wimpie at selectiveshare.com>:
>
>
> Hans,
>
> The example is below. I put all of it in a single file. When I load the
> file I get
>
> ;Compiler warnings for "bug.lisp" :
> ;   In GENERATE-KEY: In the call to GENERATE-KEY with arguments (NEW-USER
> NEW-PASSWD *LIBRARY-KEYS-DIR*),
> ;     3 arguments were provided, but at most 2 are accepted
> ;     by the lexically visible definition of GENERATE-KEY
>
> In the real project this was hidden by Quicklisp. It also fails on both
> CCL linux 64b and SBCL linux 64b with the same warning. So this was my
> mistake. I will have to read up on scoping rules again.
>
> Thanks for your time.
>
>
>
> #|****************************************************************************|#
> (in-package #:cl-user)
>
> (defpackage #:encryption
>   (:use #:cl)
>   (:export #:generate-key))
>
> (in-package #:encryption)
>
> (defun generate-key (new-user new-passwd home-dir
>                      &optional (out *standard-output*))
>   (declare (ignore new-user new-passwd home-dir out))
>   (print "Correct function called."))
>
>
> #|****************************************************************************|#
> (in-package #:cl-user)
>
> (defpackage #:director
>   (:use    #:cl
>         #:encryption)
>   (:export #:generate-key))
>
> (in-package #:director)
>
> (defparameter *library-keys-dir* #P"C:/tmp/keys")
>
> (defun generate-key (new-user new-passwd)
>   (encryption:generate-key new-user new-passwd *library-keys-dir*))
>
>
> #|****************************************************************************|#
> (in-package :cl-user)
>
> (defpackage #:main
>   (:use #:cl))
>
> (in-package #:main)
>
> (director:generate-key "username" "gpg-passphrase")
>
>
>
>
>
> --
> Wimpie Nortje
> Strongroom - Host-proof notepad
> Selective Share - Encryption-as-a-Service
> https://www.selectiveshare.com
> <https://www.selectiveshare.com/?pk_campaign=email-sig>
>
>
>
> On Mon, Jun 8, 2015, at 01:16 PM, Hans Hübner wrote:
>
> Wimpie,
>
> can you please supply us with a complete, working example of code that
> demonstrates the problem, in particular including the defpackage forms?
>
> Thanks,
> Hans
>
> 2015-06-08 7:03 GMT-04:00 Wimpie Nortje <wimpie at selectiveshare.com>:
>
> Hi everyone,
>
> I am porting my application from linux 64b to windows 32b. On windows
> CCL calls the wrong function while it works fine in linux.
>
> In principle the code looks like this
>
> (in-package :b)
> (defun fn (par1 par2 &optional (out *standard-output*))     [3]
>       (do-stuff))
>
> (in-package :a)
> (defun fn (par1 par2)                        [2]
>       (b:fn par1 par2 *some-global*))   [1]
>
> (in-package :main)
> (a:fn Val1 Val2)
>
>
> When I run this I get the following error:
> Too many arguments in call to #<Compiled-function B:FN #xE0A390E>:
> 3 arguments provided, at most 2 accepted.
>    [Condition of type CCL::TOO-MANY-ARGUMENTS]
>
> It seems that the function call at [1] is calling the definition at [2]
> instead of the one at [3]. Also, when I do M-. (slime-edit-definition)
> at [1] it jumps to [2].
>
> If I rename b:fn to something else without any other code changes, it
> works.
>
> This code works unmodified on linux 64b. I have not yet tried on windows
> 64b
>
> Is this a bug or am I doing something wrong?
>
> I am running CCL Version 1.10-r16196  (WindowsX8632) on Windows XP SP3.
>
>
> --
> Wimpie Nortje
> Strongroom - Host-proof notepad
> Selective Share - Encryption-as-a-Service
> https://www.selectiveshare.com
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel
>
>
>
>
>
>
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20150608/b0db1bfd/attachment.htm>


More information about the Openmcl-devel mailing list