Edit
Attach
Printable
topic end
<!-- * Set TOPICTITLE = #define private public - A package riddle, part III (22 Aug 2009) --> <style type="text/css"> pre {background-color:#ffeecc;} </style> %STARTINCLUDE% <a name="22"></a> ---+++ [[DefinePrivatePublic20090822PackageRiddlePart3][A package riddle, part III]] (22 Aug 2009) <summary> Lisp recently <a href="DefinePrivatePublic20090820PackageRiddlePart2">surprised me</a> with an error message which I had not expected. </summary> <pre> (defun test() (test_dialog)) (in-package :clausbrod.de) (use-package :oli) (sd-defdialog 'test_dialog :ok-action '(display "test_dialog")) </pre> Load the above code, run =(test)=, and you'll get: <img src="%ATTACHURLPATH%/testdialog.png" alt="testdialog.png" width="321" height="134" /> <br clear="all" /> In <nop>CoCreate Modeling, the =sd-defdialog= macro automatically exports the name of the new dialog (in this case, =test_dialog=) into the default package. Hence, you'd expect that the function =(test)=, which is in the default package, would be able to call that dialog! Astute readers (and <nop>CoCreate Modeling's Lisp compiler) will rightfully scold me for using =(in-package)= in the midst of a file. However, the error doesn't go away if you split up the above code example into two files, the second of which then properly starts with =(in-package)=. And in fact, the problem originally manifested itself in a multiple-file scenario. But to make it even easier for readers to run the test themselves, I just folded the two files into one. Lisp actually provides us with a subtle hint which I ignored so far: Did you notice that the complaint is about a symbol =#:TEST_DIALOG=, and not simply =TEST_DIALOG=? The =#:= prefix adds an important piece to the puzzle. Apparently, Lisp thinks that =TEST_DIALOG= is not a normal symbol, but a so-called _uninterned symbol_. Uninterned symbols are symbols which don't belong to _any_ Lisp package - they are homeless. For details: * [[http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node110.html][Creating Symbols]] (from "Common Lisp the Language", 2nd edition) * [[http://gigamonkeys.com/book/programming-in-the-large-packages-and-symbols.html][Programming in the Large: Packages and Symbols]] (from Peter Seibel's excellent "Practical Common Lisp") * [[http://www.flownet.com/gat/packages.pdf][The Complete Idiot's Guide to Common Lisp Packages]] * [[http://osdir.com/ml/lisp.cl-gardeners/2006-05/msg00004.html][Potting Soil: Colons continued - uninterned symbols]] Uninterned symbols are beasts which live in a slightly darker corner of Common Lisp, or at least you don't run into them too often. And in our particular case, it isn't exactly obvious how =TEST_DIALOG= turned into an uninterned symbol. We would have expected it to be a symbol interned in the =clausbrod.de= package, which is where the dialog is defined! Those who are still with me in this series will probably know where this is heading. Anyway - [[DefinePrivatePublic20090828PackageRiddle4][next time]], we'll finally solve the puzzle! --- %STOPINCLUDE% %COMMENT{type="below" nonotify="on"}% ---
to top
End of topic
Skip to action links
|
Back to top
Edit
|
Attach image or document
|
Printable version
|
Raw text
|
Refresh
|
More topic actions
Revisions: | r1.4 |
>
|
r1.3
|
>
|
r1.2
|
Total page history
|
Backlinks
You are here:
Blog
>
DefinePrivatePublic20090822PackageRiddlePart3
r1.4 - 01 Sep 2009 - 10:25 -
ClausBrod
to top
Blog
This site
2017
:
12
-
11
-
10
2016
:
10
-
7
-
3
2015
:
11
-
10
-
9
-
4
-
1
2014
:
5
2013
:
9
-
8
-
7
-
6
-
5
2012
:
2
-
10
2011
:
1
-
8
-
9
-
10
-
12
2010
:
11
-
10
-
9
-
4
2009
:
11
-
9
-
8
-
7
-
6
-
5
-
4
-
3
2008
:
5
-
4
-
3
-
1
2007:
12
-
8
-
7
-
6
-
5
-
4
-
3
-
1
2006:
4
-
3
-
2
-
1
2005:
12
-
6
-
5
-
4
2004:
12
-
11
-
10
C++
CoCreate Modeling
COM & .NET
Java
Mac
Lisp
OpenSource
Scripting
Windows
Stuff
Changes
Index
Search
Maintenance
Impressum
Datenschutzerklärung
Home
Webs
Atari
Blog
Claus
CoCreateModeling
Klassentreffen
Main
Sandbox
Sommelier
TWiki
Xplm
Jump:
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback