freenode/#lisp - IRC Chatlog
Search
10:21:18
elderK
no-defun-allowed: The many-lines-of-code thing is for me, because I don't run IRC in Emacs.
10:21:45
elderK
Because I had to make an Emacs port, which requires libraries that refuse to cooperate.
10:22:50
elderK
One problem is that libjpeg-turbo is built using CMake, which of course, doesn't install .la files. Where as libgd is built with autotools, and expects .la for llibjpeg. Which doesn't exist. So it dies.
10:23:31
elderK
Another alternative is to replace the distribution's libgd with my own version, that uses cmake instead of autotools. But then I'm concerned what other packages it will break.
10:23:59
elderK
It's a real cluster@!#$. Especially since some projects have /two/ build systems. And they don't install the same stuff.
10:26:07
elderK
It's like, why not standardize completely around pkg-config? That could help but CMake doesn't want to. And pkg-config is useless on Windows, for the most part.
10:28:21
elderK
makomo: How do you find this answer? https://stackoverflow.com/questions/18008099/chls-innermost-backquoted-form-should-be-expanded-first-meaning
10:29:03
elderK
My urxvt setup is pretty stock - that may be why things like URIs and stuff aren't properly highlighted. At least, not across multiple terminal lines.
10:29:23
makomo
elderK: that's one of the backquote-related SO Q&As i have bookmarked :-), but only for "archiving" purposes (i.e. i didn't want to link it because i forgot what explanation was offered there)
10:29:52
makomo
elderK: i use the mouse to select the lines, copy and paste them into emacs and then trim the username/timestamp prefixes
10:34:32
makomo
elderK: that answer is okay i think, but you have to follow the poster's terminology
10:35:02
makomo
"... and that for a doubly nested backquote form, I should reinterpret the innermost backquote forms before reinterpreting the outermost backquote form."
10:41:44
makomo
see how the backquote syntax is expanded into some implementation-defined form? that's what "expansion" is referring to
10:44:05
elderK
Right, so thinking the Schemey way: ````,,,,c1 == (quasiquote (quasiquote (quasiquote (quasiquote (unquote (unquote (unquote (unquote c1)))))))) no?
10:44:11
makomo
(let ((*print-pretty nil)) <form>) won't work at the REPL as the printing of the result happens *after* <form> is evaluated (i.e. outside the LET block, somewhere within SLIME/SWANK)
10:49:05
makomo
it might seem strange, but it makes sense when you think of it as "ladders" (i've heard the term "ladder algorithm" used somewhere)
10:51:45
pjb
elderK: why don't you just read the rules in clhs? They're very clear on how to interpret backquote…
10:52:43
makomo
elderK: using the SO terminology from that answers, CLHS uses an "equivalency description" -- it describes a possible set of forms that backquote might expand into and derives the evaluation semantics from that
10:53:02
makomo
that's all fine, but it's useful to know the "replacement description" as well -- an intuitive way to think about "canceling" the various backquote/comma pairs
10:53:53
makomo
the "replacement description" is simple for simple cases, but needs to be made more complicated (or special cased somewhere) for cases like ,@,@ or ,,@, etc.
10:56:55
jackdaniel
elderK: I think that this topic requires silent contemplation with a single source of information (in this case clhs) instead of multiple ones
10:57:30
jackdaniel
it is easy to get confused, ie some people put their "intuitive" interpretation into play which may be incorrect (or may not match your mental model)
10:57:30
elderK
jackdaniel: I would ordinarily agree. But there were parts in the CLHS spec I was not sure how to... apply. Seeing that post on SO, clarifies that.
10:57:41
elderK
My goal now is to get a few nested macros, and expand them, according to CLHs rules.
10:59:44
makomo
jackdaniel: "silent contemplation" is the part i agree with, but i think you really do need multiple source of information (either to see where they went wrong, or to clarify some points)
11:00:42
jackdaniel
I think that you confuse him instead of helping (and I judge it by the fact, that I was away for more than an hour and you still talk about the same thing)
11:01:46
jackdaniel
I'm known for being unfair, sometimes it happens though that being unfair doesn't mean "wrong"
11:02:11
elderK
Maybe this really is something that's simple. Just, it's not clicking for me atm. But, I am definitely closer now.
11:02:12
jackdaniel
also being satisfied with help and getting grasp of something are two different things as well
11:05:11
jackdaniel
http://ep.yimg.com/ty/cdn/paulgraham/onlisp.pdf here you have nice explanation in english about backquote
11:10:30
makomo
elderK: 5 examples in total, don't get scared :-) http://plaster.tymoon.eu/view/1008#1008
11:11:36
jackdaniel
so called ,@,@ "idiom" is incorrect in light of clhs (it relies on some intuition shared by some)
11:12:08
jackdaniel
no you didn't, one of key arguments is that it is "natural extrapolation" from the spec
11:12:21
jackdaniel
and I was not interested in discussing it, just given you resources you may follow
11:12:26
makomo
jackdaniel: it's not an extrapolation, it's ridigly and mechanicaly following the rules
11:13:56
makomo
jackdaniel: when you get the time, take a look at the expansion i did by hand and tell me what step is wrong
11:14:37
makomo
right, but you're not providing any proof that it is undefined/incorrect as per the CLHS rules
11:14:56
jackdaniel
I have more interesting thigns to do than proving you wrong. I did point you to the references which discuss it
11:15:33
makomo
but none of the commenters there use the formal rules to prove that ,@,@ is undefined, which is why i did it by myself
11:15:34
jackdaniel
if this is not enough for you, then please consider practical argument for not spreading this incorrect information: it doesn't work on all CL implementations
11:16:03
makomo
jackdaniel: that's an implementation's problem, is it not? pjb actually reported to CCL that ,@,@ doesn't work
11:16:30
jackdaniel
no, this is a community problem that you spread a dubious syntax and you label it "idiomatic"
11:19:03
jackdaniel
makomo: let's make a wager: I prove you wrong, you solve one ECL issue I point you to, I'm not able to, I'll solve another CL foss issue you point me to
11:19:14
makomo
jackdaniel: just saying that it's incorrect and leaving isn't helpful... we should sit down and discuss it once and for all some time :-)
11:22:08
makomo
but a necessary condition for the proof is that it has to be done using the formal rules provided by the CLHS, ok?
11:43:58
elderK
makomo: You treat `'something like ''something. I.e The 'something as a "basic object." Would I be incorrect to expand that further into, `(quote something) ?
11:44:53
makomo
elderK: that would be correct and was something i tried once, but found it too verbose
11:47:00
void_pointer
elderK: reader macros are expanded when the file is read into lisp, before being evaluated, compiled, or really anything else for that matter
11:47:39
pjb
elderK: cf chapter 2. The lisp reader reads the character #\` then it looks it up in the *readtable* and find a reader macro for it. It calls the reader macro.
11:48:10
pjb
elderK: the reader-macro for ` will read the following expressions, parsing the , and ,@ and substiting the whole by a lisp form to build the equivalent list.
11:48:33
pjb
(let ((bar 42)) '`(foo ,bar)) #| --> (list* 'foo (list bar)) |# <-- This is what is read.
11:49:06
pjb
(let ((bar 42)) (read-from-string "`(foo ,bar)")) #| --> (list* 'foo (list bar)) ; 11 |#
11:49:18
jackdaniel
makomo: it mostly is, first we have to point out issues (to avoid situation, where the winner side picks an unreasonable issue)
11:50:20
makomo
jackdaniel: well, it's not like either of us is *required* to do what the other says, so it's mostly a matter of pride/honor
11:50:57
makomo
i was going to trust you to pick out something normal (it's not like i ever worked on either ECL or McCLIM, so it would be a wild ride anyway)
11:51:22
jackdaniel
so please send me your proof that ,@,@ is correct (expansion you have mentioned which follows rules) and the issue you have picked when you have it
11:54:26
jackdaniel
you need to verify, if structure layout is the same and provide two restarts if it isn't
11:55:06
jackdaniel
most effort on your side would be navigating through ecl source code which codebase you are not familiar with
11:55:56
makomo
jackdaniel: ok, my issue is (half-jokingly) https://web.archive.org/web/20130622010232/http://sourceforge.net/p/ecls/bugs/251/ :-)
11:56:51
jackdaniel
OK, but I don't promise that I'll solve it before next release, it will be pretty involving change of the reader which is written in most part in C
11:57:33
jackdaniel
I'll let you know when I get to the doulbe splice (I first need to finish current PR on McCLIM)
11:58:55
makomo
just the individual steps, i haven't documented which particular rule was used, but the steps are small enough so it should be easy to see
12:18:42
elderK
makomo: How long did it take you before you could follow this process in your head at lightspeed?
12:19:05
elderK
I've been doing the expansions by hand, on my own, then comparing against your notes.
12:22:53
makomo
Steele mentions it in cltl2 as well (and he has a very nice discussion of backquote there -- that's another resource i would suggest)
12:50:31
makomo
nevermind, steps (4) and (5) in the expansion of ,@,@ do differ, but the difference is a single backquote replaced with a quote
17:30:02
jcowan
s there any trick to load a system such that the current package is changed after the system is loaded? This would be useful when implementing a different language in CL.
17:30:57
jcowan
For example, suppose I write an implementation of Elisp in CL. I define two packages, ELISP (which inherits from CL as usual) and ELISP-USER (which inherits only from ELISP). Then I want to load this and have the user wind up in ELISP-USER, but I don't see any way to do that.
17:37:07
jcowan
Well, if the user has to type that at the REPL, it's rather verbose. And if you put it in a file for convenience, it doesn't work. Indeed, at the REPL you might just as well write the two forms separately without progn.
17:43:11
jcowan
In what package does the elisp symbol live? Presumably CL-USER. Is that acceptable practice?
17:44:06
jcowan
So again the user has to type two forms: a load and (elisp). This is some improvement on find-package or in-package, but not optimal.
17:49:40
jcowan
or if not put in CL-USER, the user must type (load ...) and (elisp:elisp). Uglier yet.
18:15:29
pjb
jcowan: note that even if you put elisp in cl-user, the user may change the current package before wanting to call elisp, so he cannot type (elisp) willy nilly.
18:15:55
pjb
jcowan: some repl let you define commands that are accessible whatever the current package. You could define such repl command to start elisp.
18:25:06
jcowan
So if use-package (or its defpackage equivalent) is discouraged because name pollution, which is recommended, importing or qualified symbols?
18:27:24
pjb
And neither is use-package really. See for example: https://github.com/informatimago/rc/blob/master/common.lisp#L437
18:28:51
pjb
But indeed, there may be some name collision, hence the carefully currated package list https://github.com/informatimago/rc/blob/master/common.lisp#L302
18:30:01
pjb
jcowan: the point is that the owner of the package gets to decide on the used packages.
18:37:38
jcowan
Yes, however, you take the risk of breaking your code if the used package is updated.
18:39:03
jcowan
If/when I implement ISLisp I am going to add defpackage, in-package, and single-colon qualified symbols to the language definition. The ISLisp notes say that there was an intent to add modularity, but they ran out of time.
18:42:48
pjb
jcowan: even if you don't use the package, if there's an update, there's potential bitrot.
18:42:50
jcowan
There is going to be a fair amount of shadowing of CL required because of slightly different semantics: e.g. internal-time-units-per-second is a function, and you can't define it as such without shadowing it
18:45:37
fiddlerwoaroof
Yeah, I don't know that there's a consensus about avoiding :USE, but I generally prefer to qualify my symbols so I know where they come from
18:46:08
fiddlerwoaroof
This is a bit painful in CL because there's no standard way to locally rename a package.
18:46:26
jcowan
People make a big deal about distinguishing "bug fixes" from "breaking changes", but every bug fix *is* a breaking change if your users have already worked around your bugs.
18:47:11
fiddlerwoaroof
some libraries provide something like that: https://github.com/3b/package-local-nicknames
18:47:35
fiddlerwoaroof
Having an extensible reader is something I miss when I write Clojure or Elisp
18:50:06
fiddlerwoaroof
I remember one that used a reader macro to resolve the nicknames in a conforming manner
18:51:12
jcowan
The file https://github.com/3b/package-local-nicknames/blob/master/package-local-nicknames.lisp puzzles me: if loaded, it does nothing, because it consists of a single in-package form. What's it meant for?
18:56:37
fiddlerwoaroof
And then there are things that use ASDF to manipulate the environment a system's source files are loaded in: http://quickdocs.org/package-renaming/
19:01:07
void_pointer
I am trying to make a window, do some stuff on the main thread, and then close it without user input (if anyone is curious, this program is querying the rendering capabilities and doing some tests before closing).
19:01:54
void_pointer
But I am not sure how to get something running on the main thread after I create it.
19:09:02
pjb
void_pointer: you cannot do it with bordeaux-threads, but there are implementation specific ways to run stuff on the main thread.
19:09:32
pjb
void_pointer: you can also portably implement your own loop running on the main thread, waiting for messages from the other threads to be evaluated.
19:11:02
void_pointer
pjb: I would like to avoid implementation specific stuff if I can help it but if it is the only choice then that is the way it is
19:13:57
fiddlerwoaroof
Anyways, for the specific purpose of running something in the main thread, this works well: https://github.com/Shinmera/trivial-main-thread
20:15:46
jmercouris
this isn't exactly a Lisp question, but a question about how you would use a library
20:16:04
jmercouris
so let's say you are using drakma to get the body of a page, what process, would you use to strip any ads from the page?
20:16:30
jmercouris
I guess it isn't as simple as just removing JS blocks on the page, as those can be dynamically inserted
20:17:20
jmercouris
I am thinking somehow you would need to be able to capture all network requests and determine if they are from a domain that serves Ads or not using a list, and then deny requests to load assets from domains on that lis
20:36:41
jmercouris
pjb: Well, it is a web-page so the content type would be something like text/html, right, but drakma will just load the body, you would need to traverse the resources to determine whether to load those
20:37:03
jmercouris
I'm debating whether I want to do the adblocking on common lisp still, or just use the built in webkit content blocking API (which will probably be way way faster)
20:40:18
pjb
jmercouris: so once you know it's html, you can read the standard about the html format, and parse it and find the ads in there.
20:40:38
pjb
there are also html and xml parsers, but I'm not sure how complete and uptodate they are.
20:41:18
jmercouris
pjb: most ads these days are served via ajax queries, so it's not as simple as just removing the offending html
20:41:55
jmercouris
sometimes there are place holder divs or something, that get populated with ads, maybe if you remove the placeholder div, then the ad won't even load
20:42:26
jmercouris
maybe it would be best to implement an AI, train a model and distribute that model
20:54:07
pjb
jmercouris: well, if you want future proof, shot all the guys on the w3c. They keep issuing new standards! You will have to catch up.
20:57:25
anamorphic
Hi, I defined a define-setf-expander here https://paste.ofcode.org/ygctgJ6i8KCnDFHgJiuhvG Basically my first attempt at an exapander. Does it seem correct? Checked it for things like double evals. Not sure how else I could have messed up though...
21:08:50
jmercouris
so I can use something like (cl-string-match:match-re ".*a.*b" to do a fuzzy search for anything with a and b in a row, but how could I make that case insensitive?
21:20:44
aeth
in regex it's just (afaik) [Aa] or [Bb] anyway and is only hard when you want to extend it past that
21:21:20
jmercouris
aeth: yes, but would not be quicker to transform my strings to all lowercase instead off branching on every single check?
21:24:51
jmercouris
then again, using match-re is way more expressive than having a remove-if predicate that has a cl-ppcre regex wrapped within a lambda
21:25:39
jmercouris
you know, I'm not carving things into a stone tablet here, I think I will go with lowercasing for now
21:26:14
aeth
Usually I just write my own state machines and either parse character-by-character or substrings in a line-as-string, using only things like string=, char=, etc.
21:26:43
jmercouris
aeth: so what, you generate automata for every type of match you wish to do and store these models?
21:27:20
aeth
Well, no, I do it manually because I have to do it often enough to find the pattern for the DSL, and I haven't done it often enough. Just turns 1 line into 30, though.
21:28:19
jmercouris
interesting, I'm not doing the parsing for a DSL, just fuzzy matching user input against a list of candidate
21:29:04
jmercouris
though I could do something like that, I think I'll stick with the single line for now :P
21:34:16
aeth
jmercouris: I think you could do this, though, assuming you split it into lines or have the :start and :end points and it's in a string (not a stream): (find-if (lambda (c) (or (char-equal #\a c) (char-equal #\b c))) "abc")
21:35:21
aeth
(position-if if you want to get the position and then look for whitespace separators to get the word that contains that character)
21:36:38
aeth
(if you want more than one match, that's where it gets tricky because you'd have to repeatedly run position-if with modified starting points)
21:40:08
makomo
aeth: were these emebedded DSLs (within CL)? what did you need string matching for in that case? looking for symbols with special patterns in their names or something?
21:40:42
aeth
makomo: My most recent work in string matching was for parsing https://www.chessprogramming.org/UCI
21:42:46
aeth
makomo: Well, my plan is to eventually handle it in a macro just like anything else (XML, JSON, HTML, etc.)
21:47:20
aeth
makomo: (:isready) wouldn't require string matching. Seeing if the other side sent the response "readyok" would require string matching.
21:49:10
jmercouris
however, if you have 3 letters that you want to fuzzy match in a row, it will not work
21:52:19
makomo
aeth: i didn't pay close attention to the page. now i see that it's a protocol. i guess that's a DSL, but i was thinking in the "source code sense" (the usual sense) of the word
21:52:43
aeth
jmercouris: For a...b...c... you'd have to write three position/position-if tests, with each one informing the :start of the next
21:59:07
jmercouris
I'll stick with the single line solution, performance is not an issue, and people after me will also have to read the code, and I don't necessarly need them to be fluent in my automata design :D
22:01:14
aeth
The state machine DSL for writing the embedded DSL for handling someone else's external, string-based (and hopefully line-based) DSL
22:02:11
jmercouris
I wasn't being very specific, often times things are very clear in my head, its just that when the words come out, I forget that you aren't also in my head :D
22:02:51
jmercouris
so there are things I often think I've said or included, but on second reflection, I realize I omitted, it is on accident though
22:19:24
no-defun-allowed
mine is 10:00:00 since i like in gmt+10 but yes it should be midnight in UTC
22:19:35
aeth
for me: (multiple-value-list (decode-universal-time 0)) => (0 0 19 31 12 1899 6 NIL 5)
22:20:33
aeth
It should basically just be a reversal of ISO-8601's format until the time zone/DST/etc. stuff at the end.