freenode/#lisp - IRC Chatlog
Search
10:54:20
jmercouris
So I have a file upload form on my website, and that returns me a object like this: #<FLEXI-STREAMS::VECTOR-INPUT-STREAM {1003014B23}>
10:54:44
jmercouris
one would logically think, based on the documentation of cl-csv https://github.com/AccelerationNet/cl-csv that you would be able to read this input stream
10:56:11
jmercouris
how can I get cl-csv to actually read it? I tried flexi-streams:octets-to-string, but that requires a string
10:56:38
jmercouris
so then I did alexandria:readm-stream-content-into-string first, but then it didn't work
11:00:57
_death
the vector-input-stream is a binary stream, and make-flexi-stream can make a bivalent stream reading from it
15:20:39
beach
Since things are quiet here, ... A few hours ago in the #clim channel, I was inquiring about the possibility of implementing a "desktop environment" in Common Lisp such that it could work both on a GNU/Linux machine running X11 and Gnome and on some ultimate Lisp operating system.
15:20:48
beach
As it turns out, I am pretty ignorant about how such an environment would work. But it seems to me that the basis of such a thing would be a window manager, perhaps coupled with a workspace switcher.
15:20:53
beach
I am aware of Stumpwm, but I am not aware of a recent non-tiling window manager. As it turns out, though, my students wrote such a thing some 15 years ago, called Eclipse, but it hasn't been worked on for the past 8 or so years.
15:20:55
beach
If someone with knowledge about desktop environments would be interested in reviving Eclipse (and perhaps giving it a better name), I would encourage it. :)
15:22:49
beach
I don't know. It might very well work. But I suspect it is not entirely conforming when it comes to all the X11 conventions that a window manager must follow.
15:23:34
beach
I also don't know whether it could just replace the default window manager that I am using on Ubuntu, or what it would take to make that possible.
15:35:56
Josh_2
Any reason why I might be picking up a null character when sending data over the network?
15:36:25
Josh_2
The start of my string which is sent over the network has a #\nul and #\! at the start even though that is not present on the sending side
15:38:25
dim
beach: I was at school with Iban Hatchondo in Bordeaux in 1st year of university eons ago, but then I moved to other places… fun to see his name again ;-)
15:43:46
Josh_2
That gives me the string "\0!{\"resolution\":{\"x\":720,\"y\":1280}}" on the CL side
15:47:17
tempate
this may seem like a very stupid question, but I don't know when I should be using a macro
15:47:43
jackdaniel
tempate: when you have a boilerplate which you want to abstract into a single call
15:52:30
beach
tempate: The advice from jackdaniel is correct, but more general. A function may very well work for some boilerplate code.
15:55:07
tempate
coming from C, I don't really think in those terms, so when coding I think in terms of functions taking arguments and spitting results
15:58:10
phoe
imagine if the C compiler could generate code that looks like loop { for x from 0 to 10; for y = 2 * x; do { printf("%s %s\n", x, y); }; finally return 42; }
15:58:42
phoe
that's more or less what Lisp macros allow you to do with the syntax, since this is exactly how Lisp's LOOP macro works
16:00:38
beach
tempate: Except that Common Lisp macros are sane because they work on code as a data structure instead of text.
16:01:59
beach
tempate: You can think of functions as control abstractions, classes as data abstractions, and macros as syntactic abstractions.
16:02:24
djeis[m]
It's like if you could write C macros in C and they took a datatype more useful for manipulation than just strings.
16:02:34
phoe
C macros are interpreted by the C preprocessor and therefore have very limited abilities; Lisp macros are interpreted by the same Lisp engine that powers the rest of the system and therefore can use all of Lisp functionality to generate Lisp code.
16:03:13
phoe
that allows you to use e.g. functions, classes, other macros, to generate Lisp code inside a macro.
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