When I load the following code under SBCL I get several style warnings
about undefined functions. I created this contrived code just to show
that you can't fix the problem by re-arranging the code. There must be
a way of creating forward references or declarations in Common Lisp.
(defun fun1 ()
(fun2))
(defun fun2 ()
(fun1))
Thanks for the help.
Blake McBride
Blake McBride wrote:
>
> When I load the following code under SBCL I get several style warnings
> about undefined functions. I created this contrived code just to show
> that you can't fix the problem by re-arranging the code. There must be
> a way of creating forward references or declarations in Common Lisp.
Lisp calls this a declaration.
http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node105.html
e.g.
(declaim (ftype function fun2))
(defun fun1 ()
(fun2))
(defun fun2 ()
(fun1))
or
(defun fun1 ()
(declare (ftype function fun2))
(fun2))
(defun fun2 ()
(fun1))
- Daniel
Thanks. That is exactly what I was looking for. It was a little rough
following this through the HyperSpec. I appreciate your help!
D Herring wrote:
> Blake McBride wrote:
>>
>> When I load the following code under SBCL I get several style warnings
>> about undefined functions. I created this contrived code just to show
>> that you can't fix the problem by re-arranging the code. There must
>> be a way of creating forward references or declarations in Common Lisp.
>
> Lisp calls this a declaration.
> http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node105.html
>
> e.g.
>
> (declaim (ftype function fun2))
>
> (defun fun1 ()
> (fun2))
>
> (defun fun2 ()
> (fun1))
>
> or
>
> (defun fun1 ()
> (declare (ftype function fun2))
> (fun2))
>
> (defun fun2 ()
> (fun1))
>
>
> - Daniel
Blake McBride wrote:
>
> Thanks. That is exactly what I was looking for.
"That" being extra declarations for you to maintain just to make a
compiler happy, all I can say is PWUAHAHAHAHAHAHHAHAA, it is time to let
go of your Java/C++ Stockholm Syndrome in which being captive to a
compiler is exactly for what you are looking. I always got /such/ a huge
kick after trundling off to my header file to add declarations for a C
function every time I added or changed one. Not.
You were exactly looking for with-compilation-unit, as well as more
automatic ways of loading code in general.
hth,kt
--
http://www.theoryyalgebra.com/
"In the morning, hear the Way;
in the evening, die content!"
-- Confucius
I agree with what you are saying (if I understand correctly). It makes
sense that a macro would have to be defined before a function which uses
it but not a function in a dynamic environment. I wouldn't normally
think or want to add such code but SBCL kept complaining and it got
annoying when I was scanning through the warnings to see if there was
anything significant.
I agree that (in general) things that don't relate to a solution should
be absolutely minimized. If you want to declare/specify ad nausim you
could always switch to ADA. Being able to stick to the problem's
solution rather than the language's extra baggage is one of the great
beauties of Lisp.
Ken Tilton wrote:
>
>
> Blake McBride wrote:
>>
>> Thanks. That is exactly what I was looking for.
>
> "That" being extra declarations for you to maintain just to make a
> compiler happy, all I can say is PWUAHAHAHAHAHAHHAHAA, it is time to let
> go of your Java/C++ Stockholm Syndrome in which being captive to a
> compiler is exactly for what you are looking. I always got /such/ a huge
> kick after trundling off to my header file to add declarations for a C
> function every time I added or changed one. Not.
>
> You were exactly looking for with-compilation-unit, as well as more
> automatic ways of loading code in general.
>
> hth,kt
>
Blake McBride wrote:
>
> I agree with what you are saying (if I understand correctly). It makes
> sense that a macro would have to be defined before a function which uses
> it...
???? You were responding to me? It could be a useful measure of how
little you understand that your response cannot be intelligibly
connected to what I offered. We have seen this before. You need to shut
up a little and listen to the people trying to help you, because I am
the second person to give up.*
kt
* with-compilation-unit. k
--
http://www.theoryyalgebra.com/
"In the morning, hear the Way;
in the evening, die content!"
-- Confucius
From: Kent M Pitman
Subject: Re: Don't understand forward referencing
Date:
Message-ID: <u3asqvh7m.fsf@nhplace.com>
Blake McBride <·····@mcbride.name> writes:
> Thanks. That is exactly what I was looking for. It was a little
> rough following this through the HyperSpec. I appreciate your help!
The HyperSpec is not a tutorial document.
Kent M Pitman wrote:
> Blake McBride <·····@mcbride.name> writes:
>
>> Thanks. That is exactly what I was looking for. It was a little
>> rough following this through the HyperSpec. I appreciate your help!
>
> The HyperSpec is not a tutorial document.
Agreed, but then again there is no _complete_ ANSI Common Lisp book out
there to my knowledge so I am left with the HyperSpec.
(Neither Graham nor Seibel's books answer my question.)
Blake McBride
Blake McBride wrote:
> Kent M Pitman wrote:
>
>> Blake McBride <·····@mcbride.name> writes:
>>
>>> Thanks. That is exactly what I was looking for. It was a little
>>> rough following this through the HyperSpec. I appreciate your help!
>>
>>
>> The HyperSpec is not a tutorial document.
>
>
> Agreed, but then again there is no _complete_ ANSI Common Lisp book out
> there to my knowledge so I am left with the HyperSpec.
>
> (Neither Graham nor Seibel's books answer my question.)
Based on what we have seen here in c.l.l, it would not help if they did.
Please find another language, Ruby is great I here.
kt
--
http://www.theoryyalgebra.com/
"In the morning, hear the Way;
in the evening, die content!"
-- Confucius
On Mon, 21 Jan 2008 16:03:49 -0600, Blake McBride <·····@mcbride.name> wrote:
> When I load the following code under SBCL I get several style
> warnings about undefined functions. I created this contrived code
> just to show that you can't fix the problem by re-arranging the
> code. There must be a way of creating forward references or
> declarations in Common Lisp.
>
> (defun fun1 ()
> (fun2))
>
> (defun fun2 ()
> (fun1))
You don't need any forward references, that's perfectly legal Lisp
code. SBCL is just trying to be helpful. As you said, these are
"style warnings", not errors or anything like that.
Also, you won't get these warnings if the two functions are in one
file you compile with COMPILE-FILE, or if you wrap their compilation
(even if they aren't in the same file) with WITH-COMPILATION-UNIT.
http://www.lispworks.com/documentation/HyperSpec/Body/m_w_comp.htm
http://www.lispworks.com/documentation/HyperSpec/Body/f_cmp_fi.htm
HTH,
Edi.
--
European Common Lisp Meeting, Amsterdam, April 19/20, 2008
http://weitz.de/eclm2008/
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
I was loading uncompiled code (not compiling or loading compiled code).
This error is VERY annoying because it is totally meaningless, produces
a lot of garbage on the screen, and you can't find significant warnings
amongst all the garbage. I don't want to turn warnings off (presuming
there is a way to do that) because I do want to see meaningful warnings.
Thanks for the input though.
Blake McBride
Edi Weitz wrote:
> On Mon, 21 Jan 2008 16:03:49 -0600, Blake McBride <·····@mcbride.name> wrote:
>
>> When I load the following code under SBCL I get several style
>> warnings about undefined functions. I created this contrived code
>> just to show that you can't fix the problem by re-arranging the
>> code. There must be a way of creating forward references or
>> declarations in Common Lisp.
>>
>> (defun fun1 ()
>> (fun2))
>>
>> (defun fun2 ()
>> (fun1))
>
> You don't need any forward references, that's perfectly legal Lisp
> code. SBCL is just trying to be helpful. As you said, these are
> "style warnings", not errors or anything like that.
>
> Also, you won't get these warnings if the two functions are in one
> file you compile with COMPILE-FILE, or if you wrap their compilation
> (even if they aren't in the same file) with WITH-COMPILATION-UNIT.
>
> http://www.lispworks.com/documentation/HyperSpec/Body/m_w_comp.htm
> http://www.lispworks.com/documentation/HyperSpec/Body/f_cmp_fi.htm
>
> HTH,
> Edi.
>
On Mon, 21 Jan 2008 16:32:51 -0600, Blake McBride <·····@mcbride.name> wrote:
> I was loading uncompiled code (not compiling or loading compiled
> code).
SBCL always compiles your code.
> This error is VERY annoying because it is totally meaningless,
> produces a lot of garbage on the screen, and you can't find
> significant warnings amongst all the garbage.
Please stop shouting at me and do your homework instead. And the next
time try to find someone else to answer your questions.
Edi.
--
European Common Lisp Meeting, Amsterdam, April 19/20, 2008
http://weitz.de/eclm2008/
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
In article <···············@news.supernews.com>,
Blake McBride <·····@mcbride.name> wrote:
> I was loading uncompiled code (not compiling or loading compiled code).
Really?
You were loading source code which gets compiled.
http://www.sbcl.org/manual/Compiler_002donly-Implementation.html#Compiler_002donly-Implementation
SBCL is a compiler-only implementation (mostly).
> This error is VERY annoying because it is totally meaningless,
Its not meaningless. When you load code, the forms gets piece
by piece READ, COMPILEd and executed.
Similar to this (mucho simplified):
(loop with eof = #:eof
for form = (read stream nil eof)
until (eq form eof)
do (EXECUTE (COMPILE-FORM form)))
For each form you
get the compiler output, because it would not make sense
to delay the output.
> produces
> a lot of garbage on the screen, and you can't find significant warnings
> amongst all the garbage. I don't want to turn warnings off (presuming
> there is a way to do that) because I do want to see meaningful warnings.
You might want to read the SBCL manual about controlling
output of the compiler.
>
> Thanks for the input though.
>
> Blake McBride
>
>
> Edi Weitz wrote:
> > On Mon, 21 Jan 2008 16:03:49 -0600, Blake McBride <·····@mcbride.name> wrote:
> >
> >> When I load the following code under SBCL I get several style
> >> warnings about undefined functions. I created this contrived code
> >> just to show that you can't fix the problem by re-arranging the
> >> code. There must be a way of creating forward references or
> >> declarations in Common Lisp.
> >>
> >> (defun fun1 ()
> >> (fun2))
> >>
> >> (defun fun2 ()
> >> (fun1))
> >
> > You don't need any forward references, that's perfectly legal Lisp
> > code. SBCL is just trying to be helpful. As you said, these are
> > "style warnings", not errors or anything like that.
> >
> > Also, you won't get these warnings if the two functions are in one
> > file you compile with COMPILE-FILE, or if you wrap their compilation
> > (even if they aren't in the same file) with WITH-COMPILATION-UNIT.
> >
> > http://www.lispworks.com/documentation/HyperSpec/Body/m_w_comp.htm
> > http://www.lispworks.com/documentation/HyperSpec/Body/f_cmp_fi.htm
> >
> > HTH,
> > Edi.
> >
Blake McBride <·····@mcbride.name> writes:
> I was loading uncompiled code (not compiling or loading compiled code).
> This error is VERY annoying because it is totally meaningless, produces
> a lot of garbage on the screen, and you can't find significant warnings
> amongst all the garbage. I don't want to turn warnings off (presuming
> there is a way to do that) because I do want to see meaningful warnings.
You can use the Superior Lisp Interaction Mode for Emacs (SLIME) which
will display all notes separately and sorted by severity. It's the
developing environment SBCL is mostly used with, and it does hence
support this implementation very well.
-T.
In article <···············@news.supernews.com>,
Blake McBride <·····@mcbride.name> wrote:
> When I load the following code under SBCL I get several style warnings
> about undefined functions. I created this contrived code just to show
> that you can't fix the problem by re-arranging the code. There must be
> a way of creating forward references or declarations in Common Lisp.
>
>
> (defun fun1 ()
> (fun2))
>
> (defun fun2 ()
> (fun1))
>
> Thanks for the help.
>
> Blake McBride
One way could be to use WITH-COMPILATION-UNIT.
Load this code:
(with-compilation-unit ()
(defun fun1 ()
(fun2))
(defun fun2 ()
(fun1)))
From: Kent M Pitman
Subject: Re: Don't understand forward referencing
Date:
Message-ID: <uy7aiu2ar.fsf@nhplace.com>
Rainer Joswig <······@lisp.de> writes:
> (with-compilation-unit ()
> (defun fun1 ()
> (fun2))
> (defun fun2 ()
> (fun1)))
compile-file is supposed to treat a file as a compilation unit, so it should
never be necessary to put it within in a file that contains only code and not
calls to compile-file or load.
The intended use is:
+------- foo1.lisp --------
| (defun fun1 () (fun2))
+-------------------------
+------- foo2.lisp --------
| (defun fun2 () (fun1))
+-------------------------
(with-compilation-unit ()
(compile-file "foo1.lisp")
(compile-file "foo2.lisp"))
or whatever... so that you don't get error messages prematurely after
compiling the first one.
In spite of its name, with-compilation-unit can go around other things,
like calls to load, and if you're going to load in the same bundle of
actions, that's often very useful to do.
Blake McBride <·····@mcbride.name> writes:
> When I load the following code under SBCL I get several style warnings
> about undefined functions. I created this contrived code just to show
> that you can't fix the problem by re-arranging the code. There must
> be a way of creating forward references or declarations in Common Lisp.
>
>
> (defun fun1 ()
> (fun2))
>
> (defun fun2 ()
> (fun1))
>
> Thanks for the help.
I saw that you have gotten the usual suspects to show their personal
styles, and that you got to know about DECLAIM.
Since you seems to be, like me, used to less verbose development
environments I suggest you take a look at the SBCL manual to try to
limit the amount of "noise" generated.
Now, if you are like me I guess you want it far quieter than that,
though. I have commented out some "noise" in the compiler source and you
might want to do the same. E.g. in src/code/defboot.lisp in the function
"%defun" you might want to comment out the style warning that yells at
you whenever you redefine a function.
Of course, this and other message are useful and a lot can be learnt
from them. But if you feel like some adventure, try it out. Personally
I'd love to have more options to make the compiler shut up, and might if
I ever be able, implement that someday. Hope I could be of some help, or
at least entertainment.
/Andreas
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?