freenode/#lisp - IRC Chatlog
Search
16:21:18
tempate
as an example, I'm trying to solve a couple exercises from L99. My current solution is https://bpaste.net/show/46ce5dc6ed84 but I have the feeling this could be done in a way better way, as the second and third functions are pretty much the same, and the last one, is looping through the list three times, which doesn't seem to be very good
16:24:36
phoe
or use LOOP's COLLECT like beach suggests if you don't want to deal with collection manually
16:26:14
tempate
yeah, it seemed I good place to use COLLECT but I wasn't too sure on how to use it, let me look at it more deeply
16:27:07
tempate
beach: still, even if I use LOOP, wouldn't I be looping through the whole sequence three time if I run the third function?
16:34:07
beach
tempate: Sure, you can combine the three functions, but that's not a question of using macros or not.
16:34:29
tempate
phoe: not sure if the default syntax should be to put the do after the if, i.e. if do, or just have the do in front of the first thing to do
16:35:08
beach
tempate: But you need slime-indentation to get the indentation of conditional loop clauses right.
16:35:19
tempate
beach: couldn't I write a macro that loops through the whole sequence and then add the inside of what to do depending on which function is running it?
16:37:43
beach
tempate: Sure, you can even write a function that does that. There are several, like MAP, MAPCAR, etc.
16:40:07
tempate
beach: as I understand it, if I run the third function, three loops are going to take place
16:40:08
beach
"a macro that loops through the whole sequence and then add the inside of what to do depending on which function is running it" seems like a good description of (LOOP FOR .. IN ...).
16:40:44
beach
tempate: Yes, when you run the third function, the other two are going to run as well.
16:42:26
beach
tempate: I think it will be hard to write any kind of abstraction that takes your three LOOP bodies and combines them so as to avoid creating intermediate lists, if that is what you mean.
16:59:33
nirved
tempate: instead of first and second you could use the loop built-in destructuring - (loop :for (count element) :in ...)
17:03:15
tempate
nirved: if you are referring to the third function, I need to sometimes return the list containing both the first and the second element, so I'm not sure if it's worth it
17:06:45
nirved
tempate: i use keywords with loop for syntax highlighting, and less symbol pollution
17:58:44
jmercouris
Here's the error: https://gist.github.com/jmercouris/11cbd5c2b07986d1ac4e19709fd0cdf7
17:59:57
jmercouris
Ah, my stupidity, didn't realize the ql made the issue, problem solved, thanks rubber duck
18:23:22
dim
I think making a solid choice of a RDMBS and then using as many features it can provide is a good move (the smart one, I'd argue), so my advice is to pick Postgres and Postmodern
18:25:06
dim
in the wild changing from an RDBMS to another usually happens up to one time in a project's lifetime, and it's a major undertaking; unless you *have* to support several RDBMS backends at the same time, being _portable_ in between them is not going to prove interesting ever
18:25:53
dim
it's much harder and way more involved to be SQL-portable that to be compliant with several CL implementations, say, despite both CL and SQL having a standard specification
18:26:55
dlowe
The SLQ spec is more akin to the Scheme spec, where there's bare bones that everyone piles their own stuff onto
18:28:41
emaczen
How do we enable/find the SBCL source code so that emacs can M-. to source locations?
18:30:56
dim
dlowe: the SQL spec is not seriously followed by any other implementation than PostgreSQL, and the SQL spec makes no provision for data types generics the way Postgres does, which sometimes paints us in a corner and forces us not to follow it closely
18:31:57
dim
the SQL spec is a strange political game that happens between 3 proprietary vendors, what they try to achieve is having checkboxes that the other vendors haven't crossed yet so that their sales people have an edge in discussions with buyers
18:36:04
aeth
Even when you're using a mostly portable library you might be interested in non-portable features, e.g. JSON
18:37:41
makomo
emaczen: you have to use a certain SBCL-specific function to tell the SBCL internals where to find its source code
18:38:59
makomo
emaczen: you usually put that in your .sbclrc to make it happen automatically when SBCL is started
18:41:31
makomo
emaczen: but i guess you should watch out that you checkout the right release (so that it matches your package manager's SBCL version), instead of the master
19:05:41
emaczen
when trying to install SBCL I get the error output/prefix.def: No such file or directory
19:53:44
aeth
Incompatible changes in m.n.k releases is why distros typically never update SBCL until their next distro version, months/years later, in effect creating de facto stable versions (and probably different ones for each distro)
19:54:42
aeth
But they generally are afaik minor standards violations and the CL community takes the spec seriously
20:06:15
verisimilitude
Those minor violations tend to be related to CLOS, from the last times I've checked.
20:19:06
aeth
Generally if you can run your code in multiple implementations (e.g. SBCL and CCL) you shouldn't have trouble running it in new SBCL versions afaik.
20:19:37
aeth
If you rely on SBCL internals directly without a portability library, that's where things tend to be messy. Or, I guess, if you rely on assumptions about SBCL's implementation details of CLOS
20:22:59
emaczen
Is there a possibility of strange caching that makes compilation successful on the older version?
20:23:44
aeth
If you (1) rebooted, (2) didn't install *over* an older SBCL, and (3) cleared your cache, that's probably 99.9% of errors at the implementation level.
20:27:12
aeth
rebooting might help if something somewhere at some level got cached to an older version for some strange reason
20:32:00
aeth
emaczen: After that the only thing I can think of is to make sure you're using the correct SBCL.
20:33:17
scymtym
emaczen: if you paste the code, somebody else can verify that it does not compile in SBCL 1.4.16
20:37:41
scymtym
can you paste that part of the code? maybe it can be reduced to demonstrate the problem without depending on the rest of your code
20:42:50
emaczen
scymtym: I'm evaluating (typecase l1 l2) where MATCHING::L1 = :?LAMBDA-LIST MATCHING::L2 = (VERTEX (G DIRECTED-GRAPH) &KEY (KEY #'IDENTITY) (TEST #'EQ) IN ...)
20:44:20
emaczen
:?var is a custom deftype that succeeds when a type is a symbol with the first character being a ?
20:45:28
emaczen
The error in the backtrace is taking me to the next case down which is: (cons cons atom) which makes no sense anyway since l1 is not a cons
20:49:38
sukaeto
beach: re: a non-tiling WM in Lisp - what's wrong with just improving on StumpWM's floating window mode
20:50:36
aeth
emaczen: I would try writing the simplest possible case and putting it in a pastebin (Github and Gitlab have pastebins built-in)
20:51:26
emaczen
I got into this in the first place because I was just going to upgrade SBCL instead of trying to find older sources
20:56:52
aeth
emaczen: one thing you could try doing is compiling an SBCL half way between the current version and your last-working version, and continue doing a binary search until it breaks
20:59:19
verisimilitude
If I were you, I'd check my use with the relevant parts of the standard and, if I'm using it correctly, cease caring.
21:00:01
emaczen
verisimilitude: Yeah, I'm going to try what aeth said, and download and try other newer versions than 1.4.6
21:03:01
aeth
Because if that doesn't work, and it's a problem with SBCL, then that halves the range where things could have changed
22:28:18
dxtr
If I have to construct a separate list for it first then that's fine - but is there a suitable function for that?
22:32:10
actuallybatman
dxtr: I would do: `for i from 0 to (-1 (length list))` instead of `for elt in list` and offset the pointer as needed. maybe do a macro that captures prev and next per iteration to hide the loop details.
22:32:12
no-defun-allowed
(defun mapold (function &rest lists) (apply #'mapcar (lambda (&rest args) (list args (apply function args))) lists))
22:32:51
pillton
dxtr: (reduce (lambda (last current) (print (list last current)) current) (list 2 3 4 5) :initial-value 1)
22:36:34
tempate
is this function well written or can it be improved? https://bpaste.net/show/4f85298c746e
22:37:52
tempate
on a different note, is it possible to change where a cons should point to in a list? That is, can I make the second element point to the fourth, removing therefore the third from the list?
22:39:11
verisimilitude
Yes, tempate; there are RPLACA and RPLACD functions for this, although you'll usually want to use (SETF CAR) and (SETF CDR).
22:42:31
pjb
tempate: otherwise, it does exactly the same as yours, how can you say it's hard to follow?
22:47:33
makomo
tempate: it's like FLET, except it allow recursion and one function referencing another
22:54:37
aeth
prog and go instead of labels? something something lambda the ultimate something something
22:55:01
pjb
tempate: so the micro-optimization here is to choose between two local variable and a list, knowing that sometimes you will just throw away the list (ie. when the run length is 1).
22:55:53
pjb
tempate: also, since having a list is so important here, I would avoid `(1 ,i) and use instead (list 1 i). (actually I would use (setf run-length 1 item i)
1:11:05
Xach
dxtr: i have a trick i use but i don't know if it fits your situation, just curious about it.