<Decs>
Hey all, this week I wrote a small runtime to support the Actor Model of computation. Pastebin if you're interested: https://pastebin.com/piPY0GVX. First time I've tackled a problem like this, all comments are welcome.
<Decs>
ooops the pastebin link dissapeared
<no-defun-allowed>
It is unusual to represent objects like queues and tickers as closures.
<beach>
Decs: No, it's just the . at the end.
wxie has joined #lisp
<beach>
Decs: CASE doesn't evaluate its keys, so don't quote them.
<beach>
Decs: As it stands, you include QUOTE in the case.
<Decs>
I was reading let over lambda this week too haha
<beach>
Decs: You need to indent your LOOP clauses. SLIME will do this right for you.
<beach>
And, yes, as no-defun-allowed points out, you would typically use a standard class for a queue, not a closure.
<no-defun-allowed>
And then it might be more efficient to use a lock and condition variable per queue.
ldb has joined #lisp
<Decs>
okay thanks beach. There may be something funky with my emacs as I can never get my loops to indent properly
<beach>
Are you using SLIME?
<beach>
Apparently, the contribution slime-indentation is now part of the default setup. But if you have an older version, you may have to include it manually.
<Decs>
Yes, okay I'll look into that.
<Decs>
There is only the one message queue
<beach>
There are an awful lot of c*r calls in there. That's a sign that you need to use standard classes or structs instead of lists.
<no-defun-allowed>
I would also represent each actor as an object that holds its own message queue and closure.
wxie has quit [Remote host closed the connection]
<beach>
At the very least, you should introduce a layer of named abstractions as "aliases" for those c*r calls.
<Decs>
The use of closures are a symptom of having just learnt of them, its my new superpower!
<beach>
I mean, (setf (car timer) (car (cadr timer))) is totally incomprehensible.
<beach>
You need to put some names on those operations.
ldb has quit [Ping timeout: 260 seconds]
<beach>
You seem to have several IFs with only a `then' branch. Use WHEN for those.
<beach>
Then you can remove the PROGN.
<beach>
Or if it is an (IF (NOT ...)) then use UNLESS instead.
<Decs>
I totally agree I need to name some things, so when i come back to this code it's not incomprehensible like you say
<no-defun-allowed>
You could probably get away with using a package like safe-queue for the queue implementation too.
<beach>
So I think that sums it up: Use standard classes. Indent properly. Don't quote your CASE keys. Introduce abstractions. Use WHEN and UNLESS for single-branch conditionals.
<Decs>
Hehe I'm particularly find of the cluster-fudge of cars and cdrs in the ticker closure
ebrasca has joined #lisp
<no-defun-allowed>
That's not anythig to be proud of.
<no-defun-allowed>
..anything?
<Decs>
awesome thanks for your comments beach. much appreciated!
<beach>
Anytime.
<Decs>
*find/fond
<no-defun-allowed>
The trouble with making structures from lists is that you have to infer the shape from wherever that structure is created.
<Decs>
didn't say proud
<no-defun-allowed>
I read "fond, noun: Having a strong liking, inclination, or affection", and you told us all. But to keep this productive, let's say I said fond instead.
kaftejiman has joined #lisp
<no-defun-allowed>
noun→adjective. God dammit, I should focus on just my homework and not #lisp and my homework.
shifty has joined #lisp
pjb has quit [Ping timeout: 272 seconds]
<no-defun-allowed>
But beach summarised what should be done nicely.
<Decs>
Cheers yeah it's been at the back of my mind that the list destructuring (?) is messy. I'll definitely look into making every thing more explicit
ldb has joined #lisp
<beach>
Good luck.
ldb has quit [Ping timeout: 256 seconds]
<Decs>
I had read Carl Hewitt didnt consider actors having their own message queues as fundamental so I decided on a whim that I would take that approach. even though all the implementations Ive seen tack them onto the actors class. Not sure of the pros and cons of either approach.
niceplaces has joined #lisp
<no-defun-allowed>
If you had an implementation where actors had their own threads, and receiving a message blocked the thread, I think it would be a requirement to use separate queues.
niceplace has quit [Ping timeout: 272 seconds]
Jesin has joined #lisp
orivej has quit [Ping timeout: 256 seconds]
<no-defun-allowed>
You use message handlers to represent actors and a scheduler running on one thread, which does not require that. I have not tested this, but I would also expect that using a message queue per actor (and an appropriate means of scheduling) would improve throughput with many worker threads.
pjb has joined #lisp
ech has quit [Ping timeout: 246 seconds]
gravicappa has joined #lisp
ldb has joined #lisp
<Decs>
ahh, yes I tried to make the queue operations as fast as i could to limit blocking between worker threads, but I can see how it may be a problem with more worker threads operating on the queue potentially simultaneously
<no-defun-allowed>
(Oh, and if you're on SBCL, safe-queue will use SB-CONCURRENCY, which is likely faster as it uses compare-and-swap instead of a lock.)
<Decs>
with the multi queue approach threads will only block if trying to write to the same actors queue
<Decs>
as opposed to potentially every time a message is sent
<Decs>
awesome thanks, although I'm using ecl on my phone.
ldb_ has joined #lisp
ldb has quit [Ping timeout: 272 seconds]
marusich has quit [Quit: afk means offline :D]
ldb has joined #lisp
ldb_ has quit [Ping timeout: 272 seconds]
libertyprime has joined #lisp
narimiran has joined #lisp
EvW has quit [Ping timeout: 260 seconds]
Decs has quit [Remote host closed the connection]
ldb has quit [Quit: leaving]
seok has joined #lisp
srazzaque has joined #lisp
<seok>
can you pass multiple values (values a b c ...) to a function which takes same number of arguments?
<no-defun-allowed>
multiple-value-call?
<seok>
no-defun-allowed oh that works! thanks
<seok>
amazing
<seok>
Nice
bhartrihari has left #lisp ["Disconnected: Replaced by new connection"]
bhartrihari has joined #lisp
rgherdt has joined #lisp
GuerrillaMonkey has joined #lisp
libertyprime has quit [Ping timeout: 246 seconds]
shifty has quit [Remote host closed the connection]
shifty has joined #lisp
narimiran has quit [Ping timeout: 258 seconds]
Jeanne-Kamikaze has quit [Ping timeout: 246 seconds]
Jeanne-Kamikaze has joined #lisp
GuerrillaMonkey has quit [Ping timeout: 260 seconds]
bhartrihari has left #lisp ["Disconnected: Replaced by new connection"]
bhartrihari has joined #lisp
libertyprime has joined #lisp
sdumi has quit [Ping timeout: 246 seconds]
bitmapper has quit []
sdumi has joined #lisp
sdumi has quit [Read error: Connection reset by peer]
sdumi has joined #lisp
_whitelogger has joined #lisp
frgo_ has joined #lisp
<seok>
How would I use (min ) on an alist?
<seok>
like this one (("EURUSD" . 1388620800487) ("GBPUSD" . 1388620800709)
<seok>
oops is that too big?
<beach>
What is the result you want?
pve has joined #lisp
frgo has quit [Ping timeout: 272 seconds]
<seok>
i want to know the key of the one that has the smallest number
toorevitimirp has joined #lisp
<beach>
(loop with min-entry = (first alist) with min-value = (cdr min-entry) for entry in (rest alist) when (< (cdr entry) min-value) do (setf min-entry entry) (setf min-value (cdr entry)) finally (return min-entry))
<beach>
Something like that.
<beach>
Alternatively, you can define a comparison predicate and use #'REDUCE.
<MichaelRaskin>
(took me some time to dig up _where_ I read the post)
<p_l>
yeah
<p_l>
the systems that have issues don't have updated root CA cert
<MichaelRaskin>
Or paranoidally check everything provided in the chain even if it is not actually necessary to establish trust
<Xach>
ah, ok. hmm. i don't think my operating systems have updates for certs pending, though.
lnostdal has joined #lisp
<Xach>
thanks for the help, i think it has moved out of the realm of #lisp
sdumi has joined #lisp
sdumi has quit [Read error: Connection reset by peer]
bhartrihari has left #lisp ["Disconnected: Replaced by new connection"]
bhartrihari has joined #lisp
sdumi has joined #lisp
gravicappa has quit [Ping timeout: 258 seconds]
karswell_ has quit [Ping timeout: 246 seconds]
karswell_ has joined #lisp
theseb has joined #lisp
<theseb>
Good practice to always check types of all macro arguments?
<theseb>
I'm imagining lots of hard to find bugs if macros are not always made bulletproof
<phoe>
theseb: kind of; usually the types are either conses or symbols
<phoe>
and for conses, you want stronger checks than just typechecking - you usually want destructuring of some sort
<Bike>
a form can be anything, so there's nothing to check. the rest of the syntax is usually covered by the lambda list
jeosol has quit [Ping timeout: 245 seconds]
<theseb>
e.g. I made a for loop macro that works like this...(for i (list 1 2 3) ....) ......Seems like it may avoid issues to check if 1st for macro arg is a symbol and 2nd macro arg evals to a list
<theseb>
otherwise....bugs may "sneak in" to a massive lisp program
andrei-n has joined #lisp
karswell_ is now known as karswell
<theseb>
Oh one last thing.....is it easy to switch between CL and Clojure....I'm hoping that Clojure becoming fashionable is a good thing for the CL and Lisp community in general
<aeth>
theseb: you can check that the first is a symbol, but you can't check the second at macro time, at best you can insert a CHECK-TYPE in your expansion
<theseb>
aeth: right...it would be in the expansion that list type is checked
<Josh_2>
Afternoon all
lucasb has joined #lisp
<pjb>
theseb: it really depends on the complexity of your function (macros are functions), and whether you use the values immediately, or later or deeper in the code. If you use the value immediately, then a type error will be soon detected and reported, in a way that should be understandable to the programmer.
<pjb>
theseb: on the other hand, if the values are used later or deeper in the code, the relationship between the bad value and the call (or macrocall) can be less obvious. Then it may be helpful to the programmer to check the types and report the error earlier.
<pjb>
theseb: but it's rarely done. One objection is that the programmer checking the types often is too restrictive. Lisp is a generic programming language: you don't write function processing specific types, but functions processing ANY type that it can.
<pjb>
theseb: as for the ease of switching, 1- there's a clojure implementation written in CL, 2- just try to convert 10kLOC of Clojure to CL, and tell us! (better write directly in CL).
lnostdal has quit [Ping timeout: 265 seconds]
<pjb>
theseb: also for the types if you don't check it, then the type restrictions may depend on the implementation of the function. Which can be considered good or bad…
narimiran has joined #lisp
cosimone has quit [Quit: Quit.]
<aeth>
pjb: afaik there are two Clojures in CL, not one
<aeth>
theseb: this is off-topic, but Clojure looks past fashionable, not "becoming fashionable", to me. That's the risk of relying on "fashion" in the first place.
bitmapper has joined #lisp
<aeth>
pjb: You want to check the type early so you can fail early. Sure, a for loop macro would probably fail fairly early (but the message won't be as clear to the user) without a list (but it should be a sequence) as the input, but most things could fail very deep
<aeth>
IME it's fairly common in a large program to get a random NIL pop up when it could've been generated somewhere very far from where it shows.
<pjb>
I prefer that, than artificially restrictive type checks.
<pjb>
That's the curse of C and C++.
<pjb>
it leads to tons of duplicated code and inefficiencies.
lnostdal has joined #lisp
<theseb>
aeth, pjb: i see both sides....dynamic typing is a wonderful thing that leads to cleaner code but may also lead to hard to find bugs.
<theseb>
aeth: are you saying Clojure isn't as popular anymore?
<theseb>
aeth: or are you saying it is way popular and 'beyond just fashionable'
<aeth>
theseb: it appears to have peaked 5-6 years ago in multiple (obviously all unreliable in their own way) measures, e.g. Google Trends.
<pjb>
aeth: it's wrong. the generated binaries are often identical, since most type have the same size.
<theseb>
aeth: i would think ClojureScript will rocket to the moon since apparently anything in the browser becomes super popular
froggey has quit [Remote host closed the connection]
<aeth>
theseb: 5-10 years ago, everyone was trying to compile things to JS (including dozens of Lisps, mostly Schemes, but two CLs)
sdumi has quit [Ping timeout: 256 seconds]
<aeth>
theseb: These days, it seems to have consolidated on TypeScript. Maybe WASM will be another chance for Lisp in the browser.
froggey has joined #lisp
<theseb>
aeth: yes WASM breathes new life into new langs for the browser
<aeth>
Not yet. Afaik, it still doesn't support GC
<aeth>
It's mostly aimed at C/C++/Rust
<aeth>
Those languages don't compete with JS at all, and most importantly, aren't CL
<p_l>
aeth: thanks to V8, you can't even expect C to work right
<aeth>
pjb: Quite a few CL APIs are for a specific type or for the union of a specific type and NIL (i.e. (or null foo) which I use a DEFTYPE to write as (maybe foo)).
<aeth>
Although admittedly a lot of that doesn't need anything more than an IF/WHEN
bhartrihari has left #lisp ["Disconnected: Replaced by new connection"]
bhartrihari has joined #lisp
<p_l>
currently V8, and thus Chrome, can't handle WASM that isn't representable as straight JS
X-Scale` has joined #lisp
<aeth>
p_l: Chrome is the new IE6
<p_l>
this is related to Chrome apparently translating WASM to JS
X-Scale has quit [Ping timeout: 256 seconds]
X-Scale` is now known as X-Scale
lnostdal has quit [Ping timeout: 246 seconds]
bhartrihari has left #lisp ["Disconnected: Replaced by new connection"]
bhartrihari has joined #lisp
decs has joined #lisp
emacsomancer has quit [Read error: Connection reset by peer]
jesse1010 has joined #lisp
emacsomancer has joined #lisp
lnostdal has joined #lisp
<phoe>
I once came into #lisp and saw Chrome, being the new IE6, apparently translating WASM to JS
<p_l>
phoe: the context was "chances for lisp on wasm"
<p_l>
actually, a cross compiler for a limited language could be useful...
<p_l>
also for eBPF programs
<decs>
Thanks for your advice earlier guys, I've spruced up my little hobby framework in accordance with your comments. I kept the closures for the moment though as I'd like to experiment with some of the material in Let Over Lambda. Pastebin https://pastebin.com/ZCjSjA37 if you feel like having a squiz
hsaziz has joined #lisp
srazzaque has quit [Remote host closed the connection]
stoneglass has joined #lisp
emacsomancer has quit [Read error: Connection reset by peer]
lnostdal has quit [Quit: "Fascism, Nazism, Communism and Socialism are only superficial variations of the same monstrous theme—collectivism." -- Ayn Rand]
emacsomancer has joined #lisp
decs has quit [Remote host closed the connection]
hsaziz has quit [Ping timeout: 265 seconds]
X-Scale` has joined #lisp
Bit_MCP has joined #lisp
thmprover has joined #lisp
X-Scale has quit [Ping timeout: 272 seconds]
X-Scale` is now known as X-Scale
smazga has joined #lisp
orivej_ has joined #lisp
orivej has quit [Ping timeout: 265 seconds]
smazga has quit [Ping timeout: 265 seconds]
<aeth>
phoe: the context (with a bunch of offtopic thrown in, yes) being why we still don't have Lisp in the browser.
scymtym_ has joined #lisp
<flip214>
does someone know of a REPL over HTTP, ie. with a HTML <textarea> and a history and syntax highlighting and <tab>completion (via JS) and any other features?
<phoe>
cl-jupyter might be the closest I think
scymtym has quit [Ping timeout: 240 seconds]
<thmprover>
OK, I am about to start a toy AI project, and I'm deliberating between using Common Lisp vs Scheme...
<phoe>
thmprover: well you've come to a Common Lisp place
bhartrihari has left #lisp ["Disconnected: Replaced by new connection"]
<thmprover>
phoe: what!? I thought this was "generic lisp"
<aeth>
You're probably best just asking in #lisp for CL and #scheme for Scheme and getting the strongest argument for each, though. ##lisp (for Lisps in general) is kind of inactive
smazga has joined #lisp
<thmprover>
OK, well, what is the strongest arguments in favor of CL? (I don't know CL, I work with Clojure daily though)
<phoe>
multiparadigm, it doesn't really enforce any paradigm od programming style on you and adapts to new ways of programming
<flip214>
thmprover: thanks! but feels very slow, I'd have hoped for something very interactive
<flip214>
thmprover: very rich library ecosystem
<phoe>
flip214: this likely executes a new CLISP process for each hit of the button, hence slowness
<thmprover>
I have read a good chunk of "Let over Lambda", so I appreciate the strength of CL's macro system, and realize Scheme lacks this power
smazga has quit [Ping timeout: 256 seconds]
<beach>
thmprover: As far as I know, Scheme doesn't have anything like CLOS yet. And that is one of the absolute strongest point in favor of Common Lisp.
<flip214>
phoe: yeah, right
<flip214>
cl-jupyter looks very nice, from the screenshots
<p_l>
Scheme doesn't have CLOS equivalent in standard library, no
<aeth>
beach: That's not quite true. Plenty of Schemes have CLOS-like systems, although portable Scheme does not and probably cannot
<p_l>
aeth: I think TinyCLOS was portable across R5RS
<thmprover>
So I'm going to be doing some symbolic mathematics, and I'd like arithmetic operators to extend to new types (e.g., quaternions should have addition). Can CL handle this?
<beach>
aeth: I think you just proved my point.
<p_l>
that of course still left you with porting all other kinds of stuff
<beach>
aeth: "Schemes" in plural form, and -like at the end. Very likely mutually incompatible.
<aeth>
Well, yes. If you're interested in CLOS there's only one Scheme you'd want to use.
<beach>
aeth: Of course portable Scheme could have it. It is just a matter of including it in the next version of the standard.
<beach>
<aeth>
beach: It would probably have the same issue as R6RS's condition system, in that it would define a hierarchy that might conflict with an implementation, thus meaning that otherwise-conformant implementations might ignore that part of the standard.
<aeth>
It's kind of too late to do that sort of thing with Scheme, at least portably and standardized.
<p_l>
I wonder if Ralph would count more as Scheme or CL?
<beach>
p_l: I seriously doubt that something like CLOS for Scheme could be in a library. My experience with CLOS is that it permeates every aspect of the base system as well.
<p_l>
Probably more of a Scheme
<p_l>
beach: at the same time, CLOS' major claim to fame is that it could be introduced through library
<aeth>
beach: It can, it just has to be a built-in library rather than one that can be added as a portability library.
<p_l>
that said, CL is very fluid in that area, isn't it? (And we like it like that)
<beach>
I can't believe that I am being argued with about this issue.
<flip214>
hmmm, I'm testing cl-jupyter but I always get fatal error encountered in SBCL pid 273284(tid 0x7f0c8f9fb2c0):
<flip214>
Can't find sbcl.core
<p_l>
beach: I hope I don't come through as argumentative on this - I just find Lisp implementations to be so malleable :)
Inline has joined #lisp
chip2n has joined #lisp
<flip214>
thanks, solved
Jeanne-Kamikaze has joined #lisp
xlei_ has joined #lisp
jeosol has joined #lisp
xlei has quit [Ping timeout: 260 seconds]
xlei_ is now known as xlei
chip2n has quit [Read error: Connection reset by peer]
rogersm has joined #lisp
chip2n has joined #lisp
<aeth>
On the one hand, CLOS is literally going to be in "a library" in Airship Scheme, but on the other hand, of course that's just exposing the underlying CLOS functionality from the base CL implementation it's running on...
shka_ has quit [Ping timeout: 256 seconds]
hsaziz has joined #lisp
scymtym_ has quit [Remote host closed the connection]
scymtym has joined #lisp
EvW1 has quit [Ping timeout: 272 seconds]
Cuccslayer has joined #lisp
<Cuccslayer>
Hello
<Cuccslayer>
i have a problem with the libffi dlls, i have put them on PATH and even pushed the directory in which they are to cffi:*foreign-library-directories*
<stylewarning>
Can you provide your CFFI declaration