freenode/#lisp - IRC Chatlog
Search
12:42:32
hajovonta
like (multiple-value-bind (a b) (list 1 2) (list a b)) but it doesn't work because list only returns 1 value and the other will be nil.
12:48:45
jmercouris
what if the values in the list are like this (list "key1" "value1" "key2" "value2") what's the best way to turn that into an easy to access data structure like a hash-table?
12:49:26
Bicyclidine
(loop with result = (make-hash-table :test #'equal) for (key value) on list by #'cddr do (setf (gethash key result) value) finally (return result))
12:50:14
jmercouris
Bicyclidine: I was hoping for some built in, a library I'm using returns json results in that manner
12:51:02
jmercouris
Bicyclidine: Doesn't matter, just means I'd have to make a "utility" function, I wouldn't like embedding that snippet into my codebase
12:51:55
flip214
jmercouris: but if there are not that many entries, a simple list might be faster to process.
12:52:10
flip214
jmercouris: or you could tell your json library to return a hash-table in the first place!
12:52:44
jmercouris
What I currently have is like a (position "key" list) and then do nth +1 on the position of the key I'm looking for
12:53:38
jmercouris
flip214: Not too many, so it is okay, I think it'd be smarter to change the json lib return though, you're right
12:53:54
jmercouris
there is (yason:parse stream :object-as :plist), I'm sure there is :hash-table as well or something
12:55:31
jmercouris
e.g. (yason:parse ...) and my cursor is there, can I jump to the docstring for that function somehow?
12:56:55
jmercouris
sigjuice: That is quite useful, that one I did know about though, imagine something more like a help buffer
12:59:08
jmercouris
yeah, I wish it included a list of "keyword arguments" ... which "can be used to override the parser settings"
12:59:41
jmercouris
so maybe it does make more sense to just jump to source instead of opening a help buffer with the docstring
13:00:13
jmercouris
yeah, I see the following: (check-type *parse-object-as* (member :hash-table :alist :plist) as possibilities
13:00:59
sigjuice
I didn't read far enough to see that %parse was a thing. I saw *parse-object-as* and immediately mmmdotted
13:03:16
sigjuice
also a quick experiment: CL-USER> (with-input-from-string (s "{}") (yason:parse s)) => #<HASH-TABLE :TEST EQUAL :COUNT 0 {1008D960A3}>
16:09:19
borei
some non-technical thoughts, but rather more language philsophy. Using lisp for last 8 months i started to realise that im using (or trying to use) it in the same way like i used to use "traditional languages" - like C/C++ or python. The same classes, functions, program structure etc etc. Recentely i found very interesting book - "Let over lambda". That book is targetting to change approach in regards to programming in lisp. Now i'm trying
16:09:19
borei
to find how to implement "true lisp" solution to particular problems. Not easy task id say.
16:11:41
jackdaniel
borei: LoL doesn't show how Lisp practicioners solve problems. It may be amusing though.
16:14:12
borei
can't say, but it opened eyes is absolutely different way. I finally started to understand what is closure, but don't know how to use it, except for couter-like problem.
16:14:27
dlowe
borei: unlike some, CL is not an "opinionated" language, so you should feel free to work however you want. You can pick tricks up along the way.
16:15:47
borei
true, but i think very important part is - to know your "tools set" and to how to use that tools in most efficient way.
16:20:03
jmercouris
it really depends on the problem at hand, different approaches lend themselves to different tools, in the context of lisp, that may mean different paradigms that it supports
16:20:33
jmercouris
what others have said is true, lisp is not opinionated, this flexibility allows you to adapt your style to the problem at hand
16:21:47
pjb
borei: the only difference, is that closures are anonymous, and have all their methods (functions) in the same lexical scope, while with CLOS, methods are written all over the place.
16:22:51
pjb
So in terms of software engineering, you will usually want classes, as soon as it becomes more complex than an anonymous object with one or two methods.
16:23:12
jmercouris
what about this (defvar something (lambda () (print "my function"))) is my lambda still an anonymous function?
16:23:49
jmercouris
but I have a symbol pointing to it (or whatever the word for "something" in this context is)
16:24:47
pjb
And I argue that (lambda (x) x) is the name of the function (lambda (x) x), since we call functions with (<name> …) and ((lambda (x) x) …) shows that (lambda (x) x) is the name.
16:26:06
pjb
borei: one advantage of closures over CLOS objects, is that it takes its slots from the lexical environment. So "object construction" is easy and almost invisible.
16:27:26
Bike
when we talk about anonymous functions, what we're actually trying to emphasize is that functions are values like anything else, rather than some details of how binding works.
16:28:07
Bike
many programming languages do not allow functions to be dealt with as values, and only allow referencing them less directly through names. that's it.
16:28:08
hajovonta
what I really liked is that the author showed that it's possible to keep the lexical environment
16:28:36
pjb
Well, really, there's no (function-name f) operator, so we could say that in lisp, no function is named.
16:29:01
pjb
You can implement function-name returning a list of symbols fbound to the function. Not very satisfatory, and very slow.
16:29:06
beach
jmercouris: All Common Lisp objects are anonymous in that respect. But we have references to them. Otherwise the GC would get them.
16:34:12
jmercouris
beach: I just looked it up in CLHS which led to global environment, then indefinite extend
16:42:07
beach
_death: I think the minion maintainer has declared that the Cliki format changed and he is not going to modify minion to recognize the new one.
16:42:23
jmercouris
I feel like Guy Steele is a name I've seen before, is there something he is famous for in the context of lisp?
16:45:52
pjb
And of course, there's always will be FizzBuzzEnterpriseEdition. What a legacy! https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
16:47:36
jmercouris
beach: I didn't live in a pre-java world, so it hard for me to judge what life was like then, but java is a great language, with great ideas, it's just a little too verbose for my taste
16:48:18
beach
jmercouris: It had no new ideas. But it had the syntax that made C++ programmers think it was not too different. Boy were they wrong. It is closer to Common Lisp.
16:51:01
beach
jmercouris: If you have no GC, you can't really program only with references (or pointers) as we do in Java or Common Lisp, because you never know how many references you have. So you get this very complex programming style with templates, copy constructors, smart pointers, you name it.
16:51:49
jmercouris
I wish I knew C++ so I could understand the differences, I only know some basic C which doesn't have any of those features as far as I know
16:52:51
beach
jmercouris: Correct, C doesn't have those, which makes it totally impossible to write applications in it. The C++ features are there to make it somewhat possible.
17:15:22
beach
jmercouris: If you ever get stuck with using C or C++ to write applications, the best thing to do is to link you program with the Boehm/Weiser garbage collector and then you use pointers for everything just like we do in Java and Common Lisp. That's the only sane way to write applications in those languages.
17:17:44
jmercouris
beach: thanks for the advice, but I don't plan on working any C/++ jobs anytime soon :D
17:48:31
dim
well I still spend some time writting applications in C... in PostgreSQL-C that is... it's special, but not that bad
19:37:05
comborico1611
Why is it when you do M-del in Slime, all the text is deleted except for all the parentheses?
19:43:01
comborico1611
pjb: Hmm. I never realized that. I am new to Emacs, though. I just thought I would have realized that by now. Weird.
19:44:48
pjb
Instead of editing the text, with indiscriminate structure, with paredit you're editing the sexp, with it's tree-like structure specified by the parentheses.
19:45:15
pjb
So you have commands to process the text itself, and commands to process the structure of the sexp.
20:04:07
dim
jmercouris: then why not ignore lisp altogether and go write Python code instead, I wonder? paredit is really nice to have, and like everything, demands some learning... when new to Emacs I'm not convinced paredit adds too much to the learning curve after all
20:04:39
jmercouris
dim: You are free to your own opinion. You've presented a false dichotomy though; paredit or python, it doesn't work that way
20:05:03
jmercouris
paredit isnt THE killer feature that makes lisp good, so it doesn't merit frustrating new users
20:05:16
jmercouris
I believe it is best to slowly add things to your workflow as you master them instead of piling them on all at once
20:06:25
rumbler31
I find a tension between new users losing their proper nesting while hearing that "lisp has no syntax" to be a strong driver behind calls to use paredit earlier than other tools
20:08:04
rumbler31
I remember losing my nesting and staring at the parens thinking, where the hell am I supposed to add the missing one!
20:08:04
jmercouris
they don't forget how hard it was, they think it will save you frustration in the very near future
20:08:20
jmercouris
they are very correct about this, but I would say, when you get to that point, you can pick it up
20:08:29
comborico1611
rumbler31: That may be if the new user isn't using a book to guide them or something. And that is more of an experienced programmer coming to Lisp.
20:08:54
dim
all I'm saying is that if new to Emacs and paredit is installed, I'd be surprised that learning how to use paredit in Emacs would be much more difficult than learning bare Emacs
20:09:28
dim
(ok I also said that I don't understand why you'd target lesser quality tools than the ones you have)
20:09:52
rumbler31
comborico1611: what do you mean about using a book, are you following along in a text that is instructing you in what to type?
20:10:18
jmercouris
I don't disagree with you, it's not like I don't use paredit, I just think it's a lot for a new user, I could barely remember the movement commands after using emacs for a day
20:10:33
comborico1611
I suppose so. The position I'm in at the moment is to focus 100% of my time working on this beginner's book to CL. Then, if I'm still intersted in pursuing more Lisp coding, then add on things.
20:10:40
jmercouris
then again, it has been many years, so I am not sure how much I can really remember about how it was
20:13:09
comborico1611
I would go so far as to say if one doesn't know Emacs, skip Emacs and go through this book, then pick it up later. The disclaimer on that is whether the newcomer to Lisp is freestyling it or following in a book. If they are freestyling/more advanced, then whatever they want to do.
20:16:19
jmercouris
So, I'm thinking about how to represent something like the emacs window layout, I assume this done using a tree, right?
20:17:43
jmercouris
this would I guess show buffer1 on the left hand side, and buffer2 in the top right corner, buffer3 in the bottom right corner
20:18:42
cgay
You're more-or-less describing what a window layout looks like in CLIM/DUIM source code.
20:19:21
jmercouris
cgay: Ok, good to know that my reinvention of the wheel will be similar to existing paradigms :D, it means a step in the right direction I guess lol
20:24:52
jmercouris
I think I'll use a structs to build my tree instead of plain lists, it'll make it conceptually easier for me
21:55:46
pjb
comborico1611: in anycase, for all the minor modes listed in C-h m, you can disable and enable them at will. Most of the time, their command will toggle them: M-x paredit-mode RET Otherwise type C-u 0 M-x paredit-mode RET to disable, and C-u 1 M-x paredit-mode RET to enable.
21:56:20
pjb
However, before enabling paredit-mode you need to check that parentheses are well balanced. Use M-x check-parens RET
21:58:32
pjb
And yes, I agree that newbies may start using NotePad.exe (or nano) to edit lisp, and use the clisp REPL in a terminal (or rlwrap ccl or rlwrap sbcl). But not more than a couple of weeks. Once you feel the pain of working with a text editor and in a terminal, you should switch to emacs+paredit+slime and understand their advantages.
22:39:07
dim
what's the intended behavior when a condition is signaled and not handled from within a with-open-file form? is there an implicit unwind-protect that properly closes the file?
22:40:15
Shinmera
Just read clhs: "When control leaves the body, either normally or abnormally (such as by use of throw), the file is automatically closed. If a new output file is being written, and control leaves abnormally, the file is aborted and the file system is left, so far as possible, as if the file had never been opened.
22:45:00
dim
this old code of mine is a little hard to debug with its use of make-broadcast-stream to capture output and errors of uiop:run-program in both the console and a log file
23:04:41
pjb
dim: it's not that it's hard, it's that it may need to be exhaustive: the condition hierarchy in your application may easily be the triple of the size of your application class hierarchy.
23:05:11
comborico1611
pjb: Portacle has been a life-saver for me. It should be one of the first things that comes out of the mouth of the Lisp community to beginners.
23:06:17
pjb
Having been into programming since 1975, I tend to either have learned stuff before stuff existed, or just have a natural preference to go to the main reference (however hard or arid it may be to read), and to build my own tools.
23:07:37
pjb
Of course, I can understand the interest of having nice pedagogical environments (and even perhaps IDEs for professional work), but the former should be the task of teachers, and the both require a lot of resources to develop and maintain.
23:07:38
Shinmera
I've ironed out some more bugs in portacle today. There should be a new release tomorrow.
23:08:12
comborico1611
pjb: Yes, but as an active contributor to assisting beginners, I'm just telling you what my experience has been. You listed your recommendation for newbies (emacs+paredit+slime).
23:11:21
comborico1611
pjb: I've never seen nor seen a reference to that website. Sometimes #lisp is going to be the first place a person goes to for info. Anyways, I'm not trying to debate what's the best resource avenue for a beginner, I'm just telling you what I think as a beginner. And that is Portacle is the best thing out there for the growth of Common Lisp.
23:12:02
pjb
comborico1611: but don't tell it to me, since I'm a seasonned lisper. Tell it to your fellow newbies, by updating this cliki page.
23:12:47
pjb
It's when you're learning that you know best what information you need to learn. Therefore it's now that you should document that, leavining little bread crumbs on cliki.net
23:14:10
pjb
And furthermore, have fun browsing this wiki, there is a lot of interesting informations and links.
23:16:00
comborico1611
pjb: Yeah, I think it is really adequate as it is. My verbage would sound very fanatical/fan-boy. The first subject of the page is Portacle, so that's on target.