From: Peter Seibel
Subject: Good examples of use of conditions?
Date: 
Message-ID: <m3of15sxam.fsf@javamonkey.com>
Can anyone point me to some publically available code that makes
particularly good use of the Common Lisp condition system? For
example, an API that really uses typed conditions and restarts as part
of its public interface. I'm particularly interested in code that uses
conditions and restarts programatically but any good use of the system
is of interest. Thanks.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp

From: Kent M Pitman
Subject: Re: Good examples of use of conditions?
Date: 
Message-ID: <sfwwuftbo72.fsf@shell01.TheWorld.com>
Peter Seibel <·····@javamonkey.com> writes:

> Can anyone point me to some publically available code that makes
> particularly good use of the Common Lisp condition system? For
> example, an API that really uses typed conditions and restarts as part
> of its public interface. I'm particularly interested in code that uses
> conditions and restarts programatically but any good use of the system
> is of interest. Thanks.

The likely answer to this question is no.

The reason for this is that conditions are about protocols.
I call protocols "half programs".  They implement half of a functionality,
the importance of which is only ever seen in conjunction with some other
program that was independently written.  If the program were written in
conjunction, then the "protocol" would not be needed.  

For example, a good program that illustrates HTTP is tough.  You need
TWO programs--a good server AND a good client.  Having only one is not
adequately illustrative.  Learning protocols is often very hard as a
result of this.

You need, therefore, to ask for a good pair of programs that work in
relation to one another.  Often, though, the reason that the condition
system is helpful is that it substitutes for source-code, providing an
adapter so that you don't have to see the source code in order to connect
up.  You may in fact find two open-source systems that are able to connect
up and that might illustrate your need, but you might also find that half
of what you look for has no source available while still being useful,
or that no single person reading this mail has all of the info you seek
so no one responds.

Your desire is, in short, ill-phrased and you are either going to have to
learn the two parts separately or else accept partial answers.

I don't mean this to be critical so much as to explain why you'll probably
get few responses in spite of people wanting to be helpful.
From: Peter Seibel
Subject: Re: Good examples of use of conditions?
Date: 
Message-ID: <m3smqgoywh.fsf@javamonkey.com>
Kent M Pitman <······@world.std.com> writes:

> Peter Seibel <·····@javamonkey.com> writes:
> 
> > Can anyone point me to some publically available code that makes
> > particularly good use of the Common Lisp condition system? For
> > example, an API that really uses typed conditions and restarts as part
> > of its public interface. I'm particularly interested in code that uses
> > conditions and restarts programatically but any good use of the system
> > is of interest. Thanks.
> 
> The likely answer to this question is no.
> 
> The reason for this is that conditions are about protocols. I call
> protocols "half programs". They implement half of a functionality,
> the importance of which is only ever seen in conjunction with some
> other program that was independently written. If the program were
> written in conjunction, then the "protocol" would not be needed.

That's perfect. I'd love to see an example of a "half program" written
that provides a well thought-out protocol for interfacing with
independently developed code that uses the condition system. That's
why I mentioned code with a "public interface" that uses conditions.

In fact, that's sort of a test for whether it's actually a good
protocol--if it is comprehensible *without* the "other half" showing
exactly how it is used.

> You need, therefore, to ask for a good pair of programs that work in
> relation to one another. Often, though, the reason that the
> condition system is helpful is that it substitutes for source-code,
> providing an adapter so that you don't have to see the source code
> in order to connect up. You may in fact find two open-source systems
> that are able to connect up and that might illustrate your need, but
> you might also find that half of what you look for has no source
> available while still being useful, or that no single person reading
> this mail has all of the info you seek so no one responds.
> 
> Your desire is, in short, ill-phrased and you are either going to
> have to learn the two parts separately or else accept partial
> answers.

I am perfectly willing to accept a partial answer--if any one has, or
knows of, a piece of code that provides a good condition-based
protocol, with or without the "other half" please let me know; I'm
quite interested to see it.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Joerg-Cyril Hoehle
Subject: Re: Good examples of use of conditions?
Date: 
Message-ID: <u3chriinq.fsf@T-Systems.com>
Peter Seibel <·····@javamonkey.com> writes:
> I am perfectly willing to accept a partial answer--if any one has, or
> knows of, a piece of code that provides a good condition-based
> protocol, with or without the "other half" please let me know; I'm
> quite interested to see it.

Tim Bradshaw and I have both talked here about applications where we
used conditions for what I consider interesting uses.

My application was logfile-analysis, where the file is comma separated
values (CSV), e.g. some logfiles or spreadsheet output. Now, what
should the application do if there are too many commas? Or not enough?
I signaled conditions.

I used continuable conditions (e.g. cerror) when I wanted to express
the idea of a default behaviour of my program half, e.g. ignore too
many columns (arguably a bad default). The default behaviour is useful
with MUFFLE-WARNINGS (sp?). For example, when you throw a csv file at
MS' ODBC-on-flat-file component (built into the OS), it does exactly
this: silently ignore extra columns.

The "other half" could do as follows: ignore the whole line instead of
extra columns (you miss some data, but don't have garbage due to
shifted columns). That's what the original Perl logfile analysis
application did that I was given to improve and rewrote and turned 10x
faster in Lisp.

The "other half" could do as follows: react on the "too many" signal,
get the offending line and proceed heuristically (application
dependent) to repair the broken line. For example, some CSV files may
contain an URL in one column: ";" is legal in a URL, so it can lead
stupid SW whose programmers never heard about the quoting problem to
produce junk lines in a csv file using ";" as separator.
That's real life! Do you want product names?

I don't know if I can give away my code by this time -- but not
because of complexity or "not beautiful enough".

Good luck with your book on Lisp!
	Joerg Hoehle
TSI ITC-Security Technologiezentrum
From: Peter Seibel
Subject: Re: Good examples of use of conditions?
Date: 
Message-ID: <m33chr8mte.fsf@javamonkey.com>
Joerg-Cyril Hoehle <·····@users.spam.no> writes:

> I don't know if I can give away my code by this time -- but not
> because of complexity or "not beautiful enough".

No worries. I get the point of what you were doing from your
description. I imagine I can whip up some code to demonstrate the
idea. Thanks for the example.

> Good luck with your book on Lisp!

Thanks!

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp