freenode/#lisp - IRC Chatlog
Search
15:32:15
Demosthenex
_death: so i found the mailbox lib, which defines a simple object for locked inter-thread communication
15:38:12
dim
Shinmera: re (coerce "/" 'character), see https://github.com/dimitri/pgloader/issues/835#issuecomment-421627350 where I've been using (aref ... 0) instead, because I'm not exposing reader macrology in pglaoder's command language
16:03:24
beach
I mean, if, while running your application, you run out of space in one generation and the GC is disabled, then the system will fail. And if you don't run out of space, then the GC won't run.
16:24:18
AeroNotix
hmm, well there goes that theory. I was trying to see why two threads operating on two different hardware memory transactions were occasionally failing
16:32:37
AeroNotix
shka_: Well, it's more a case of how RTM behaves on the cpu, rather than anything intrinsic to SBCL it seems
16:36:35
Demosthenex
if i create a thread in a let inside a function, when i leave the let scope is the thread killed?
16:51:41
Demosthenex
_death: https://bpaste.net/show/5db6bd9c1964 i've been able to get async input working with other screen updates going
16:52:09
Demosthenex
i'm deliberately moving it, and also trying to protect and restore the position
16:55:09
Demosthenex
AeroNotix: that's a good thought, but it spends 99% of its time sleeping, and its a POC by a noob ;]
16:56:11
AeroNotix
Demosthenex: I prefer using a different method of thread synchronization: channels
16:57:01
pjb
Demosthenex: you could use a global special variable, but there's no guarantee that they're writable atomically.
16:57:44
Demosthenex
pjb: if i make a var, it's just to be checked before the next loop (ie: (loop until *quit* do ....)
16:58:28
AeroNotix
I mention thread-safe just so it's clear that it should be thread safe, setting a variable *should* be fine, without explicit locking but ymmv. I'm not clear on whether setf is atomic.
17:02:39
Demosthenex
https://bpaste.net/show/668b79f059a3 added your global, and now cursor preserves
17:14:37
whartung
even if the global write is atomic, doesn’t mean the other threads will see the change due to caching on the cores.
17:25:49
jackdaniel
looking at the article https://spcl.inf.ethz.ch/Publications/.pdf/atomic-bench.pdf I see 30x penalty
17:26:32
jackdaniel
I don't have opinion what is a good solution because I didn't read the whole backlog
17:28:05
pjb
That said, it's true that you can often merge locks, but it would increase parallelism to keep one lock per data, if they're independent.
17:29:18
AeroNotix
not entirely an expert but you can try to use transactional memory with more coarse grained locks and let the cpu figure out chances for data parallelism
17:29:32
pjb
Demosthenex: for example, you are trying to access a unique resource, the screen. Instead of accessing it from multiple threads, have a single thread own it and access it, and multiple threads communicating with this screen management thread. This can be more efficient, since the screen management thread can then serialize and optimize the requests, and those requests can be built in parallel my the other threads.
17:30:22
AeroNotix
There's a few reasonably decent actor libraries that abstract this kind of interface
17:33:02
AeroNotix
well I've used LFE and Erlang extensively, I dunno, I feel like I understand them both well enough to say whether they bring anything useful to the table
17:36:51
AeroNotix
Just that erlang is "dayjob" stuff and if I have free time I'd prefer to spend it with CL
17:38:22
AeroNotix
I don't think this behaviour is only visible with stmx, it may be just a quirk of how rtm works. I've got a single threaded loop that continually sets a variable to a random value.
17:38:37
AeroNotix
Despite nothing else (in my code, at least) accessing that variable, sometimes the transaction rolls back.
17:39:06
AeroNotix
I, at first, thought it could be the gc interfering with the variable, tried using sb-sys:without-gcing but it didn't change the behaviour
17:40:00
whartung
also, to highlight pjb’s idea of a single controlling thread, the screen is a spectacularly low bandwidth device. Far cheaper to stuff something on a queue and have the controlling thread update, than to have everyone try it and wait for the screen to update.
17:40:31
whartung
if the controlling thread is using something like curses, it can batch all of the updates in to one hit to the display, something competenig threads potentially can not do
17:43:07
AeroNotix
https://gist.github.com/AeroNotix/fd0d7c4d62ac35ff2095d7bfcd6ab8de here's the code. set-it is a macro cause I've extracted this from a test suite where set-it being a macro makes sense.
17:47:10
pjb
To complement what whartung is saying, you should have a look at how emacs on the terminal does it! You'd be surprised.
17:48:54
AeroNotix
Not to mention that it'll subjectively make the code far easier to reason about and understand
17:49:20
AeroNotix
instead of minute instances of locking/unlocking. You would have send-to-screen type operations that don't care how the screen handles that operation
17:49:48
whartung
you still have locking and unlocking, but theyre ideally faster since you’re only fighting over a queue, vs a slow display.
17:50:08
AeroNotix
whartung: indeed, but the individual instances of locking can be abstracted into the "screen" API
18:03:46
Demosthenex
pjb: so the casier demo is just like the mailboxes i'm using, and really i don't need anything deep, i just wanted async input while taking forms data so i can have popup combo boxes display autocompletion options without stopping
18:21:13
pjb
Demosthenex: I don't know. I've got my own mailbox synchronization abstration here: https://framagit.org/patchwork/mclgui/blob/master/mailbox.lisp but it locks the recipient until the sender posts a message.
18:22:04
pjb
So right, this is also the point I wanted to mention: usually, threads will be waiting on a queue or a mailbox like this, to receive a message and process it. So it's natural and easy to define a quit message to have the thread stop.
18:27:26
AeroNotix
btw in the area of self-hosted git sites, check out gitea and gogs. Far superior to gitlab (IMHO!!)
19:40:57
jasom
jackdaniel: Most lisp-in-X are rubbish, mainly because it's relaly easy to make a bad one, but very hard to make a good one.
19:45:35
aeth
I'm having a hard enough time writing Scheme-in-Common-Lisp and Scheme's the closest Lisp to CL that's not Emacs Lisp or essentially obsolete. The hard part is getting the exact semantic match while preserving performance. Pseudoscheme never tried to do this, hence the "pseudo".
19:46:03
jasom
jackdaniel: which part is bold? I think it's relatively intuitive that the larger the distance between the difficulty of doing something poorly and the difficulty of doing something well, the more times something will be done poorly. I know it's easy to do one badly because I have done so.
19:46:24
aeth
I can't imagine doing a Lisp-in-Foo that is not just Foo with s-expressions because the semantic mismatch would be even greater than Scheme-on-CL
19:47:31
plathrop
welll... every language has to be written in another language. So it has to be possible to write good Lisp-in-Foo for *some* values of Foo
19:48:31
plathrop
I'm just being overly pedantic about "doing a Lisp-in-Foo" == "Foo with s-expressions"
19:48:37
jackdaniel
bold, that /most/ are /rubbish/. first suggests you have compared at least a few, second that they are worthless (given some objective(?) metric)
19:49:03
aeth
jackdaniel: It's actually the least bold claim that most $thing_on_the_internet are rubbish
19:50:25
aeth
The problem with bad software is it doesn't (usually) have a test suite to express how bad it is.
19:51:07
jackdaniel
aeth: informal verification fails short: take randomly person from this channel they'll say: python is rubbish; take randomly person from python channel they'll say: lisp is dead ;)
19:51:50
aeth
jackdaniel: People actually can use Python for serious projects, so it's not rubbish in the context here. I would guess that there are thousands and thousands of hobby Lisps and "Lisps" out there and maybe 20-30 are usable.
19:52:57
aeth
The problem is, you'd need to try to write a project in $foo to find out that it's not a usable language implementation sometimes.
19:53:32
aeth
It's very easy to make a Lisp, so I don't think it's controversial that there are many.
19:57:44
jasom
actually we can be fairly certain it's a function, since deftest (in this case) expands to a defun and test-+ is defined with deftest as well
20:13:13
pfdietz
Is there a portable implementation of the Common Lisp reader (in Common Lisp) anywhere? That is, I want to be able to modify it so I don't want to use any CL's builtin reader.
20:16:03
pfdietz
Want I want this for is this: I want to be able to trawl lisp sources for code fragments to use in testing, but I don't want to actually have to load the code, so packages may not be defined. So I want a reader that can skip over package names it doesn't know without completely aborting.
20:20:48
jasom
http://metamodular.com/incremental-parsing.pdf <-- there's the paper I was thinking of, not sure if there is currently useful code
20:24:16
jasom
And here's the code for parsing lisp that that paper is intending to do better than: https://github.com/robert-strandh/Climacs/tree/master/Syntax/Lisp
22:18:52
kenu
I am trying to query db with postmodern's doquery, but it doesnt preserve upper cases in column names
22:22:07
aeth
If it's using symbols it has to assume that the user is probably going to say foo, which gets translated into FOO, and want it to represent "foo". |foo| would be how to get case-sensitivity, but if it assumes upcasing and then downcases it that wouldn't help
22:34:17
jasom
And you definitely can set postmodern:*downcase-symbols* to nil and use '|ColumnName|
22:40:46
jasom
though since most of the forms get expanded a macroexpand time you'll have to be smart about how you set that.
22:53:21
jasom
ah "All identifiers (including column names) that are not double-quoted are folded to lower case in PostgreSQL."
22:56:33
kenu
and I get literally "users.usersId" printed for every row in db instead of the actual value
22:57:52
jasom
though I object to their :auto implementation for escaping; it ought to escape any names with upper case characters for just this reason...
23:03:26
jasom
they ought to provide a case-inverting version IMO, that would allow you to do 'users '|users.userId| or 'users.user\Id
23:03:57
jasom
they ought to provide a case-inverting version IMO, that would allow you to do 'users '|USERS.USERiD| or 'users.user\id
23:06:24
jasom
kenu: it does look like the better solution is to just change your schema to be users.user_id
23:09:36
aeth
The greatest evil in programming language syntax is forbidding foo-bar-baz just so someone can write "x-y" instead of "x - y", which makes everything slightly harder to read.
23:10:45
aeth
and camelCase is only fine for short names with no acronyms, making it ironically the worst decision for something like Java
23:11:10
whartung
I use short names in other language becaueCamelCaseIsAPainToType compared-to-variables-with-dashes-which-is-easy
23:13:04
kenu
@jasom there is already some js code queryng that db and I don't feel like changing it
23:14:20
jasom
aeth: also ironic is that standard python style already recommends spaces around binops, so if you follow the style, then x-y could be unambiguously an identifier
23:15:10
whartung
all the chording and shifting is why I’m not a fan of emacs — just hard on my wrists, and I’m not really interested in remapping everything to make it easier.
23:15:34
jasom
whartung: fortunately someone already did all the remapping, and they called it "evil-mode"
23:15:37
oni-on-ion
whartung: try to type slower, or perhaps remap caps lock to control; that is what i have done. but i still dont really like it honestly.
23:15:52
aeth
jasom: Two things are imo a necessary part of style. Spaces around those operators and parentheses when mixing multiple operators so the reader and writer of the file don't need to have the precedence rules memorized. i.e. x + (c * y)
23:16:10
aeth
jasom: and if you consistently always use that style then (+ x (* c y)) isn't *that* different.
23:16:41
oni-on-ion
whartung: hmm try switch up hands? ie. right shift or right alt, i dont use them as often as i should but i started to more and more.
23:17:22
jasom
whartung: I've tried several vim layers for emacs over the years and evil is the only one that didn't cause my muscle memory to get annoyed every few minutes.
23:18:08
oni-on-ion
whartung: hehe. mine is missing at the moment but i still poke into the little rubber thing +)
23:18:40
oni-on-ion
i was next thinking of moving the spacebar elsewhere. like maybe if TopLeft of keyboard was backspace, and TopRight was space....
23:19:12
whartung
yea. on my mac, the CMD key is the “thumb” key, but taht’s not mapped to meta in Aquaemacs (which is a macification of emacs) that I use.
23:20:26
whartung
though in some places shift-backspace is not backspace, and then I rage and bonk things...
23:22:39
whartung
I try not to go for massive customizations of, well, anything, because it’s One More Thing I have to manage and take care of and port across versions, and workstations, and then get all sort of muscle memory that doesn’t work on the kiosk at the hotel.
23:24:00
whartung
(it’s amazing how close emacs is to a canon cat and the “Humane Interface” and yet, how far away it is at the same time.
0:02:00
jasom
https://gitlab.com/at-home-modifier/at-home-modifier-evdev/wikis/home <-- there's what I was thinking of. It's a linux driver that implements what is needed for doing it; any key can be different when chorded vs not chorded.
0:03:47
jasom
I use my thumb for alt and my middle finger for control when I need to use emacs keys that I haven't remapped yet (e.g. C-c C-k) by moving my whole hand; it's a smaller movement than going to my trackball so shouldn't be too bad.
0:20:00
no-defun-allowed
`(ql:quickload :bordeaux-threads)` `(bt:make-thread (lambda () (loop ...))`
0:20:46
no-defun-allowed
(defmacro make-thunk (&body body) `(bt:make-thread (lambda () ,@body))) is also useful