
Does https://docs.racket-lang.org/reference/file-ports.html#%28def._%28%28quote._~23~25kernel%29._port-try-file-lock~3f%29%29\|port-try-lock-file? work across processes, or is it intended to be used within the same Racket VM?

I assume it works across processes since it’s based on OS tools apparently, but I just want to make sure

Answering to myself: Yes, it’s cross process. This can be seen with lslocks
on Unix at least, with this: #lang racket
;; Only works with Unix
(define filename (make-temporary-file "racket_alock~a"))
(call-with-file-lock/timeout
#f 'exclusive
(lambda ()
(call-with-file-lock/timeout filename 'shared
(lambda () (printf "Shouldn't get here\n"))
(lambda () (printf "Failed to obtain lock for file\n")))
(define-values (in out) (make-pipe))
(parameterize ([current-output-port out])
(system "lslocks"))
(close-output-port out)
(for ([line (in-lines in)])
(when (string-contains? line "racket_alock")
(displayln "Found lock:")
(displayln line)))
(displayln 'done))
(lambda () (printf "Shouldn't get here either\n"))
#:lock-file (make-lock-file-name filename))

I have a dump question: why isn’t there a list-insert
in (racket/list)
?

Good question. It’s missing from srfi/1 too. Most likely because it is an O(n) operation - and making it available will tempt people to use it :wink:

As are most list operations in racket/list :wink:

This one even uses space O(n).

true

This leads to: Why is there no standard double linked lists?

Thank the IBM 704, I guess :wink:


I wonder what he is looking for.

He’s working up the courage to ask her to lunch.

a bug, obviously!

He’s looking for a moth. Was told to debug his program and …

Do you mean something like (list-insert '(1 2 3 4 5) 2 '(a b c))
-> '(1 2 a b c 3 4 5)
?

So does list-update :cry:

’(1 2 (a b c) 3 4 5)

Maybe not the fastest implementation, but not too bad IMHO: (define (list-insert old-list position new-list)
(define-values (head tail)
(split-at old-list position))
(append head (list new-list) tail))
Leave out the the list
application in the last line to get the behavior I thought of first.

Thanks. I was just curious why there isn’t one. Implementing it is less of a problem. Also @notjack ’s rebellion has one.