freenode/lisp - IRC Chatlog
Search
10:12:45
Duuqnd
I should probably stop playing around with it because it's making me dislike Unix-likes and Windows more than I already did.
10:19:06
pjb
dieggsy: have a look at: (com.informatimago.tools.manifest:distribution) https://github.com/informatimago/lisp/blob/master/tools/manifest.lisp#L144 ; of course, totally ad-hoc.
10:20:37
Duuqnd
Being able to click on an example and having it run is also pretty neat: https://i.imgur.com/h1pAQI1.png
10:25:47
pjb
nij: I guess PG doesn't fund Common Lisp, because he wasn't billionaires after selling viaweb. So instead he founded Y-combinator VC to fund startups to make him eventually a billionaire. Note that if you can pitch a good startup with y-combinator (and use Common Lisp to implement it), then PG would fund CL, indirectly.
10:27:08
pjb
nij: oh, you meant a standization process? But once your startup will have made it, you will be able to do that yourself, which would be logical, since you will have used CL to build your products!
10:27:49
pjb
PG sold viaweb to yahoo! who hurried to rewrite it in C++… So there's some lost interst in CL there.
10:32:57
Nilby
I think foundational Lisp is thing that's above the normal economy, like other technologies say, e.g. GPS, you can't just throw money to make it happen, and it doesn't produce profit directly, but it's super useful and enables whole classes of other profitable endeavors.
10:35:28
no-defun-allowed
It does not transcend reality. No other programming languages make money on their own, other than creating a net loss for everyone dumb enough to use some.
11:24:51
daphnis
to remove the end of a string, is there something more straightforward than (subseq str 0 (1- (length str))) ?
11:27:38
Nilby
That's pretty strightforward, but if you know it was specific characters you could use trim.
12:22:14
pjb
daphnis: if you took the precaution of storing your string in a vector with a fill-pointer: (decf (fill-pointer str))
12:23:56
pjb
(let ((str (make-array 32 :element-type 'character :fill-pointer t)) (src "Hello World")) (replace str src) (setf (fill-pointer str) (length src)) (print str) (decf (fill-pointer str)) str) #| "Hello World" --> "Hello Worl" |#
12:24:54
pjb
daphnis: now, if your string is a tad long, you may want to avoid copying it: (let ((str "Hello World")) (make-array (1- (length str)) :displaced-to str)) #| --> "Hello Worl" |#
12:25:45
pjb
https://github.com/informatimago/lisp/blob/master/common-lisp/cesarum/utility.lisp#L1778
12:27:01
pjb
daphnis: note, for most strings (length < 24 or 32), subseq will be more efficient, on 64-bit hardware.
12:56:13
beach
AHA! The handle of Fernando Borretti is eudoxia, who apparently was here last around 5 years ago.
13:39:46
pjb
dieggsy: note that: (or) #| --> nil |# So it serves two purposes; 1- protection in case we miss a case; 2- ease of editing the bunch of #+ in a single form.
13:40:17
pjb
dieggsy: with paredit, you can easily manipulate list sexps, so sometimes adding a PROGN, AND or OR can help editing.
13:41:06
dieggsy
i was just talking about how i gave up parens editing frameworks in favor of manual editing because they all felt like they got in my way lol
13:42:10
pjb
Oh, and in the case #+(or unix) it's entirely useless, probably a left over from copy-pasting; but also a hint that we'd like to get a future feature to or unix with for nextstep. note that OpenStep worked on unices (sunos and hp/ux), Mach-OS, and Windows-NT.
13:42:55
dieggsy
pjb: i think part of the fuss is i'm also using evil-mode and none of them quite click with that, you have to use some kind of sub-par adapter package
14:33:59
pyc
While typing code into a .lisp file, is there a way to autocomplete known symbols? For example, form<key-sequence> should autocomplete it to format. Is it available? I tried <tab> but it does not seem to autcomplete. I have SLIME running in Emacs.
14:39:42
beach
pyc: I almost never use the Meta key, so I would have to type C-[ C-i instead, and the [ and the i are on the same hand, so slower to type.
14:41:39
jfb4
ok but you can remap in a line super-meta-control the way of the Lisp machine keyboards
14:42:12
splittist
It is useful if you are using a terminal in a browser that eats lots of M-... chords
14:44:19
pyc
(sort '("foo" "bar" "baz" "qux") 'string-lessp) or (sort '("foo" "bar" "baz" "qux") #'string-lessp)? Does it matter if I use 'string-lessp or #'string-lessp? Is one better style than the other?
14:45:27
pyc
beach: Would you please elaborate the reason behind your recommendation? Trying to understand why one is better than the other.
14:45:46
beach
SORT will then be called with a function object, so no further indirection needs to be resolved, whereas if you call it with a symbol, some kind of lookup is required.
14:47:00
beach
I occasionally use a symbol for the :DISPLAY-FUNCTION pane option in CLIM, so that when the function is redefined, I don't have to re-evaluate my DEFINE-APPLICATION-FRAME form.
14:47:31
edgar-rft
pyc: 'string-lessp doesn't work with FLETs or LABELs, it will *always* use the global function even if a lexical local function exists
14:48:18
beach
pyc: The former. It is a way to take a value in the function namespace and turn it into a value in the variable namespace.
14:52:05
pyc
(sort (directory "*.txt") #'string-lessp) ; This fails with: The value #P"/Users/pyc/learning/a.txt" is not of type (OR (VECTOR CHARACTER) BASE-STRING SYMBOL CHARACTER) when binding SB-IMPL:STRING1. I understand the error. I am passing a list of pathnames to sort but using a predicate meant for string. What is the right way to solve this problem?
14:54:07
pyc
Bike: In my case, I will get the same result whether I sort by entire pathname or only by the filename because all my pathnames would start with #P"/Users/pyc/learning/" I am looking for files in a single directory only.
14:57:54
pyc
(sort (directory "*.txt") #'string-lessp :key #'namestring) ; This worked fine. Really enjoyed learning about this. The CLHS document also describes the sort arguments very nicely. Thank you all for your help.
15:46:00
pjb
pyc: (sort '("foo" "bar" "baz" "qux") 'string-lessp) cannot work, because SORT is destructive, and '("foo" "bar" "baz" "qux") is immutable.
15:46:41
pjb
pyc: try: (sort (copy-list '("foo" "bar" "baz" "qux")) 'string-lessp) #| --> ("bar" "baz" "foo" "qux") |#
15:53:34
pyc
pjb: With SBCL, (sort '("foo" "bar" "baz" "qux") 'string-lessp) returns me ("bar" "baz" "foo" "qux"). Seems to do the right thing.
15:54:06
pyc
pjb: but you are right, CLHS spec says sort is destructive. so is my code undefined behavior?
15:58:48
dieggsy
pyc: it *is* destructive though, it's modifying the actual list. if you store it in a variable, you can see the original list order is changed
16:03:29
pjb
dieggsy: (let ((list '("foo" "bar" "baz" "qux"))) (print (sort list 'string-lessp)) list) #| ("bar" "baz" "foo" "qux") --> ("foo" "qux") |# does it really work?
16:04:43
dieggsy
pjb: it warns "Destructive function SORT called on constant data: ("foo" "bar" "baz" "qux")" but it does work
16:06:31
pjb
http://catb.org/jargon/html/N/nasal-demons.html http://3.bp.blogspot.com/-4f7bw2esn8w/Ut159zC3X4I/AAAAAAAAENQ/bhy3LecsfBQ/s1600/26831_1419257239999_7976058_n.jpg
16:07:10
kiwichap
I was interested in making a website or developing computer equipment and was told that LISP is the best for that
16:07:59
pjb
kiwichap: well, at least one guy earned 8-digits selling a web program written in Common Lisp, so it's possible.
16:08:31
beach
kiwichap: Yeah, well, sort of. For one thing, we haven't written in LISP for decades, so if you use LISP, we think you are using decades-old dialects.
16:08:52
beach
kiwichap: Furthermore, this channel is dedicated to Common Lisp, which is probably fine for what you want.
16:09:25
beach
kiwichap: Then, Common Lisp is the best choice for lots of stuff, you websites would represent no exception. :)
16:11:18
beach
kiwichap: When you use a Common Lisp system, you work more inside the system itself than in the host operating system, so you won't notice much difference.
16:11:23
kiwichap
ok sounds good, I am using FreeBSD, Debian and Open Suse for my websites at the moment
16:14:22
dieggsy
BSDs are excellent for servers. for daily use, much worse hardware support than Linux IME
16:16:04
dieggsy
dunno if i'd call it practical for productive use, but if you have the time, absolutely. contribute them upstream, even
16:16:32
kagevf
loke[m]: thank you - I didn't know about dirname ... yes, that would have done what I wanted ...
16:16:32
pjb
kiwichap: a lot of lisper use macOS to write lisp code on (even if deploying on MS-Windows or Linux).
16:17:49
dieggsy
is there anything that makes macOS better fit for lisp nowadays or is it just... historical vestiges kind o f
16:18:28
jackdaniel
I can't say much about osx, but I'm sure that historical vestiges play a role in some lispers preferring macos over linux
16:19:22
jackdaniel
also osx application market is bigger than linux's (if you want to sell software)
16:20:01
dieggsy
i mean surer, but that's getting at preferring macos over linux in general as opposed to for lisp specifically
16:20:48
pjb
dieggsy: I don't know, but there are some pictures of lisp conference assistance where there's about 90% mac laptops vs 10% PC laptops which probably run 90% Linux and 10% Windows.
16:21:02
jackdaniel
dieggsy: if some person prefers macos over linux and they happen to be a lisper, what do you think they will prefer for lisp?
16:21:16
Josh_2
Is there a library that makes storing data in files easier? Basically I'm thinking something like subclass of one class would store in one directory, subclasses of that in a directory inside of that. Not sure
16:21:50
dieggsy
jackdaniel: my question was, is there a particular reason to prefer macos over linux *for lisp*
16:21:53
jackdaniel
either way this drifts toward offtopic, so as a moderator I feel obligued to moderate you :)
16:22:28
kiwichap
thank you , sorry, I am tempted for a mac for IoS development and was interesting to realize Internet of Service
16:22:46
pjb
dieggsy: the only thing you have on macOS you don't have on Linux, is Clozure CL.app with a nice Hemlock editor, if you don't want to use emacs/slime.
16:23:04
pjb
dieggsy: on Linux you can run a PortableHemlock with a X11 backend, but it's not as nice.
16:23:42
jackdaniel
kiwichap: this channel is known for strict on-topicness rules, discussing other topic unrelated to common lisp is allowed on #lispcafe
16:24:22
pjb
the keyboard is more responsive on Linux\X11 than on macOS (and on Windows it's horrible).
16:24:44
pjb
and you've got more keys and modifiers in X11 than in macOS, which is nice for lisp or emacs.
16:33:10
dieggsy
Josh_2: they kinda suck to work with, but they can be mighty fast compared to other storage methods.
16:33:31
dieggsy
kiwichap: some people here swear by it, others dislike it, i don't have enough info
16:34:44
dieggsy
Josh_2: you're not wrong, but then you get into things like disk space and compression i suppose. TBH i'm no expert on the subject
17:39:50
stylewarning
But I guess it’s such an investment to build an implementation you might as well do fun stuff too
17:43:54
stylewarning
I think that’s possible but there’s also a certain way people write minimal software
17:45:41
_death
I remember lisp500 had an impressive .lisp file along with it.. although with some prettification the .c file was some 2kloc after all?
17:47:07
Josh_2
I read 'The rise of Worse is Better' in The Unix Haters Handbook very recently, interesting stuff and relevant to what you said stylewarning
17:48:19
pyc
http://clhs.lisp.se/Body/f_search.htm says this: "For example, when start-end is true, the ..." but I don't see start-end specified anywhere else on this page. what is start-end referring to here?
17:54:34
stylewarning
Josh_2: I’m not suggesting hyper-minimalism. I’m just saying that I think there’s room for a Common Lisp implementation that is small and straightforward, and especially easy for a reader to understand
18:11:40
jackdaniel
stripping away interrupt handling, threads, sticking to bytecode compiler (without linking sheningans) and bolting first "standard library" then "clos" should bring you 3/4 way there
18:14:40
jackdaniel
one could go a few steps further and: implement non-conforming format and non-conforming loop which cover >98% of use cases
18:19:37
jackdaniel
that would give you an ad hoc, bug-ridden, slow implementation of 100% of common lisp :)
18:23:14
shka_
honestly though, i think that for educational purposes some other lisp implementation makes more sense to study
18:23:19
jackdaniel
smaller modules are easier to maintain ;) but sure, given that we have a standard that would be a regression
18:27:48
dieggsy
lol, i think they meant more abstractly like algorithms and shit. i might disagree wit that too though. I dunno, I love scheme and I love CL. you can learn from either and make great practical use of either
18:28:28
stylewarning
dieggsy: but learning either doesn’t really provide insight into implementation
18:29:17
stylewarning
dieggsy: and currently in Common Lisp it’s hard to answer the question “what if Common Lisp had XYZ?”
18:30:01
stylewarning
For instance I would love to know what a computed goto special operator would be like in Lisp
18:30:20
stylewarning
Unless you’re a genius compiler hacker like Paul K, you can’t just simply add this to something like SBCL
18:31:15
stylewarning
If we had a COMPUTED-GO special operator, then we could hack something like cheap coroutines in Lisp
18:31:59
stylewarning
That would be fun to play with, but necessitates a substrate for easily modifying a CL implementation
18:32:31
raeda_
On that topic, I've been playing with Graal/Truffle lately, which is a compiler toolkit. If there was a Truffle based CL, it would be easy to modify it for experiments
18:33:15
stylewarning
As discussed, a COMPUTED-GO, or even simpler, a jump table, are not something you can implement in CL as a macro without huge caveats
18:37:53
Bike
can't you? if the implementation optimizes CASE (as sbcl does for example) it doesn't seem to me like you'd be doing much worse than direct support
18:38:56
stylewarning
Bike: well if an implementation supports CASE as a jump table then of course we are Golden
18:39:45
Bike
i don't understand how the simple implementation helps here, if you want to worry about performance
18:40:41
stylewarning
Bike: I gave an example of a control structure that is difficult to implement; maybe there are better examples than what I provided
18:40:54
pyc
Pastebin link please for this channel? I forgot it. Someone should add the pastebin link to the topic.
18:41:12
stylewarning
Optimized CASE still doesn’t give computed goto; tags would need be able to appear anywhere in the lexical scope
18:44:40
Bike
for a coroutine wouldn't you have to jump "into" a tagbody, essentially? tagbody only has dynamic extent so you can't do that
18:45:51
Bike
if i wanted to implement coroutines i'd probably start with continuations and go from there
18:46:14
stylewarning
I think the DEFUN would be something like: LET jump-point = LTV(mutable-cell); (TAGBODY (go jump-point) ...)
18:46:52
Bike
well, i mean, so you'd have the tagbody in the coroutine, and when you yield you communicate the jump point back to the caller, right?
18:49:24
Bike
lisp doesn't let you do that. if you want to do that, you'd have to take care of things like storing the stack frame to put it back when you enter
18:49:57
Bike
e.g. if you had some dynamic-extent thing in play at the yield point, you'd need to be able to put that back when you resume
18:51:09
jcowan
stylewarning: CLHS 1.7 http://www.lispworks.com/documentation/HyperSpec/Body/01_g.htm tells you what the requirements are to call your implementation "a subset of CL".
18:51:28
Bike
yeah, and your body is something like (defun coroutine ... (tagbody ...)) and you're doing (return-from coroutine), yeah?
18:51:43
stylewarning
(defun f () (let ((cell ...)) (tagbody (go cell) ... (setf cell 1) (return-from f x) (tag 1) ...)))
18:52:56
Bike
okay, so your cell doesn't just have the jump point, it also has the entire stack frame?
18:53:43
stylewarning
In this case it just has the jump point; which isn’t 100% what’s required for a full “Just Works” coroutine with previously established lexical scope
18:54:39
Bike
are there uses for coroutines with no state besides the control point? i've never really usd them but i assumed the state was a large part of the appeal
18:54:47
stylewarning
But that’s a deficiency in our definition of computed goto, not necessarily in what we are trying to do with coroutines
18:55:31
stylewarning
If you have a computed goto, you’ll have to decide what lexical variables mean if you’re jumping into a lexical context
18:56:27
_death
there are also the "off the beaten path" CL implementations like Corman, Eclipse, Scieneer..
18:56:37
stylewarning
And hence why it would be nice to have a simplistic implementation that removes barriers to trying these things out
18:57:42
Bike
i don't know how much a simple implementation would help with that. like you could do a fairly small interpreter-based one, but then adding this kind of extension would be pretty involved
18:58:09
Bike
and implementing this with an interpreter would be vastly different from doing it with a compiler to the extent it would be hard to transfer what you'd learned
18:58:16
stylewarning
But I would contend it’s likely an order of magnitude less involved than trying to hack it into SBCL
18:58:33
Bike
(source: i wrote up a scheme with delimited continuations once. when i tried to write a compiler problems happened)
18:59:11
stylewarning
Yes interpreter vs compiler vs bytecode vs .... are real implementation issues and written about extensively
18:59:33
Bike
i guess the other thing i'd do is use sicl, which isn't exactly "simple", but it's modular enough to let you swap some stuff out
19:01:08
Bike
i just don't understand what you'd do with the simple prototype exactly. you couldn't use it with production code sicne it's not efficient. you couldn't use it as much of a jumping off point for modding a more efficient lisp.
19:05:01
stylewarning
I implemented this but it would be cooler with green threads https://github.com/stylewarning/lisp-random/blob/master/generators.lisp#L62
19:08:26
theothor`
FWIW, https://dlmf.nist.gov/LaTeXML/ can parse the dpans repos with some tweaks. Returns xml, and can parse directly to html. It struggles with the table macros, but I think workarounds are possible. The xml could be parsed to a clos thing also, I guess?
19:09:10
_death
stylewarning: https://8c6794b6.github.io/posts/Delimited-continuations-with-monadic-functions-in-Common-Lisp.html
19:10:18
stylewarning
_death: it’s cool but to me it’s a toy only in the sense that it doesn’t provide an orthogonal feature
19:10:46
stylewarning
IOW you need to write Lisp differently if you want this kind of feature using that technique
19:11:20
stylewarning
Same issue with CL-CONT-based continuations, where it can’t CPS the standard library like MAPCAR
19:12:47
stylewarning
(This is the CL-CONT version of coroutines: https://github.com/stylewarning/lisp-random/blob/master/coroutine.lisp )
19:13:14
stylewarning
(It appears like it’s a nice orthogonal feature but it doesn’t work in certain circumstances, whereas the thread version does)
19:14:19
_death
yeah, I have some snippets for coroutines using arnesi.. at one time I switched to cl-cont, but decided I liked arnesi better
19:55:51
pjb
stylewarning: you can check it in the sources https://gitlab.common-lisp.net/cmucl/cmucl search for process-yield and idle-loop
21:29:06
opcode
i need some help understanding car and cdr: why does (append (cdr '(1 2 3 4)) (car '(a b c d))) return (2 3 4 . A) and not (2 3 4 A)?
21:42:27
edgar-rft
APPENDing elements at the end of a list is not fast in Lisp, if you must add several elements one after the other it's often faster to PUSH to the reversed list and reverse again if finished. Alternatively you can keep a pointer to the last cell in a variable, but this only makes sense if you have really *many* of those APPEND operations on the same list.