libera/#commonlisp - IRC Chatlog
Search
14:42:56
boeg
Can anyone recommend a good code base (for learning purposes) that effectively uses conditions and return values where it makes sense to handle errors? I'm look to get a better grasp of when/what/how of error handling in lisp and I've read a lot of literature but what like to see some concrete examples
14:52:44
beach
boeg: You are then giving the caller the option of not handling errors, so the error then propagates further during execution, making it very hard to find the bug later.
14:53:48
beach
boeg: furthermore, you must then handle the error in intermediate functions, like if A calls B and B calls C, C detects an error that B does not what to do with, but A does, then B must still look at the return value and return it to A.
14:55:01
beach
boeg: So for simple things, call ERROR in the function that detects the error situation and use HANDLER-CASE in the function that (directly or indirectly) invoked the function that detects the error.
14:56:05
beach
For more sophisticated situations, provide one or more restarts in the function that detects the error, letting the caller choose a restart so that execution can continue.
14:56:17
boeg
beach: Yes, what I meant was a code base that is good at returning values where it makes sense and using conditions what that makes sense
14:58:12
beach
Then almost any code base will do, because they all return values and they all handle errors.
14:58:43
boeg
sure, but can you recommend a good code base that are good at doing it "properly"? That is maybe not too big but neither trivial
14:59:08
beach
THROW is a function in Common Lisp, but it doesn't have anything to do with error handling.
14:59:39
boeg
you know, i'd like to study a code base that is of good quality but not too big that the size will be a hindrance for the actual goal
14:59:42
beach
You can look at Cluffer if you like. It is pretty well organized if I may say so myself.
15:01:25
minion
boeg: look at PCL: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
15:14:41
beach
The plan is for Second Climacs to be so good for editing Common Lisp that I don't need to use Emacs for that anymore.
15:15:36
boeg
like some use emacs for everything for writing software, to email, to browsing and so on because it can be used as a kinda lisp machine
15:17:14
beach
We are also working on other components of an IDE for Common Lisp, like a debugger (Clordane, embryonic for now), inspector Clouseau (by scymtym, very complete), etc.
15:19:01
pjb
boeg: Perhaps an interpreter would do; there are syntax errors, parsing errors, type errors, etc: https://github.com/informatimago/nasium-lse/
15:20:32
boeg
beach: sounds cool, although I dunno if I would be interested in such a thing. What I like about emacs is that its an environment that understands (a) lisp so I can do whatever with it, like programming common lisp in it or taking notes and so on. I'm not interested in a "common lisp editor". I'm probably not the target though
15:22:20
didi
What should be the result of (let ((x 42)) (mapcar (lambda (x) (declare (ignore x)) x) '(1 2 3)))?
15:22:45
boeg
is it an editor in an environment where you can program the environment live by evaluating things in the editor?
15:23:18
pjb
didi: declarations are optional. A good implementation would signal a compile-time warning that a variable is not ignored as declared.
15:31:11
beach
boeg: But SICL is necessary for the complete Second Climacs because I plan to compile the buffer at typing speed.
15:49:45
didi
Should I use `assert' for sanity checks? For example, X must be a list of length 1 at this point; there is no fixing if it is not.
16:10:18
pjb
minion: memo for didi: note that CL:ASSERT let you fix the problem: Try: (let ((list (list 1 2 3))) (assert (= 1 (length list)) (list) "should be a list of 1 element")) and select the restart that let you enter a new value for LIST.
17:05:40
scymtym
boeg: this is not second climacs but it demonstrates some of the things that can be done by using the Lisp reader instead of regex-based analysis: https://techfak.de/~jmoringe/style-check.html . or see https://techfak.de/~jmoringe/eclector-cst-toy-2.ogv , https://techfak.de/~jmoringe/eclector-context-completion.ogv for a deeper analysis, in emacs but based on the same approach
18:11:31
aeth
I'd prefer CHECK-TYPE to ASSERT if it can be expressed as a type in a reasonable way (so e.g. not a SATISFIES type).
18:12:04
aeth
For list length, maybe ASSERT is the most straightforward, but for vector length, a CHECK-TYPE is the most readable and concise.
19:41:53
rumbler31
sorry for the noob question, but I want to return a specific value from a loop once it is complete
19:45:12
rumbler31
oh man. I forgot about that I keep thinking about return in loops as the return verb and forgetting that function call
19:49:27
jebes
everything is meant to tie together, there isn't arbitary differences like statements vs expressions
20:01:02
pjb
rumbler31: that means that loop doesn't return. return returns. If you want to return from a loop you must combine loop and return.
20:19:57
rumbler31
day 4 part 2. the wording isn't clear but I think they are trying to say that there must be at least one pair that is only a pair, even if there are other matching digits of any length
20:24:08
nirved
looks quite clear to me: counting the repeating element, matching if there's a pair, ignoring otherwise
20:28:06
nirved
a more convolved solution would be to first transform the number to a run-length encoded sequence - i.e. list of (digit repetitions), and work on it
20:44:33
pjb
When you use the loop return, it doesn't execute the finally: (loop return 42 finally (return 33)) #| --> 42 |#
21:00:19
Josh_2
hmm, so I have a problem. I have a thread that is constantly listening for connections, accepting and processing them. How can I kill this thread without ending up with the "address-in-use" error when I attempt to restart the thread on the same ip and port?
21:32:51
Josh_2
usocket:socket-listen has both :reuseaddress and :reuse-address for some reason, but had them both set to t to no avail. Instead I just put the currently listening connection into my server object so I can shut it down when I shut down the server
22:43:52
aeth
no-defun-allowed: your 2-based indices are an interesting solution to the 0-based vs. 1-based controversy in computing
22:44:22
no-defun-allowed
aeth: 0 and 1 are both radical extremists, the true solution is for 1/2 to be the starting index for an array.
22:44:47
no-defun-allowed
And it's not like anything other than Matlab and Maxima use 1-based indexing.
22:44:56
aeth
no-defun-allowed: I like starting at -1 so you have a spare item in front just in case you want to use it.
22:45:41
aeth
no-defun-allowed: Quite a few things use 1-based, as diverse as Fortran (iirc) and Lua.
22:46:48
aeth
no-defun-allowed: If someone wrote your scientific computation program in 1974 and then retired in 1981 and died in 1987, who would dare touch it to try to rewrite it?
22:47:54
pfdietz
A lot of old COBOL is being slowly GCed as the companies running the programs eventually die. This can take a while.
22:51:43
edgar-rft
Lestat9: when microsoft started in a garage they didn't have enough money for Lisp, so they bought DOS instead
22:52:34
no-defun-allowed
ACTION would say mulisp is a Lisp implementation by Microsoft but it is not Common Lisp
22:53:06
Lestat9
I was teethed on a commodore 64 and in 1984 IBM didnt even have color yet so commodore4 was king...
22:53:50
Lestat9
I talked to a girl i dated back then and she reminded me she met me on my BBS i ran on my C64, and jokingly said that was the first internet... and then ui realized it was
23:17:07
jmercouris
how much do you have to change a block of code before it is no longer copyrightable?
23:17:31
jmercouris
I know this is a legal question, but there's a snippet in my codebase that no longer resembles the original implementation, is that still under copywrite?
23:17:55
grobe0ba
jmercouris: afaik, any modifications YOU make are your IP, and thus copyrightable by you.
23:18:30
pjb
jmercouris: the technical term is derived work. Notice how you can take a book, change every sentences of it, and still get a derived work. For example, when translating.
23:18:44
duuqnd
I mean, it's technically probably maybe still owned by the author but if it doesn't even resemble the original you're probably safe as long as you don't tell anyone.
23:19:03
pjb
jmercouris: so even if you rewrite the whole software, even in a different language for a different system, you could still fall under the derived work category and own all your profit to the original author.
23:20:03
jmercouris
I'll just leave the copyright notice in anyways, even though it does not seem relevant anymore