freenode/#lisp - IRC Chatlog
Search
12:29:23
pjb
minion: memo for asarch: genera and instructions can be found at: https://cliki.net/VLM_on_Linux
13:18:16
lieven
minion: memo for asarch: for recent X versions, you need to patch genera. See https://archives.loomcom.com/genera/genera-install.html#org783aa06
13:20:49
chimneys
I have to know how lisp is more powerful, say if I write a program to open 1000 emails in python it works, so programs can do things that cannot be done manually , similarly give an example in which lisp can generate programs 1000's of them which simply can't be done using python manual programming.
13:22:44
lieven
python is turing complete and so can trivially do anything Common Lisp can, if necessary by implementing Common Lisp in python. See Greenspun's rule and the blub paradox.
13:28:16
beach
chimneys: As lieven says, Common Lisp is no more powerful than any other Turing-complete language, so there is nothing that can be done in Common Lisp that can't also be done in any other Turing complete language. It might be more convenient to do certain things in Common Lisp than in (say) Python, but those things can still be done in other languages.
13:31:15
beach
chimneys: If you think that the language doesn't influence your productivity, you should probably not waste your time learning Common Lisp.
13:31:17
chimneys
for example you could say I can make million email-ids using mouse and keyboard, yes but it will take forever. so is there any metaprogram that generates programs that can't be generated but manually one by one
13:32:11
lieven
ralt: python function annotations can run arbitrary code at function definition time so close enough I guess
13:33:04
beach
chimneys: Shinmera is (rightly so) concerned about other #lisp participants wasting valuable time from their respective projects.
13:38:15
jayspeer
heh, and you guys wonder why so few people use lisp :D get that stick out of your a**
13:40:54
nickerpro
i came to lisp because i thought i could do cool thing in it, they say ti's turing complete like python so nothing special
13:41:00
beach
I think I have a fairly good idea as to why relatively few people use Common Lisp. And it is nothing that could be fixed by participating in this kind of discussion.
13:41:13
flip214
chimneys: IMO one of the major advantages is that CL allows for a much bigger bandwidth of abstractions. You can easily build very high-level abstractions (classes, and macros for eg. control flow), but also influence the generated machine code.
13:42:40
Shinmera
jayspeer: We get this same shit every week. It doesn't help, and it's mind numbingly boring noise.
13:42:41
beach
No, "special". You said "so nothing special". And I am saying there is something special, but it is not Turning completeness.
13:43:29
flip214
chimneys: as an example, macros in lisp allow you to build an abstraction for defining classes and methods on them
13:43:45
jayspeer
Shinmera: maybe bot can automatically message user with relevant links? It would both take it off us and provide useful information
13:45:42
beach
jayspeer: I think an answer from a real person is more valuable, and why try very hard to give good answers to good questions. Besides, the kind of people who have bizarre questions probably wouldn't read the document that the link refers to.
13:48:07
pjb
Responses from a real person are good only if the telepathic link can be established, so that the response given may lead the asker to the real answer to the actual question he had.
13:53:03
beach
Shinmera: Interesting observation that there is more stuff like this during the weekend.
13:57:07
phoe
when it comes to the languages themselves, I'd say so, yes - the interactivity is really fun when you get to play with the language
13:57:25
jackdaniel
good programmers will write good code in both, although cl could be much of an aid to do so
13:57:54
beach
chimneys: There are almost no scientific studies that compare the productivity of programming languages, and the ones I know of do not feature Python. So it boils down to personal preference.
13:57:55
phoe
I love myself an interactive debugger&inspector combo that's always present and allows you to inspect the stack, check on the values bound to the variables there
13:59:05
phoe
plus the REPL that's a part of developing in the language - you never really go "$ python my-script.py" like I did when writing Python, you run Lisp once and have it running in the background all the time while you compile a function after a function into the Lisp image, likely playing with it in the REPL after each compilation to check if it does what you hope it does
14:00:07
beach
It's too bad though. Some national or union-wide agency should invest in such a study.
14:00:32
phoe
it's less of tweaking a Massive File Full Of Code™ and more of playing with individual forms that you then send into Lisp - more like a conversation with the language that runs in the background than starting from a clean slate every single time when you run a program written in Python or C++ or another non-interactive language from scratch
14:06:18
phoe
a lot of that also boils to personal proficiency and preference, so is highly variable
14:06:44
phoe
but after trying both python and lisp I like the lisp environment more due to the interactivity and the amount of introspection that's available in there
14:08:42
phoe
jayspeer: at the same time I understand some people who are tired of this sort of discussion, mostly due to the "fame" that Lisp has on the Internet
14:09:15
phoe
"OMG it's t3h language that makes the impossible possible and the possible trivial, it's the MAGIC SECRET SAUCE™©® known only to some W I Z A R D S"
14:09:26
pjb
Once upon a time, I made a #clnoobs channel so that newbies could ask their newbie questions there without bothering the serious and advanced #lisp programmers…
14:11:08
phoe
I got that sort of impression from e.g. reading multiple Graham writings, and I directly blame him for that sort of popularity. He didn't write it like that literally, of course, but he certainly attributes too much to to Lisp itself.
14:12:31
phoe
Using a particular language won't instantly cause you to become a better programmer. Sure, working with Lisp for some time will have an effect on your overall code quality, but there's no "enlightenment" that is mentioned somewhere, there's no magic in here that will suddenly pour down into your fingers and all over your keyboard.
14:13:44
pjb
There's enlightenment! It can be achieved reading sicp (or wathching the sicp lectures).
14:16:19
phoe
jackdaniel: I'd imply it's positive, since e.g. in Lisp it's easy to try and express the same idea in multiple ways due to the fact Lisp is multi-paradigm. At least in my case, I got a few "ah-ha!" moments when I realized that the same problem can be approached from a different way and the language doesn't stand in my way when I want to go functional, or object-oriented, or declarative, or even linear or via a
14:17:59
phoe
where I can consult other people and actually figure out if the idea I'm trying at the moment is worthwhile or trashy.
14:18:38
phoe
anyway, about the magic - Lisp has multiple advantages over the years, so many that other languages have copied many features from it that are now considered "industry standard". I think that's one thing to keep in mind when glancing at the language
14:19:20
phoe
s/enjoy the #lisp part of Lisp/notice that consulting with the folk of #lisp has a direct positive effect on the quality of my code/
14:21:46
phoe
but then, code review is important in *any* programming language you're writing - so nothing that is really particular about Lisp in this case
14:22:44
phoe
as well as provides some context about the "aw shit, here we go again" reactions that happen on this channel - and why I blame Graham for that sort of stuff (;
14:26:04
Nilby
I think it's reasonable to say those that ask questions without basic understanding: "Don't use Lisp. Thank you. Please go away." For me, and likely those of you who are rebellious enough to write a lot of Lisp code, such an answer would only serve to increase my determination to learn it. But people who ask about how to cons, cdr, etc. should be treated with great kindness.
14:28:10
pjb
dlowe: perhaps it was discussed here, and I said somebody should make a #clnoobs channel, and somebody did?
14:48:35
phoe
luis: (ql:system-apropos "base64") followed by a series of (length (ql:who-depends-on ...))
14:49:02
phoe
this doesn't include transitive dependencies but in this case I guess the inaccuracy is bearable
14:53:35
luis
seems like s-base64 can't encode character streams. It might be a reason to use cl-base64 instead.
15:00:11
luis
jdz: cl-base64 has a stream-to-base64-{stream,string} symbols but no defined functions. Am I missing something?
15:01:37
ralt
was trying to think of a way to debug a production image without bothering production environment
15:04:26
jdz
Oh, right, I remember: I only need to decode stuff, and I've added stream versions for that.
15:06:02
luis
jdz: you might want to publish your fork on Quicklisp, maybe? You can call it jdz-base64 or amR6LWJhc2U2NA== or something :)
15:06:29
pjb
ralt: alternatively, you can use clisp who knows how to save images without killing itself.
15:08:41
pjb
I don't remember. It can re-open the open files, if they still exist when you reboot the image.
16:17:13
jmercouris
we are using trivia in our project, and I really don't like the 'trivial-x' libraries or the "_" as OTHERWISE
16:30:49
jmercouris
galdor: A variable-pattern matches any value and binds the value to the variable. "_" and "otherwise" are special variable-patterns (a.k.a wildcard-pattern) which match any value but don't bind.
16:37:51
galdor
I personnally do not like OTHERWISE in general, looks too much like "we did not have a better solution so let's introduce a special symbol"
16:45:40
remexre
is there a standard macro for "set this value in this place if the place's current value is nil"?
16:55:20
Bike
(defmacro supercalifragilisticexpialidocious (place value) `(unless ,place (setf ,place ,value)))
17:26:00
phoe
eeeeeta: I could probably write a macro to programmatically generate 80% of German speech
17:36:20
asdf_asdf_asdf
'(1 2 3) collecting i => (1 2 3) '(1 2 3) by #'skip-arg-1 collecting i => (1 3).
17:37:18
beach
asdf_asdf_asdf: (loop for element in '(1 2 3) for i from 0 unless (= i 1) collect element)
17:38:22
HiRE
It seems to repeat whatever is after the collecting part in the list you're looping over
17:38:49
beach
It takes the argument and sticks it in a list, which is then returned at the end of the loop.
17:39:13
Xach
asdf_asdf_asdf: (loop for i in '(1 2 3 4 5) by (first-then #'cddr #'cdr) collect i) is one option
17:42:53
Xach
one possibility: (defun first-then (&rest funs) (let ((fun (pop funs))) (lambda (obj) (prog1 (funcall fun obj) (setf fun (or (pop funs) fun))))))
17:44:43
beach
How does that help if the argument to BY is evaluated only at the beginning of the loop?
17:45:50
beach
(first-then #'cddr #'cdr) is evaluated only once, at the beginning of the loop, so how can this implementation of it solve the problem that asdf_asdf_asdf has?
17:45:55
Bike
the returned closure has the effect of cddr the first time and cdr subsequent times. there is only one closure but it maintains its own state, so the loop doesn't need to evaluate the function more than once. makes sense to me.
17:49:27
eeeeeta
Xach: and, thankfully, Lisp is a language where you can get away with not knowing that sort of thing? :p
17:50:52
eeeeeta
ACTION suggests Xach turn in the source code of quicklisp instead and leave it at that :D
17:51:24
Xach
oh god, that would earn me a very poor grade - the fact that people find it useful counts for nothing
18:01:16
HiRE
ah yes, monads are quite simple. They are just monoids in the category of endofunctors
18:04:49
asdf_asdf_asdf
Thank You Beach, Xach. I want Xach's example. How pop n item from list using keyword "by"?
18:09:08
ck_
ACTION puts "by implementing the desired semantics" into the book of phrases for a rainy day
18:09:41
asdf_asdf_asdf
(loop for i in '(1 2 3 4 5) by (nth 3 :default-list) collect i) => '(1 2 3 5)
18:16:21
phoe
https://stackoverflow.com/questions/4093845/is-there-a-common-lisp-macro-for-popping-the-nth-element-from-a-list
18:21:57
asdf_asdf_asdf
phoe, thanks. I want example above, but with (nth x y), not always second item.
18:24:12
phoe
asdf_asdf_asdf: that implementation of CDNTH and (SETF CDNTH) in the above answer seems correct though
19:02:38
pjb
beach: I can't even find where in clhs the semantics of for in by and for on by is defined. It's present in 3 loop clauses; by is described for 6.1.2.1.1 The for-as-arithmetic subclause, but doesn't say if the form is evaluated once or each time (but the example are as if evaluated once).
19:12:30
Xach
asdf_asdf_asdf: you could use (first-then #'cdr #'cdr #'cdr #'cddr #'cddr)! but that is ugly.
19:31:02
no-defun-allowed
cl-base64 has a helper function to convert a base64 string into a string, but I believe it's broken for non-ASCII characters.
19:32:45
no-defun-allowed
So, to use either library with text, you will also need to use the Babel library to convert an array of octets to a string and back.
19:44:05
galdor
iirc base64 operates on octets, not on characters, so having a base64 encoding functions taking a string as parameter is surprising
19:44:39
Xach
galdor: i can understand it as a convenience to skip a step (as long as it works properly)
19:44:41
galdor
of course the library could automatically decode the string, but it requires an encoding parameter (and probably a system such as babel)
19:45:23
galdor
yep, but people are rarely aware of the encoding aspect, they are used to the "everything is utf-8" approach of many "modern" languages
19:46:25
galdor
I was thinking today it's too bad there is no standard mechanism to configure external formats
19:47:13
galdor
you always end up relying on babel because it's impossible to use :external-format on e.g. OPEN in a portable way
20:10:46
karlosz
anyone know a good reference for load-time-value and eval-when outside of the spec? there are some trickier examples that i've wondered if someone already compiled a list of ambiguous situations
20:12:49
Bike
if there is one i haven't seen it. the most substantial writing i remember on eval-when is fare's blog post saying it sucks. what tricks are you looking at?
20:22:35
karlosz
specifically i'm looking at what order toplevel clauses have to be evaluated with respect to load-time-value. i guess to give context i just added block compilation to sbcl and wondering whether im running afoul of certain ansi specified load-time vs compile time distinctions
20:23:36
Bike
in clhs load-time-value: "It is guaranteed that the evaluation of form will take place only once when the file is loaded, but the order of evaluation with respect to the evaluation of top level forms in the file is implementation-dependent."
20:24:17
karlosz
for example, on CMUCL block-compiling a struct (say, foo) and defun f () (load-time-value (make-foo)) gives a load time error in cmucl
20:24:29
pfdietz
" the order of evaluation with respect to the evaluation of top level forms in the file is implementation-dependent."
20:24:35
pjb
Now of course, if you write: (defparameter *foo* (load-time-value (+ 1 1)) You can assume that (+ 1 1) is evaluated before the load-time effects of defparameter *foo* can occur!
20:25:08
karlosz
and i'm pretty sure it's illegal but not sure what language in the spec specifically forbids that
20:32:35
karlosz
i mean i'm asking from the perspective of an implementor what will run me afoul of the spec i guess
20:33:23
Bike
the spec doesn't define an order, so you can't run afoul of it in this aspect. go where your heart calls
20:33:30
karlosz
especially because CMUCL was the only other implementation that abused compile time name resolution as aggressively as it did
21:50:09
HiRE
hmm, upon defining a class (defclass blankaccount () (customer-name balance)) and loading it into SLIME
21:50:15
pjb
vms14: right. I would have used OO. All those functions are just methods of the same generic function generate taking arguments php-node
21:53:37
pjb
When I type (make-instsance 'ba it completes alone, I just type TAB to finish it without typo.
21:55:18
pjb
Sorry, wrong file; go to: https://github.com/informatimago/lisp/blob/master/languages/linc/c-syntax.lisp#L202
21:56:27
pjb
So of course, you need to define classes for the syntactic elements: https://github.com/informatimago/lisp/blob/master/languages/linc/c-syntax.lisp#L173
21:57:06
pjb
And write a parser or macros to convert a sexp into a tree of instances of those classes.
21:58:23
pjb
(generate (parse '(defun foo (x y) (+ y x)))) -> <php?>number foo(x:number,y:number){return y+x;}</php> or whatever the php syntax is.
22:04:25
vms14
It seems much better way than how I'm doing, but I have to think now, I have no idea about where to start
22:05:37
pjb
You could start from the php grammar, if you want to implement a complete syntax. (This can be useful if you want to be able to parse php back to sexps).
22:06:25
pjb
Or you can just choose a sane subset. For example, for C or C++, it would be crazy to use the actual language grammar. Instead, you can define the grammar for a subset language as is used by human programers.
22:07:35
pjb
Similarly, the sexps syntax you will define can be able to express only a subset of the whole syntax (the subset you would use as a human programmer, or you need to generate), it doesn't necessarily have to cover the whole syntax.
22:09:09
pjb
You can also implement a php-parser and generate the sexp from it: php-source -> ast-objects -> sexp.
22:09:28
pjb
So you can parse php, get a sane sexp, edit or transform it automatically, and generate back the php.
22:09:57
vms14
would be nice, but also more complicated to write both, and I don't know if I'll need that
22:38:21
pjb
vms14: it's easy. In the case of lisp sexps, eg. if: (if <test> <then> [<else>]) -> (defclass lisp-if (lisp-expression) ((<test> :initarg :test :reader if-test) (<then> :initarg :then :reader if-then) (<else> :initarg :else :initform nil :reader if-else)))
22:39:06
pjb
vms14: then: (defmacro my-sexpified-language:if (<test> <then> &optional <else>) (make-instance 'lisp-if :test <test> :then <then> :else <else>))
22:40:24
pjb
Having classes has the big advantage that you can write generic functions dispatching on them, to do all kind of stuff on the programs thus represented. You can generate them in different languages, compile them to lisp or native code, pretty print them, transform them, etc.
22:41:03
White_Flame
I find it often yields smaller, more manageable code to do the same thing with plain data structures and manual functions
22:43:01
White_Flame
but yeah, it's still a tool in the toolbox. Just don't go all Java "OO = Object Obsessed" ;)
22:44:46
vms14
I don't see many advantadges using CLOS instead of just functions transpiling directly to what I want
22:45:53
pjb
vms14: the advantage is instead of having a procedural style, you can have a data driven style, where you have an internal representation of the program you want to generate. So you can manipulate it.
22:49:10
pjb
Instead of hardcoding stuff such as: (php-if (php-equal (php-var "a") (php-integer 0)) (php-function-call (php-function "foo") (php-var "b") (php-integer 42))), you can have some data |# (let ((php-code '(if (= a 0) (foo b 42)))) #| and process it: |# (generate (parse-php-sexp php-code)))
22:50:47
vms14
I had this (defun php-if (test &rest statements) (format nil "if(~a){~{~a~}}" test statements))
22:52:37
vms14
I'll think about writing an AST, because I'd like to learn more about compilers and metaprogramming
22:53:09
pjb
(case (first sexp) ((if) (format …)) ((= /= + - * / …) (format …)) (else #|mustbe funcall|# (format …)))
22:54:47
pjb
Or, you could (defgeneric (op &rest args) (:method ((op (eql if)) &optional then else) …) …)
22:58:11
vms14
the heredocs are because I wanted "" for the html and variable interpolation, but they make the code even uglier
23:22:55
HiRE
could someone provide me a few links of github repos or whatever with really well written modern CL code?
23:23:57
mason
HiRE: There are books worth reading. Here, for example: http://www.gigamonkeys.com/book/
23:24:40
HiRE
thanks Xach. Reason I ask is I'd like to take on a project to write a simple DNS server in CL for my own use.
23:28:01
HiRE
Xach, I'd love to take a look. One thing I was beginning to look at was even how to get started reading/writing packets in CL
23:28:37
pjb
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjU-KCOn4TnAhWRERQKHcS8Ad0QFjAAegQIAxAB&url=https%3A%2F%2Fgithub.com%2Ffjames86%2Fdragons&usg=AOvVaw15yBgmePwcAl1LunaxgUGy
23:28:38
pjb
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=2ahUKEwjU-KCOn4TnAhWRERQKHcS8Ad0QFjABegQIBxAB&url=https%3A%2F%2Fgithub.com%2Fhanshuebner%2Fans&usg=AOvVaw3Foqv4BPm4Ihcr1iFJB68t
23:28:50
HiRE
mason, that was my initial idea but I'd like to keep it pure CL if possible. I really like CL and FFI seems like a last ditch effort for me.
23:30:12
Xach
*.asd files are input to a program that can compile and load multiple files in the right order