freenode/#lisp - IRC Chatlog
Search
16:23:56
lukego
Hey what's a neat way to do some final tests on a functions' return value? like I have (calc-foo) and I want (let ((foo (calc-foo))) (check-foo foo) foo) but less verbosely? just do (check-foo (calc-foo)) and make check-foo return the value too? or is there a "prog1" type mechanism that I'm overlooking?
16:24:02
pyc
I am creating some data records hard-coded in the source code. I have to ways to define each record: (1) (list :name "alice" :age 30 :city "london") (2) '(:name "alice" :age 30 :city "london"). Which one is preferred? Are there are any best practices or pros/cons around it?
16:25:25
Bike
lukego: no, that's pretty much it. that's why a lot of for-effect functions in the standard return their argument, like initialize-instance
16:25:37
beach
pyc: What Bike said, but also, I would not use lists for stuff like that. I would use standard objects instead.
16:25:53
lukego
Bike: okay cool works for me, just a bit rusty and wondered if that was more of a Smalltalk'ism than a Lisp'ism.
16:27:13
lukego
Hey - me again - what's the significance of SLIME coloring "check-" functions in a different font-lock color?
16:27:24
pyc
beach: You man objects from CLOS? I haven't learnt that yet. Let me look up a tutorial.
16:28:18
lukego
Bike: okay. So since my function is basically being called for the side effect of signalling an error or not then I guess I should embrace this and keep check- in the name
16:28:39
beach
pyc: Many people call them "CLOS objects", but in fact every Common Lisp object is the instance of some class so that term is meaningless. That's why I used the correct term "standard object" which is what you get when you instantiate a class defined by DEFCLASS.
16:30:06
beach
pyc: You can use lists for now, but what I would do then is to define specific accessors, defined in terms of FIRST, SECOND, etc. And then use the accessors in your client code.
16:31:55
pyc
beach: okay, since I am still learning I will just use lists to play with Lisp right now. It will take me a few days to learn CLOS, so I will follow your advice then.
16:32:37
beach
pyc: Sounds good. If you do that, you can change the implementation easily when you feel more comfortable with CLOS.
16:50:30
lukego
Couldn't resist rolling a macro (check (calc-foo) (check1-foo _) (check2-foo _)) I'm on a bad-takes roll today
16:52:32
lukego
mostly because when I'm hacking away at the REPL I'll often call the callee directly but still want to know if the checks fail
16:53:03
lukego
which I guess is a way to say that the checks belong in the callee i.e. they say whether it is producing well-formed output (independent of the context of the caller)
16:55:19
lukego
Sorry if I've asked before but any happy users of check-it? I'm thinking about trying to use it for all of my testing, even though that seems a bit of an uphill battle, in case it forces me into some kind of a productive design-for-testability mindset. but I dunno if tears await
17:00:08
lukego
(Thank you all for your patience with my thinking aloud thoughts best kept to oneself kind of evening...)
17:12:34
warweasle
A long time ago, before the first Iraq war, there was a DARPA project that used lisp to predict fuel logistics to help with planning. Anyone know more about this?
17:17:00
warweasle
I read that it saved enough money to pay for all the previous DARPA projects up until then.
17:26:44
pyc
We can make a hard-coded list of records like this: (defvar *records* '((:name "alice" :age 30) (:name "bob" :age 31))). But what if I did this: (defvar *records2* '('(:name "alice" :age 30) (:name "bob" :age 31))). Will the second one lead to any problems in practice while further programming?
17:27:23
pyc
We can make a hard-coded list of records like this: (defvar *records* '((:name "alice" :age 30) (:name "bob" :age 31))). But what if I did this: (defvar *records2* '('(:name "alice" :age 30) '(:name "bob" :age 31))). Will the second one lead to any problems in practice while further programming?
17:28:08
pyc
Is the second one that has quoted list inside quoted list uncommon in real world Lisp programming?
17:47:19
pyc
Please provide advice on proper coding style: https://plaster.tymoon.eu/view/2314 From code I have seen I think *records2* is the right style. What about the other two styles? Are they outright unacceptable?
17:49:32
pyc
Josh_2: beach: thanks. so my suspicion was right. I guess I have to get used to this style. I was tempted to put some whitespace to demarcate each record clearly but looks like that's not the style.
17:49:52
pyc
It appears to me that the correct style is to treat the parentheses as invisible. As if the parentheses are just not there, so not worry about them at all.
17:50:42
beach
pyc: Open pretty much any good book on Common Lisp and you will see that these rules are followed.
17:51:28
pyc
Josh_2: yes, but the first record is still attached to the opening '(. I was trying to demarcate that too but looks like that is not a good idea as per coding style.
17:53:10
pyc
beach: you added "well, *almost* never". What is a situation where '(' has a following whitespace or ')' has a preceding whitespace?
17:55:07
pyc
Is there any Emacs/SLIME/Paredit command to take the ugly style of *records* or *records3* at https://plaster.tymoon.eu/view/2314 and automatically reformat them in the *records2* style?
18:07:53
warweasle
I read a study by NAVSEA about comparing various languages. Lisp seemed thrown in as an afterthought and it seemed like they were pushing for Haskell. The Lisp programmer showed up late and then cranked out the code in a few hours and would have won the competition IF they thought lisp was a viable language.
18:39:42
markasoftware
If :lambda-list is passed to ensure-generic-function, and an :argument-precedence-order was previously set, is the argument-precedence-order discarded?
19:38:47
beach
pyc: When the last thing before a `)' is a comment, the `)' must be on a separate line.
19:42:59
warweasle
In defmethod, I can I specify a particular array size? Like an array of matrices? Would that make the code faster?
19:48:27
Josh_2
You could define a type that is an array of a certain size and then use that as a type specifier in defmethod I suppose
19:52:22
Alfr
warweasle, but you can still write an optimized function (declare (type ..) ..) and arrange to call it if the type is correct (see typep).
20:00:12
warweasle
Alfr: I might do that later... If I need more speed. It's just a simple IIR filter so...