libera/#commonlisp - IRC Chatlog
Search
22:43:34
Krystof
the pattern we use is something like (defmacro deffoo (...) `(%deffoo ... (source-location))) (defun %deffoo (... source-location) <store source-location wherever you like> ...)
22:43:50
Krystof
then whatever consumes your source locations needs to know where you've stored them; I don't think we have a protocol for that
22:45:16
NotThatRPG
Ah. So one *calls* source location, and it gives you back the source location to do with what you will.
22:54:49
NotThatRPG_
I didn't mean to imply that it's more awful than it needed to be. But awful it did need to be.
22:56:29
Fare
The awfulest parts are those that deal with portability across 17 implementations, in UIOP. Especially the portable run-program facility.
22:58:43
Fare
pathnames are a mindfuck, though. There is a wide gap between that the standard specifies and what is common practice in today's world.
22:59:04
Fare
with plenty of undefined behavior that every implementation does in subtly different ways.
23:00:41
Shinmera
I have often thought about starting a thing for a secondary path mechanism that's more tailored towards modern systems, and adding support for that to implementations, but doing so is too much effort even for me.
23:02:25
Fare
but then you have to hook it up into LOAD and all other primitives that deal with paths.
23:02:33
Shinmera
did it? My idea would have been to allow using cl:open/etc with this new path type.
23:05:08
Fare
Also, anything that binds wrapped low-level resources to high-level variables introduces "interesting" issues to make your program async-safe. No one tries to do that because it's too hard (except for the Erlang guys maybe), but I wonder what an async-safe lisp would look like.
23:06:06
Shinmera
I'd give a lot to have the kinds of convenience that exists in JS and C# with the async keyword.
23:08:18
Fare
(well, I use Gerbil on top of Gambit, but it inherits Gambit's relatively good async behavior)
23:08:39
etimmons
One of these days I want to add environment variable support to run/launch-program. Gonna probably take a while to get it right, though
23:09:43
Fare
etimmons, even more "interesting" to get right portably. You may have to punt on many implementations and/or extend them properly.
23:10:06
rotateq
and how do C# and JS do the async stuff? a friend told me in Rust the async is with some kind of continuations, but idk
23:14:43
Shinmera
rotateq: marking a function async causes its return value to be a kinda closure. The await keyword within an async function marks a continuation/closure chain point. So async foo(){ x = await bar(); } returns a closure that should be called when bar() completes. when invoked, the function then resumes, binding x to the result of bar().
23:15:11
etimmons
Fare: by the way, I don't know how much you've checked out of gitlab emails, but I opened a merge request on reader-interception yesterday
23:15:25
Shinmera
rotateq: This makes async programming 1000x less painful because you can essentially pretend it's still imperative in most cases.
23:15:47
Shinmera
You could potentially do something like this in CL but it would definitely require code walking, and yikes.
23:19:12
random-nick
Shinmera: I think you can do something like that with cl-async and green-threads
23:20:06
random-nick
rotateq: scheme's spec requires call/cc, which means that most implementations support it and/or some saner alternative
23:20:57
hayley
And then you have a whole lot of synchronous CL code to deal with, so you won't get very far with async colouring.
23:21:02
random-nick
I think you can implement coroutines using sleeping OS threads, but that is not exactly resource efficient
23:34:39
mzan
hi, I'm blocked on this "problem". I'm not able to optimize CL code using series. It is not converted to normal loops, and it uses all the RAM. This is an example https://0bin.net/paste/n7fhjDxt#7SLnyit7-VDat6Ae5okgznwv5p1vbRmzqVylJWqK8+1
23:41:17
mzan
Shinmera: I don't know if this can help, because I'm a newbie, but there were this interesting discussion about asyncs https://news.ycombinator.com/item?id=29016796
23:49:22
mfiano
hayley: Hehe, I was referring to Robert Nystrom's article, but I can't argue with the Floyd.
23:50:46
_73
Question about exporting symbols that are only used as arguments to a function: http://dpaste.com/HVTYXNY9G
23:52:30
mfiano
Keyword symbols are self-referential, and suite uses like enum variant testing such as this well, and need not be qualified.
2:38:12
semz_
I'm not happy to ask this, but does there exist a CL implementation that compiles to Javascript?
2:39:28
Guest74
_death: while interesting it wouldn't work. This would be for reading/writing to dumb buffers gotten from drm.
2:42:10
Guest74
bike: shouldn't it be possible to have the header in lisp and simply have the pointer to the data point to foreign memory? Or header and data are contiguous?
3:43:02
dbotton
Wanted to share very early work on CLOGs GUI/Web Builder https://usercontent.irccloud-cdn.com/file/yq1ZLK9b/Screenshot%20(2).png
3:50:31
dbotton
That is all running in a web browser, of course can run "native" by using electron / ceramic, or add the panels to any web page of any framework of any language by a simple include.
4:12:45
_death
like I said, these limitations are not inherent to the approach.. but looking at DRM dumb buffers, it indeed might not work, because you don't get to pick the buffer's offset
4:14:53
Guest74
ah, I just read the readme and haven't looked at the code yet. It might be useful for clx though. X allows you to provide the mmap.
4:17:02
Guest74
it's just something that would be interesting for the future. copying the array to foreign is sort of a poor mans double buffering.
4:17:15
_death
the way it works is to have a page before the pages of interest where the last bytes are the array's header
4:21:46
Guest74
I was just thinking of the shared memory extension, but sounds like it'd possibly work for the buffer as well.
4:24:40
_death
but this header creation etc. really belongs to the implementation.. so it should probably be a contrib or something
4:27:49
Guest74
I think I eventually need to run on something besides sbcl. Maybe once everything is working smoothly.
5:30:32
abrahms`
Hi all. I'm trying to figure out how to iterate across the Nth item of a bunch of lists. I have a list of lists. I want to process the first element of each list, then the second item of each list. I feel like there should be a way to do this without setting a variable and looping index by index.
5:50:00
akater[m]
abrahms`: apply mapcar or apply mapc, or it's unclear what you want, show a form&result snippet.
5:51:46
abrahms`
Then I would want to map over the result, so if it's combined with map, that's great.
5:54:51
abrahms`
T_T I'm terrible at this right now. Spent 2.5hrs on it yesterday in what would have taken me ~20m in python.
5:55:27
abrahms`
I conceptually know what I want to have happen, and I'm fairly certain it's doable (and maybe even a good idea?) in lisp.. I just don't know the incantation for it.
5:56:40
abrahms`
Guest74: Yes. Didn't occur to me that it may spoil things for others until you just asked. :-/
5:57:30
Guest74
The test examples help to find stupid errors. I keep forgetting that and wasting time, finally got it after using the test data.
6:00:58
akater[m]
abrahms`: btw If you have only two list elements, maybe just write a loop with 2 for clauses.
6:08:24
abrahms`
Day one was mostly fine. I was struggling to figure out how to load in a test runner. Day two was spent figuring out how to correctly convert a string into a callable symbol. I had forgotten about funcall. :-/
6:10:40
Catie
Guest74: This is what I came up with, I don't think it looks that bad: http://ix.io/3GQq
6:12:03
Guest74
catie: reverse! why didn't i think of that. Summing also looks nicer, I was dpb'ing bits.
6:17:08
mfiano
bit vectors don't really buy you anything over a fixnum, except more bits, and lots of consing using the result of a bignum
6:18:12
dre
I've got the test solution worked out, https://gist.github.com/Dotrar/dcd4bf24dc4dcec0f11eeb1cfaea2583
6:19:05
Catie
mapcar'ing over many lists in parallel processes their elements in order, similar to how you hard-coded first, second, etc
6:20:02
beach
dre: You need to start paying more attention to your code layout. Sometimes LET is followed by 1 space, sometimes by 2, sometimes by 0. Sometimes COERCE is followed by a newline, sometimes not.
6:20:38
beach
dre: You want to avoid distracting the person reading your code with small stuff like that.
6:32:58
dre
ok, so I can get to a '((0 1 0) (1 1 1) (0 0 1)) list, but how can I sum that into => (1 2 2) ?
7:25:24
pjb
dre: time to read and understand: http://www.99-bottles-of-beer.net/language-common-lisp-114.html
7:43:49
flip214
I guess that (mapcar (alexandria:curry #'reduce #'+) '((0 1 0) ...)) would scale better than an apply
7:52:24
dre
how can I use the debugger effectively? trying to run my code, I come up to an error but if i use BACKTRACE -- I don't know how to parse the output
7:54:12
pjb
dre: assumedly, in the function save-lisp-and-die, there's a function defined with flet, perhaps WITHOUT-INTERRUPTS-BODY-14, and that frame corresponds to the activation of that local function.
8:02:26
abrahms`
dre: https://gist.github.com/justinabrahms/d9d110c55ad5f53288a56d0cc882aa1e - this was may day 3 part 1.
8:06:43
dre
that looks nice actually, blows my mind more than mine. I'm trying to not use packages ( by ignorance, not by intention :P) https://gist.github.com/Dotrar/dcd4bf24dc4dcec0f11eeb1cfaea2583
8:07:36
abrahms`
the packages are literally for writing small tests & logging (b/c I didn't know there was a print function)
8:08:52
abrahms`
I'm trying to do this without just writing a for loop. Think I might be in over my head for #2.
8:10:42
dre
when you get the gamma binary value, you use that as a filter on the list, down to single values. so if the gamma is 10101, filter all the items that start with '1', have you got 1 left? no? then filter down all the items that have '0' in the second spot, have you got 1 left? no? then ....
8:13:18
dre
this is what I've got so far for number 2: ( just updated gist, refresh) https://gist.github.com/Dotrar/dcd4bf24dc4dcec0f11eeb1cfaea2583
8:13:36
abrahms`
going to not click it yet. Haven't given up hope, but the clock is against me b/c I'm tired.
8:14:16
abrahms`
I'm hoping to get this mostly done tonight so I don't just think about this all day at work tomorrow.
8:14:50
dre
does anyone know where my error might be? so when I run the "aoc-process-part-2" - I get past the "princ binary-commons" bit, but somewhere in the filter-down-to-one I get an error.
8:15:16
dre
abrahms`, tbh I was sad that I couldn't chew on yesterday's problem. I solved day-2 too fast.
8:15:37
abrahms`
day 2 took me like 2.5 hours b/c I couldn't figure out how to turn a string into a callable symbol.
8:16:41
abrahms`
https://gist.github.com/justinabrahms/30eb516358bc72a7e16b802136b8b025 - Learned about destructuring-bind when I showed it to someone.
8:37:32
lisp123
suprised how many people are doing advent of code -- didn't know it was such a huge thing
8:52:31
flip214
I've got a DEFPACKAGE that does (:IMPORT-FROM ...); during compilation of that package.lisp file I get an error that these symbols do not exist (yet), because I don't want to export them.
8:53:30
flip214
well, just doing (:import-from <package> <package>::symbol...) works of course, because then they're defined when DEFPACKAGE runs
8:53:32
beach
abrahms`: Please try to lay out your code according to conventions. A closing parenthesis should not be preceded by whitespace.
8:55:56
beach
Also, your use of (caddr acc) as a Boolean value is a violation of the rules stated on page 13 of the LUV slides by Norvig and Pitman.
8:56:02
abrahms`
Ah. I tend to be a bit of a pain in that I gave up arguing about code style and now I just insist that there's either a tool or no one cares enough for it to matter to me.
8:57:25
flip214
abrahms`: well, the indentation rules are built into the "important" editors emacs (and vim), so it takes work to get it wrong... therefore there's no linter
8:57:45
beach
abrahms`: Not at all. When you submit code for others to read, it is important to follow conventions, or you are going to waste the time of people reading your code, simply because they are going to be distracted by all those cases where conventions are not followed.
8:58:12
abrahms`
beach: the thing that threw me off was the quoting of the rules. :) Sounds very serious business.
8:58:33
beach
abrahms`: If it is a true Boolean, then in an IF it is fine. But if it is NIL as a default value, then (NULL <that value>) is preferable.
8:59:12
abrahms`
The code alternates between there being a function there and there being a nil. That denotes whether we're waiting on an incoming command or an incoming integer.
9:00:50
beach
abrahms`: Note that I am not talking about language semantics here. It is about the message that you send to the person reading your code.
9:01:19
beach
abrahms`: And since you are submitting your code for others to read, I am giving you the feedback as one such person.
9:02:57
abrahms`
beach: Cool. I appreciate the feedback. I'm not clear on how my use of if to check if something is nil or a function violates the "be as specific as your data abstractions warrant" from slide 13. http://www.norvig.com/luv-slides.pdf
9:07:04
lisp123
abrahms`: You could try (defun function-exists-p (acc) (caddr acc)) or something like that. Although I would put it as a local function if its not meant to be used elsewhere
9:08:01
lisp123
Just looking at the code, I would have no idea what (caddr acc) means (i'm not even sure if its function-exists-p, but I'm guess based on this chat), and in a few months you might also forget ;)
9:08:27
lisp123
At least from my personal experience, I found it better to write very clear code vs. having to spend hours later trying to figure out WTF i did
9:09:07
abrahms`
It's a good callout. I haven't gone back and edited it, but after showing this to someone, they told me about destructuring bind which simplifies some of the shenanigans in there.
9:12:24
lisp123
Although I personally have been avoiding its use to some degree, I think it might cause interface & implementation to overlap
9:13:23
lisp123
Since you are assuming a list structure. If later you wanted to use a structure or class to represent the data object, then you will have to go back and rewrite all parts of your code that rely on it being alist
9:13:54
beach
abrahms`: What lisp123 says. If your value can be a function or NIL, then you can use FUNCTIONP or NULL to test one way or the other. If it is a Boolean, i.e., it is either true or false, using it directly in the TEST of an IF is fine.
9:14:10
abrahms`
I haven't played much w/ the non-list data types in a long while. I did PCL ~5+ years ago and I don't use common lisp regularly. Just picked it up for advent of code.
9:18:41
abrahms`
lisp123: It's mind-bending and difficult currently. I'm dramatically faster in my primary languages.. with time & effort I'm sure it'll improve.
9:25:06
lisp123
abrahms`: Yeah, I think we have all felt that to a degree. For me certainly, but I've learnt a lot and glad I stumbled upon it. And even if you don't program in lisp too much in the future, you can re-use some of its concepts in other languages
9:28:00
lisp123
Recursion, higher-order functions and the CLOS approach to OO programming were the main things I picked up
9:40:51
abrahms`
Totally. I've got a solid grasp on recursion & higher order functions.. I haven't played with CLOS at all though. Anyhow.. I'm off to bed. g'night.
9:52:49
beach
I keep being puzzled by this phenomenon. Even some professional programmers seem to be unaware of the existence of coding conventions. Is it that the existence of such conventions is not taught? Or is it that these professional programmers have not had any training? I am not talking specific coding conventions for specific languages, but even the very existence of conventions seems to be questioned here from time to time.
9:55:53
susam
If you observe this phenomenon in younger programmers, it totally makes sense. I don't say this with the intention of being disrespectful. It's just the reality today. A lot of people who get into programming these days, get into it with motives different than what we had when we were younger. For example, for many programming might just be a way to earn money and they do not care about it beyond their
9:56:53
beach
That, I understand. What I don't understand is how these people managed to get hired to become professional programmers.
9:57:14
hayley
For some people, perhaps, but they're older than me (but then, say 25 is "older" for me, and not for you two).
9:58:14
susam
Because hiring at many company these days focuses on solving leetcode type problems and some system design round. None of these really evaluates exposure to "programming culture".
10:00:10
susam
I remember, 15 years ago, when I was conducting an interview, I used to ask the candidates if they have developed any side projects using their technology of interest. I wanted to know what kind of passion they have for programming. I considered asking such questions completely fine back then.
10:00:26
hayley
I guess. I've thought to myself that those people would be better off growing vegetables (or literally participating in any other profession), since otherwise they seem to think very negatively of programming.
10:01:04
hayley
*participating in literally any other profession; word scheduling is important there.
10:01:11
susam
But today I think such questions may be considered controversial. In fact, I myself find it controversial. One might argue, what side projects they do is none of my business. One might argue, that I must focus on what they do on job only.
10:02:48
lisp123
Eh, this all sounds elitism to be honest. There's no right way and most of these subpar programmers are producing useful code, however inefficient it may be written
10:02:53
hayley
Well, short of some uninteresting very short jobs I had in high school, the résumé I wrote but never used only has side projects arguably.
10:03:02
beach
I can understand why one can aspire to a profession without being passionate about it, but it is truly shocking to me that there is no filtering process.
10:03:26
hayley
lisp123: It's unrelated to being a subpar programmer or not, though the people I am thinking of seem to actively encourage rubbish programming style.
10:03:50
susam
lisp123: I see your point and it can indeed sound like elitism and that's why I don't share this often with others. But in my heart, I know I feel disappointed to see the craftmanship in this field gradually eroding.
10:04:21
beach
lisp123: I am frequently accused of being elitist, but when I see the bugs in devices like the TV decoder or the microwave oven, I think there is a huge problem in the industry.
10:05:30
lisp123
hayley: In 'theory' there is definitely a clear divide between good code vs. bad code, good programming style vs. bad programming style. But often it might be because they were optimising for something else (less time to study / learn, spending more time on getting a proof of concept)
10:05:40
hayley
My motives involve using the computer as a means of self-expression, and as a device to slack off all day. The latter part incidentally requires that I don't write bad code, else I would be stuck spending more time maintaining it.
10:05:43
cranium
don't know about craftsmanship, but it's silly to expect professional programmers, i.e. people who already do this all day, to have side projects.
10:05:47
Nilby
I've worked with many programmers in industry and academia, and my observation is following coding conventions is highly correlated with some ineffable personality traits, but not practical skill or education. Even when it's attempted to be enforced, it can fail.
10:06:25
lisp123
(So I agree with all of your comments, but (not related at this group), often its not because said programmers or professionals were doing a 'bad' job, but they were focusing on different things)
10:07:30
susam
Nilby: I have enforced coding conventions in my teams and it has worked. At least 3 of those engineers have told me after a year that while they hated it initially, they love it now and they see the benefits of following coding conventions.
10:07:49
hayley
lisp123: I think those targets for optimisation are subjective too. With regards on getting a proof of concept: I have heard some people to write buggy code to illustrate a point. Some other people, like Leslie Lamport, argue that having a mathematical model suffices as a proof of concept, and if such a model can be checked, it is probably not buggy too.
10:07:54
beach
lisp123: You misunderstood my opinion. I expect no such thing. I merely expect people to recognize that there is such a thing as coding conventions, separate from the concept of semantics.
10:07:56
rotateq
ACTION experienced some filtering: "Oh, you can't do Java or some of our other mainstream web/app technologies and just understand things well we don't know? Then we cannot use you."
10:08:24
pve
It may be that if someone is trying to learn a new language by themselves, they do not prioritize learning conventions early on, even if they know such a thing exists. It only becomes a problem when they go on irc and try to show their code.
10:09:02
beach
pve: But the phenomenon I describe is that people don't even recognize that there is such a thing, or at least not the importance of conventions.
10:09:33
cranium
Things like the former two should be done/enforced by tools. Configure your code formatter, add it to vcs and forget about the topic.
10:10:05
beach
cranium: Code layout is the most basic stuff. But then there is naming conventions, organizing the code into modules, simplifying maintenance by making the code easier to read, etc.
10:11:12
hayley
Once I went and looked at some automated code "quality" tool (which did not support Common Lisp, of course), and looked at the warnings it produced. The warnings consisted of stuff like "There is a line with nothing but spaces on it." Who actually cares about that?
10:11:40
pve
beach: I understand. Though, I could see someone considering Lisp so alien in the beginning, that the notion of "conventions" flies out the window.
10:11:55
lisp123
hayley: Sure, I think the argument goes both ways. "My code was bad because I was focusing on "business"", when it was just bad
10:12:31
hayley
lisp123: Your business is damned if you do nitpick your code, and damned if you don't.
10:13:24
susam
Haha! That's quite true, hayley! I love it and I am going to steal your line and use it in future.
10:13:41
lisp123
beach: Sorry, I was probably slightly confused. I think that following good coding conventions is positively correlated to good code quality, so one should expect poor adherence to coding conventions in the same way one should expect poor code quality (because it does and will keep happening)
10:16:09
mzan
Hi, I'm stuck on this https://dpaste.com/9G6666P3K The function using "series" is not compiled to an efficient loop.
10:17:38
mzan
The code is working, but I'm not happy knowing that if the input file is too big, it will crash, because it should be compiled to an efficient loop working on streams.
10:18:18
mzan
So it should be a loop on all elements of the series (i.e. random numbers), discard them, and then return the last element.
10:20:34
mzan
I like series because I used Haskell a lot in the past, and so they seems rather natural for me. It seems also a way to create more useable code respect an explicit loop.
10:21:01
lisp123
beach: Thinking about it more. I think perhaps the blame should lie on all the teachers (online blogs / videos / fellow coders / (perhaps universities, but I wouldn't know since I didn't do a CS degree)) --> Had there been a stronger teaching of the importance of various concepts, some of these bad practices wouldn't propagate as much
10:22:57
susam
I doubt any CS degree has ever taught what I call the "hacker culture". It is something we used to pick up by working with other developers and seeing how well established open source projects are executed. For example, when I sent my first patches to an Apache project some 15 years ago, there were multiple rounds of reviews and I learnt a lot about the culture. Other sources were just browsing online
10:23:44
lisp123
susam: Isn't that the issue though? It should have taught these things properly vs. you finding them own as you were passionate / intelligent / hard working. Because we can't expect all to be the same
10:24:52
mzan
susam: in fact some folks suggests to follow the pull-request workflow of goo OSS projects. Studying the code is useful, but reading the pull-requests can give many hints about the standards they are following.
10:25:13
lisp123
I programmed as a side hobby during school and later on, but I only learnt about interface vs. implementation from #CLSCHOOL and studying lisp --> Is that a failing of myself or of the system
10:25:58
susam
lisp123: I agree that there is an issue but I am not sure where the solution lies. For example, I don't have a CS degree, so even if they did teach these things as part of a degree, most people like me wouldn't learn it.
10:26:55
hayley
I just don't think computer science courses ever make anything seem fun. Say, one assignment might be about a made-up Mr. Robert who had an idiot intern mess up his database which seems awfully poorly constructed just so that you get to practise one particular aspect of your programming language. If it's supposed to give industrial experience, it comes off an awful like an old fable, where the entire world is constructed to teach one stupid
10:28:06
hayley
Speaking of, the two "hackathons" I participated in were devoid of any hacking, and they were solely to come up with ideas to impress someone from a big tech company, who might even hire you to let them steal your idea if you're lucky.
10:28:21
susam
I just think it is a dilution and erosion of craftmanship which is natural when a field grows so much that it attracts everyone (the passionate and the dispassionate). Say, playing piano was as hot a field as computing is today. Say, anyone who can write a 30 second jingle with some basic notes gets a job and earns money. I am willing to bet that we would see the same erosion of craftmanship in that
10:28:39
lisp123
hayley: I dropped out of my IT degree aeons ago because it was so removed from actual programming :( I blame myself but I know what you mean
10:29:35
hayley
A month ago or so I watched some videos of the late Seymour Papert teaching programming. His audience was much younger children, but I still felt robbed of any actually engaging materials.
10:33:04
hayley
I got the same feeling from reports on early use of Smalltalk, which Adele Goldberg and Alan Kay taught to children. In "Personal dynamic media" <http://www.newmediareader.com/book_samples/nmr-26-kay.pdf> there are quite a few brilliant programs...written by children. It's really insulting when I was 18 upon entering university, and spent a whole semester writing programs which would read and write crap into a hash table, more or less.
10:35:16
hayley
"A mathematician's lament" <https://www.maa.org/external_archive/devlin/LockhartsLament.pdf>
10:36:32
hayley
The first page is quite ironic for me, because I dropped out of music classes at high school because I was terrible with music theory.
10:37:20
susam
Logo has had a big impact on my life. I have written a small post about it here: https://susam.in/blog/fd-100.html
10:41:06
susam
lisp123: Yes, indeed. Imagine the joy of a childhood kid getting excited drawing those stuff on an otherwise boring monochrome CRT display. The video link shared by Hayley is pretty cool too. I indeed used to spend a lot of time drawing those random raft patterns showed at 10:40 of the video.