freenode/#lisp - IRC Chatlog
Search
21:50:16
jasom
jmercouris: the defcfun ought to work, assuming it's linked in somewhere; I haven't heard back yet from the webkit gtk channel yet
22:08:08
osune
I do (funcall fn arg) but fn can have [0-n] arguments what is the idomatic way to declare a fn with zero arguments? I'm undecided between &rest and a declare / ignore
22:14:02
phoe
I mean, you can always try, but Lisp is going to throw errors at you every time your Russian roulette doesn't work your way.
22:14:28
osune
ok let me backpaddle a bit, because maybe i ask the wrong question and my problem is more my design
22:15:47
Shinmera
phoe: ;) (defun call-anything (fn) (let (a) (loop (ignore-errors (return (apply fn a))) (push 0 a))))
22:18:09
osune
I parse user input for a chatbot via cl-pprce. assume the commands "/echo foo" and "/ping". One takes a parameter the other doesn't. I split the string into the command and the argument parts. So i have a special case that my functions only take zero or one parameter. The function itself tries to parse the complete argument string.
22:19:22
phoe
in one case you have ("/echo" "foo"), in the other case ("/ping" "") or ("/ping" NIL) depending on how you want to put it.
22:20:56
phoe
I wouldn't define functions with DEFUN for this though. my style, at least, would be to make an EQUAL-tested hash-table, and (setf (gethash "echo" hash-table) (lambda (arg-string) ...))
22:20:56
osune
yes. thats exactly my result after the first parse. Now i could do a (if arg (funcall fn arg) (funcall fn))
22:22:24
phoe
or rather, if you want PING to explicitly NOT want an argument, you can (lambda (arg) (when arg (error ...)) ...)
22:22:39
osune
I can see why lambda is a question of style and viable but having a named function helps a bit with debugging
22:22:52
phoe
or something else. so PING returns "wrong syntax: use /PING without an argument" or something.
22:23:25
osune
well exactly what you are suggesting is what I'm doing currently: (defun ping (arg) (declare (ignore arg) "pong"))
22:24:27
phoe
but then again, other people might have more valuable insight on the matter, so don't limit yourself to just my ideas.
22:24:30
Shinmera
What I would do is handle the arglist parsing in a common place, define each command as a native lisp function, and then just apply the function to the arglist, reporting errors to the user.
22:25:05
Shinmera
Though actually what i would do is use an existing library like Maiden to do all of that for me :^)
22:27:31
osune
But this is kinda a pet project to prepare myself for a reimplementation of a scheme midi sequencer , so I'll tinker a bit more and then take a look at it
22:29:15
Shinmera
osune: Anyway, something like this is what I would do: (defun ping () (reply "pong")) (defun handle-command (string) (let ((args (split string " "))) (apply (find-symbol (string-upcase (first args))) (rest args))))
22:29:40
osune
and as long I as cannot wrap my head around CFFI (libevdev/jack) I keep myself busy and keep learning
22:29:41
Shinmera
I say "something" since you probably want to throw your command functions either into a separate namespace entirely (preferable) or into their own package
22:33:16
osune
Shinmera: hm never played with find-symbol. I use a hash-table with :test 'equal to store the functions
22:33:16
phoe
osune: I would call it bad design to unnecessarily create functions that don't know how many arguments they will accept
22:34:01
phoe
but then again, depends on if you want things like "/ping foo bar baz quux fred" to work just like "/ping" would
22:36:04
Shinmera
makomo: I've never used it, but it looked overly complicated to me and like it tried to do too much. When I needed command line arg parsing I used Fare's command-line-arguments lib
22:36:10
phoe
CLON is a mammoth. Which has its upsides and downsides. I settled for Fare's command-line-arguments instead.
22:36:47
makomo
it does look complicated i guess, but that's only because argparsing is complicated imo :-)
22:37:26
makomo
Shinmera: oh, only because i saw you talking about argparsing and mentioning libraries
22:38:17
phoe
makomo: this discussion with osune is more about parsing function args inside Lisp, not on the boundary between Lisp and the OS
22:38:21
makomo
Shinmera: oh lol, i haven't read the whole thing actually, only your last couple of posts
22:39:15
Shinmera
Arg parsing in Maiden is handled by this lil' piece of beauty: https://github.com/Shirakumo/maiden/blob/master/agents/commands/parsing.lisp
22:40:53
osune
Ok lets say "/ping foo" is a no go. An error will be generated and returned to the user. What's the lisp way to call my two functions with stepping the least toes of good Common Lisp style ? *takes a look at the link
22:43:00
Shinmera
osune: Calling a function with the wrong number of arguments causes an error. Your function may also error for other intended or unintended reasons. Therefore you need to catch all errors to report to the user anyway.
22:55:29
osune
I see currently these options and I'm unsure which is the "best" or if I'm completely wrong: https://gist.github.com/osune/88f900b70c8083457816d3ca834b2cf3
22:55:55
jmercouris
jasom: The only thing I can find is that same JS core stuff by apple like you found; https://developer.apple.com/documentation/javascriptcore
23:09:02
Shinmera
osune: The "event" is there so that you have a context to work with in your commands. For instance, so that the command "knows" which channel to reply to.
23:09:28
Shinmera
Or rather, the event knows that and the reply function uses this information to do the right thing.
23:14:16
osune
love it! it solves the whole problem via format and I'm happy that I can say my solution looks nearly identical , apart from the event mechanic . Thanks that was insigthfull
23:15:10
Shinmera
The error reporting of this approach is somewhat poor as you're depending on the implementation's errors to be insightful (which they are often not)
23:15:52
Shinmera
A "proper" approach would manually parse and match a lambda list, like what maiden-commands does. But that's rather involved.
23:20:34
Shinmera
osune: I've updated the paste with a change that should improve error reports a bit.
23:48:00
aeth
pillton: Is there a way to see the disassembly produced by specialization-store for a given defspecialization?
23:54:48
aeth
Found it, it's (map nil (compose #'disassemble #'specialization-store:specialization-function) (specialization-store::store-specializations #'foo))
23:55:30
aeth
I was trying to call the slot names provided from the slime inspector (another way to get the disassembly), but your readers don't match your slot names
23:55:42
pillton
Another way is to give the specialization a function name. (defspecialization (store :name %store/specialization)) (disassemble '%store/specialization)
23:56:42
aeth
It looks like it produces exactly what I would produce by hand, with identical disassembly.
23:58:49
aeth
It also looks like it can be inlined, which is great for trivial functions if it works just like function inlining does
23:59:24
pillton
Yes. https://github.com/markcox80/specialization-store/wiki/Tutorial-3:-Compile-Time-Support
0:02:15
aeth
(Although technically the fixnum one is incorrect because adding two fixnums doesn't necessarily produce a fixnum.)
0:08:47
aeth
How do I know that it's using the correct foo? Or is that the runtime dispatch foo? Is that because I'm doing that in the REPL?
0:13:25
aeth
pillton: If I introduce an observable side effect to the runtime dispatch, I can see if a given function is using runtime dispatch
0:16:41
pillton
It should be exported. The expand-store function is part of the object protocol within SS's MOP.
0:18:31
aeth
Looks like the trace only shows up in the REPL when I do something like this: (let ((foo (let ((rand (random 1))) (if (zerop rand) 1f0 1)))) (foo foo foo))
0:18:52
aeth
e.g. (defun bar () (foo 1f0 2f0)) or (defun baz () (let ((foo (let ((rand (random 1))) (if (zerop rand) 1f0 1)))) (foo foo foo)))
0:20:57
aeth
This doesn't call the trace every time. (defun baz () (let ((foo (let ((rand (random 2))) (if (zerop rand) 1f0 1)))) (foo foo foo)))
0:22:06
aeth
I'm not sure if that's because it's really smart or if runtime dispatch uses something else
0:23:27
pillton
Expand-store is invoked when the function is compiled to see if any compile time optimizations can be performed.
0:28:47
aeth
But they call the same function in the disassembly. In fact, if I disassemble a foo-fn and a foo-sf, it looks like they call the same function in the disassembly. At least, if that's what this means; "MOV EAX, #x2054DF78"
0:36:24
aeth
Does this mean that when it's not inline SBCL always uses runtime dispatch to determine which foo to call, even when the types are known? e.g. (defun foo-sf () (foo 1f0 1f0)) (defun foo-fn () (foo 1 1))
0:37:27
aeth
Interestingly, CCL gives a bogus warning when defining the functions themselves: In FOO-SF: In the call to FOO with arguments (1.0 1.0), 2 arguments were provided, but at most 0 are accepted by the current global definition of FOO
0:37:51
pillton
Yes. The standard specifies that compiler macros are not invoked when a function is declared not inline.
0:42:16
aeth
pillton: Does specialization-store have a way to inline the dispatch but not the function itself? Sometimes that might be the most performant option, if the function is very large but the type of the arguments in the calling function is known
0:44:16
jmercouris
jasom: here's the interface file https://gist.github.com/d641b6ed92f35ae3fea76ddec14717b4
0:45:25
aeth
pillton: I guess it's possible with a combination of named specializations and expand functions, where the :expand-function calls the named specialization?
0:46:34
pillton
aeth: Matrix multiplication is always part of a larger problem. If the larger problem wants to be efficient then it should declare the types.
0:56:35
aeth
pillton: is it intentional that define-specialization cannot use :name and defspecialization can?
0:59:12
aeth
This is pointless compared to just inlining it, I was just combining the two things in the tutorial other than inline in one place
0:59:19
aeth
(define-specialization (foo :name %foo/single-float) ((x single-float) (y single-float)) single-float (:function (lambda (x y) (+ x y))) (:expand-function (specialization-store:compiler-macro-lambda (x y) `(+ ,x ,y))))
0:59:59
aeth
And there's no problem with defspecialization: (defspecialization (foo :name %foo/fixnum) ((x fixnum) (y fixnum)) fixnum (+ x y))
1:00:32
aeth
I was just going off of https://github.com/markcox80/specialization-store/wiki/Tutorial-3:-Compile-Time-Support
1:05:04
aeth
(define-specialization foo ((x single-float) (y single-float)) single-float (:name %foo/single-float) (:function (lambda (x y) (+ x y))) (:expand-function (specialization-store:compiler-macro-lambda (x y) `(+ ,x ,y))))
3:33:42
krwq
hello, I'm using cl-dbi to fetch couple of million rows from the postgres db. Currently my sbcl's memory is being exhausted when doing that - on my side I'm not allocating it - I believe this is happening due to: https://github.com/fukamachi/cl-dbi/blob/master/src/dbd/postgres.lisp#L95 (reading whole db to a list) - does anyone know any better alternatives? should I switch to postmodern or are there any better alter
3:35:32
krwq
nope but I noticed that when I compile sbcl from sources and run gc in the loop it doesn't happen - the problem with newest sbcl is that some other libraries are not working correctly with it (I had problems with cepl and log4cl)
4:27:22
sigjuice
is there a utility that will fetch a copy of the upstream version of a quicklisp release?
4:35:03
jmercouris
sigjuice: I believe it was yourself that sent me the link to the QL repo/project mapping
4:35:54
jmercouris
sigjuice: I mean this repository: https://github.com/quicklisp/quicklisp-projects
4:36:17
jmercouris
conceivably it should be possible to write such a utility, could be pretty useful
4:37:18
sigjuice
jmercouris thanks for your offer! I figured I can't be the first person with such a wish, so I asked here.
4:37:58
jmercouris
I've never heard of such a tool, then again, I haven't heard of a lot of stuff :D best wait until Xach is online before departing on this journey
4:40:09
sigjuice
so far I have been looking at the quicklisp-projects repo and manually fetching copies to my quicklisp/local-projects
4:45:20
jmercouris
yeah, we could very easily automate it though I think, I have a feeling there is someway to do it already via quicklisp though, mayb
5:25:47
aeth
Interesting, people are doing JVM->WASM and WASM->JVM already. https://news.ycombinator.com/item?id=16075933
5:28:09
aeth
That's going to happen for sure. ABCL might work with JVM -> WASM and Clasp might work with LLVM -> WASM without much extra effort.
5:33:10
jmercouris
aeth: you'll still probably want some layer in between to work with the dom and stuff like that though, you'll need to extend the language in some meaningful way
5:45:01
rme
I have worked with a client who uses CL to model x86 cpus. But not in the sense of "run Windows on this Lisp-emulated x86".
5:46:24
dmiles
yeah actually as i think harder (that is what i meant "run Windows on this Lisp-emulated x86") it would be an entire system like VM i would be thinking of
5:47:55
dmiles
the benefits would be abstractions available on the level of the machine instance i suppose
6:53:52
EvilTofu
Hello again! In (defmethod add-list-of-symbols-to-object ((alist cons))) where I add a list of symbols to something, is there a way to specify that the list has to be symbols only or should the code not care?
6:56:19
pillton
No. Methods can only dispatch on classes and there is no class representing a list of symbols.
6:59:57
EvilTofu
So I can actually provide two methods where one is a list of symbols and one where the parameter is a symbol.
7:14:22
hibikelel
Wondering if there's somebody up this late who can help me with a bit of a quandry
7:15:16
hibikelel
I'm a novice programmer, and even that's stretching it, I've got a very shallow knowledge of a wide number of languages but couldn't code my way out of a paper bag when you get down to it
7:16:01
hibikelel
Out of all the languages I've messed around with Lisp seems to be the only language/family I can see myself doing any long-term work in, at least for fun
7:17:22
hibikelel
Dedided I'd work on a much larger project, really test my skills, I've never done anything with 3d graphics before so I figured I'd tinker around, trouble is there doesn't seem to be any libraries written, in racket anyway, for any openGL implementation after 1.5 which is pretty out of date at this point
7:18:53
hibikelel
Should I just switch to another language or might it be worth writing some wrapper functions for a C graphics lib
7:19:11
|3b|
#scheme or #racket might know more about scheme/racket bindings, this channel is mostly about common lisp, for which there is cl-opengl
7:19:46
JuanDaugherty
RECOMMEND: reevaluate your judgement on the graphics library, do more research and go with best you can find in time you have
7:20:00
hibikelel
You know I've been bouncing between implementations for a while and I'm not against using CL, I guess I'll give that a shot
7:20:35
JuanDaugherty
and obviously continue with lisp, but there is a cl vs scheme decision to make
7:20:41
hibikelel
Worked through most of SICP, read a bunch of Scheme books, Little Schemer, then Realm of Racket, about halfway through HTDP
7:21:22
hibikelel
Never done any 'serious' work however, and while it's a true statement that I have no idea what the fcuk I'm doing I feel I know enough to figure it out
7:22:15
hibikelel
Let's see... I must have written my first real python program in 2014 but I didn't keep up with it, I did about jack shit until I wanna say three months ago
7:23:00
EvilTofu
If I want a function that adds a connection from one node to another (add-connection node1 node2) but I want the option of a bidirectional connection and want a (add-connection node1 node2 :bidirectional), how should this be implemented? And is this a valid lisp way of doing this?
7:23:38
hibikelel
Built up the vocabulary, finally beat it into my skull what exactly constitutes a class (no I didn't, every language changes it around) and I have trouble staying on one language when I get bored, I've got knowledge as broad as a gorge, deep as a puddle
7:24:03
hibikelel
I've probably made it through the first half of close to a dozen different books on nearly as many languages, and god knows how many tutorials
7:24:05
JuanDaugherty
in computer programming, unlike comparable professions, there's a forced dilletantism that comes from the impact of its history and role in the capital system
7:24:34
|3b|
EvilTofu: usually you would have (add-connection node1 node2 :bidirectional t), and use &key
7:25:22
hibikelel
I don't intend to become some master-programmer who reinvents everything about modern society, nice as that would be, when you get down to it I just want to hack around with pretty pictures
7:26:27
hibikelel
Have a neat idea for a simple 3rd person shooter, don't even intend to sell it, just show off to some friends, I'd be surprised if whatever I come up with would be considered passable on the ps1
7:27:23
JuanDaugherty
hibikelel, it is probably inappropriate for you to try to do a lisp app for ps1
7:28:12
hibikelel
Not what I meant, I was trying to say that the level of quality I'm shooting for here wouldn't have made a passable game on that platform, not that I'm actually intending to write a game for the ps1
7:28:44
hibikelel
That said interestingly enough Crash Bandicoot was written in a proprietary lisp dialect called GOOL
7:28:49
|3b|
you could also pass :bidirectional nil if you wanted to be explicit at the call site (or if you wanted to pass it on from another variable or similar)
7:29:09
JuanDaugherty
i still am unable to determine the nature of the specific paedagogical emergency
7:29:38
|3b|
there is also the option when writing the defun to determine if :bidirectional was specified at all when you want more complicated defaulting behavior, but usually you don't need that
7:30:24
hibikelel
I was just having trouble finding a 3d graphics library for racket, folks in here reccomended cl
7:32:02
|3b|
hibikelel: note that 'here' is a bit biased, other channels might have other biases and thus other suggestions :)
7:32:02
hibikelel
folks in this channel reccomended cl, I connected to #lisp thinking it was a general lisp chanel, unaware there was chanels for specifict dialects
7:34:52
JuanDaugherty
fwiw, i move freely across lang cultures but for you that's probably inappropriate. I wrote my first program in 1974, went to college for it, had a long career, etc
7:37:42
hibikelel
awesome, as much as I'd like to have a career in programming one day I'm not sure that I'm cut out for it, I'd prefer to keep it as a neat hobby rather than anything I do too seriously. No offense to those who do so for a living but I like the unconstrained nature of a blank editor, allowing me to work on/tinker with whatever I feel like, having to maintain someone else's software as product seems like
7:39:00
JuanDaugherty
that is the common reaction to doing it under the capital system, the major alternative is academic/scientific computing
7:39:35
JuanDaugherty
and the dilletantism you seem to be headed for was once common, still is a thing i think
7:41:03
JuanDaugherty
and extremely common pattern was for people to get sucked in from other disciplines, especially technical ones and then burn out on the noxious character of the industry
7:42:37
hibikelel
I've always loved computing, but I'm more of a technician than a programmer, ressurected the laptop I'm typing this on from a chinese electronics-scrapper, had almost no parts, not even a display, ordered all of that and assembled the machine, turns out the backlight-fuse was blown, so I did my first soldering job on this thing, pretty proud of it in all honesty
7:44:39
hibikelel
I mean what can be said for the commercialization of the technical sector, the advent of the microprocessor didn't exactly change everything about everything overnight, but it certainly made a massive impact once consumer-grade computers were in the hands of the masses, from there the internet supercharged things
7:47:06
JuanDaugherty
'the commercialization of the technical sector' may make sense in china or russia, but the technical sector originated in and never left the technical sector
7:49:38
hibikelel
Perhaps that was a poor turn of phrase, I was attempting to articulate the transition of general computing from the past-time of academics and amateur programmers through the mid-sixties into the late-seventies, into what we wolud consider the modern information economy. Time was unless you were manufacturing hardware there was almost no money to be made in computing outside of supporting a corporate
7:51:41
JuanDaugherty
even mathematics itself arose in the practical activities of accounting, surveying, etc
7:56:53
JuanDaugherty
probably the height of what you are talking about was in the late 70s and early 80s, a fairly brief time, less than a decade
7:59:23
JuanDaugherty
anyway, as far as your original paedogogical emergency, i'd give portacle a try, use the libs it provides
9:11:50
hajovonta
also, it's a lot of money just to travel and stay, and in the past few years it was nearly impossible to embark on the journey