jackdaniel changed the topic of #lisp to: Common Lisp, the #1=(programmable . #1#) programming language<http://cliki.net/> logs:<https://irclog.whitequark.org/lisp,http://ccl.clozure.com/irc-logs/lisp/> | SBCL 1.4.5, CMUCL 21b, ECL 16.1.3, CCL 1.11.5, ABCL 1.5.0
graphene has joined #lisp
anewuser has joined #lisp
dale has quit [Quit: dale]
mkolenda has quit [Quit: Free ZNC ~ Powered by LunarBNC: https://LunarBNC.net]
durn has quit [Ping timeout: 252 seconds]
asarch has quit [Quit: Leaving]
mkolenda has joined #lisp
rumbler31 has joined #lisp
quipa has quit [Ping timeout: 252 seconds]
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Xach> serichsen: sorry. i need to fix it.
quazimodo has joined #lisp
fortitude has quit [Remote host closed the connection]
graphene has quit [Remote host closed the connection]
serichsen has quit [Ping timeout: 240 seconds]
pfdietz has quit [Ping timeout: 240 seconds]
graphene has joined #lisp
pfdietz has joined #lisp
dented42 has joined #lisp
nowhere_man has joined #lisp
elderK has joined #lisp
pjb has quit [Read error: Connection reset by peer]
pjb has joined #lisp
Cymew has quit [Read error: Connection reset by peer]
Cymew has joined #lisp
scymtym has quit [Ping timeout: 245 seconds]
warweasle has joined #lisp
Oladon has joined #lisp
Josh_2 has quit [Quit: ERC (IRC client for Emacs 26.1)]
pjb has quit [Ping timeout: 252 seconds]
doesthiswork has joined #lisp
<doesthiswork> what test framework should I use?
shifty has joined #lisp
<AeroNotix> doesthiswork: prove, rove or fiveam
<doesthiswork> alrighty
<AeroNotix> imho, rove is the better of the three.
<emaczen> I see :little-endian in my *features* how common is the type of endianness across implementations?
esrse has joined #lisp
<|3b|> how common is little endian, or how common to be specified that way in *features*?
<|3b|> little-endian is fairly common (mostly depends on CPU or ABI rather than implementation), and there is a library called "trivial-features" that i think will put that sort of thing in *features* in a consistent way
<emaczen> |3b|: If I started using a big-endian machine, would :big-endian be in the *features* list?
<|3b|> depends on implementation, but trivial-features would put it there if needed on implementations that didn't already do so
warweasle has quit [Quit: away...]
robotoad has joined #lisp
igemnace has joined #lisp
quazimodo has quit [Ping timeout: 252 seconds]
quazimodo has joined #lisp
doesthiswork has quit [Quit: Leaving.]
eminhi has joined #lisp
Roy_Fokker has quit [Quit: Leaving]
rumbler31 has quit [Remote host closed the connection]
nowhere_man has quit [Ping timeout: 245 seconds]
rumbler31 has joined #lisp
dddddd has quit [Remote host closed the connection]
r1b has joined #lisp
xsperry has joined #lisp
NB0X-Matt-CA has quit [Quit: WeeChat 2.0.1]
igemnace has quit [Read error: Connection reset by peer]
igemnace has joined #lisp
<beach> Good morning everyone!
<jgkamat> morning bea
<jgkamat> beach :)
<no-defun-allowed> morning beach
rumbler31 has quit [Remote host closed the connection]
<jeosol> morning beach
elderK has quit [Quit: Connection closed for inactivity]
pierpal has quit [Quit: Poof]
pierpal has joined #lisp
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #lisp
igemnace has quit [Read error: Connection reset by peer]
igemnace_ has joined #lisp
r1b has quit [Quit: r1b]
pierpal has quit [Read error: Connection reset by peer]
siraben has quit [Remote host closed the connection]
siraben has joined #lisp
Oladon has quit [Quit: Leaving.]
siraben has quit [Ping timeout: 268 seconds]
rumbler31 has joined #lisp
rumbler31 has quit [Ping timeout: 240 seconds]
masterdonx has quit [Quit: ZNC - http://znc.in]
masterdonx has joined #lisp
anewuser has quit [Quit: anewuser]
marvin2 has quit [Ping timeout: 252 seconds]
graphene has quit [Ping timeout: 252 seconds]
antonv has joined #lisp
<antonv> jackdaniel: hi
<antonv> jackdaniel: how do you think, the error: too few arguments to function call, expected at least 3, have 2
<antonv> cl_set(VV[26],cl_remove(1, VV[45]));
<antonv> is it an ECl or rowsell bug?
<antonv> As I understand it's a compilation failure of this file: https://github.com/roswell/roswell/blob/release/lisp/extend-quicklisp.lisp
xsperry has quit [Quit: CGI:IRC (Ping timeout)]
parjanya has quit [Remote host closed the connection]
<no-defun-allowed> yeah that's missing the sequence to remove from
parjanya has joined #lisp
<no-defun-allowed> that file does look pretty messy
<beach> It does.
<beach> Inconsistent and incorrect spacing.
<beach> Multiple IN-PACKAGE forms.
<beach> Absence of newlines between top-level forms.
<no-defun-allowed> it's quite fortunate nothing else is broken.
<makomo> morning
<no-defun-allowed> morning, makomo
<beach> Hello makomo.
<makomo> hello :-)
<beach> .. Incorrect indentation.
<no-defun-allowed> well, i might give cleaning it up a go after the relevant issue gets fixed.
pierpal has joined #lisp
<beach> That would be good I guess. But messy code often suggests messy thinking on the part of the author.
<antonv> beach: or maybe author writes lots of code
<beach> That is no excuse.
<beach> In fact, it's the other way around.
<antonv> around how?
<beach> Someone who writes lots of code should, in order to be as fast as possible, decide once and for all how the indentation should look, what spacing to use, etc.
<beach> Otherwise, he or she must stop and think about it each time.
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<antonv> Maybe they decided, but you just don't understand their system :)
<no-defun-allowed> i should probably nuke/delete my old github account
<beach> antonv: I seriously doubt that.
<no-defun-allowed> it's a bloody mess, antonv
<no-defun-allowed> unless "choose based on the output of RANDOM" is a style, there's no formatting style or patterns
parjanya has quit [Read error: Connection reset by peer]
<antonv> no-defun-allowed: what github accound do yyou mean?
parjanya has joined #lisp
<no-defun-allowed> i'm deleting my really old github account since i used it since i was around 11
<antonv> no-defun-allowed: how old are you now?
<no-defun-allowed> 17
<antonv> fine age
<no-defun-allowed> do you think the roswell maintainers would accept a PR that cleans up just one file?
<beach> no-defun-allowed: You can try. It would send a good signal.
<antonv> no-defun-allowed: i donn't know
<no-defun-allowed> what would i be saying if i did?
<beach> I think I know the author. Isn't he a frequent participant at ELS despite being far away?
<beach> no-defun-allowed: "clean up code according to established conventions."
<no-defun-allowed> fair enough
<no-defun-allowed> fortunately the list i need to give REMOVE is in with the setf, hah
pierpal has quit [Read error: Connection reset by peer]
<antonv> no-defun-allowed: if you have nothing to do, maybe you better implement email notifications using Amazon SES in cl-test-grid?
<no-defun-allowed> i'm not that bored
<antonv> good for you
<no-defun-allowed> okay that came off a bit rude
<antonv> )
<antonv> :)
<no-defun-allowed> in around 30 minutes i have to leave for the orthodontist and it's pretty much one symbol i have to add
<antonv> what symbol?
<no-defun-allowed> `ql-dist:*dist-enumeration-functions*​`
<no-defun-allowed> L144 should be `(remove 'roswell-dist-enumeration-function ql-dist:*dist-enumeration-functions*)` if i'm not mistaken
moei has quit [Read error: Connection reset by peer]
moei has joined #lisp
<antonv> no-defun-allowed: a, yes, you're right, but that's fixed already - issue is closed on github.
slyrus has quit [Remote host closed the connection]
slyrus1 is now known as slyrus
slyrus1 has joined #lisp
<no-defun-allowed> i think all the read-from-string asdf symbols could be done with a reader macro like #+asdf
<antonv> no-defun-allowed: if asdf was present (so that #+asdf works), then there would be no need for read-from-string at all
froggey has quit [Ping timeout: 252 seconds]
froggey has joined #lisp
Bike has quit [Quit: Lost terminal]
<jackdaniel> antonv: so is there something for me to investigate?
<jackdaniel> or question solved itself when I was sound asleep? :)
<antonv> jackdaniel: solved - it was a roswell bug, fixed already
<antonv> jackdaniel: you wake up early
pjb has joined #lisp
<antonv> I'm only preparing for sleep
<jackdaniel> heh
lavaflow has quit [Read error: Connection reset by peer]
<jackdaniel> no-defun-allowed: keep in mind that such email notification would benefit whole ecosystem, cl-test-grid is invaluable help for implementers
lavaflow has joined #lisp
pjb has quit [Ping timeout: 252 seconds]
eminhi has quit [Ping timeout: 272 seconds]
sauvin has joined #lisp
<emaczen> how do you use cffi to postfix increment ++ a char**?
<emaczen> my understanding is that a ++ on a int* increments the address by 4 since integers are represented with 4 bytes
antonv has quit [Ping timeout: 245 seconds]
<emaczen> since char* is variable, how can you determine what to increment by or is ++ implemented via strlen or counting the length of the current char*?
<jackdaniel> pointer increment always increments by the address size
<emaczen> We dereference with cffi:mem-ref right?
makomo has quit [Read error: Connection reset by peer]
nonlinear has joined #lisp
frgo has joined #lisp
bigfondue has quit [Ping timeout: 240 seconds]
quipa has joined #lisp
wiselord has quit [Ping timeout: 268 seconds]
dented42 has joined #lisp
svillemot has quit [Quit: ZNC 1.6.5+deb1+deb9u1 - http://znc.in]
heisig has joined #lisp
arduo has joined #lisp
svillemot has joined #lisp
arduo has quit [Remote host closed the connection]
quazimodo has quit [Ping timeout: 252 seconds]
quazimodo has joined #lisp
bigfondue has joined #lisp
gabbiel has joined #lisp
Younder has quit [Ping timeout: 246 seconds]
gabbiel has quit [Remote host closed the connection]
nirved has joined #lisp
Demosthenex has quit [Ping timeout: 244 seconds]
Demosthenex has joined #lisp
<no-defun-allowed> There is one thing though: if FEATURES change, will old fasls be used?
<no-defun-allowed> I figure that fasl checking would be done on read forms instead of string representations but I'm not sure.
Cymew has quit [Remote host closed the connection]
ealfonso has joined #lisp
flamebeard has joined #lisp
<beach> "fasl checking"?
<jackdaniel> beach: I believe he talks about verifying, if fasl's need to be recompiled (asdf's cache-specific behavior)
<beach> Ah, OK.
<jackdaniel> she* :)
rozenglass has quit [Remote host closed the connection]
<Shinmera> fasls are recompiled if the file timestamp changes or the implementation version changes
<Shinmera> that's the standard asdf behaviour at least
shka_ has joined #lisp
<shka_> good morning
<beach> Hello shka_.
<shka_> what is the fastest way to convert bitvector into integer?
<jackdaniel> (coerce bit-vector 'integer)
nowhere_man has joined #lisp
<shka_> wow, that works?
<shka_> let me try
<jackdaniel> I don't know, have you tried it?
<Shinmera> It's not specified to, but it might.
<shka_> well, it does not work
<shka_> at least not in sbcl
rumbler31 has joined #lisp
<shka_> jackdaniel: idea of that did not occur to me
<shka_> but maybe there is something sbcl specific for that
<shka_> oh, there is a library!
<shka_> ok, bit-smasher is way faster then reduce (lambda (a b) (+ (ash a 1) b)) ;-)
rumbler31 has quit [Ping timeout: 272 seconds]
shrdlu68 has joined #lisp
angavrilov has joined #lisp
vlatkoB has joined #lisp
eminhi has joined #lisp
<Shinmera> The fastest way of course is to just use integers instead of bit vectors
<shka_> it is true
ealfonso has quit [Ping timeout: 252 seconds]
ealfonso has joined #lisp
mange has quit [Remote host closed the connection]
<shrdlu68> shka_: One can use a window function with octet vectors, uint62 vectors, etc, without converting to bit vectors.
<shka_> obviously
robotoad has quit [Quit: robotoad]
<shrdlu68> I switched my code to this from using bit-vectors, using a uint62 vector.
<shrdlu68> Surprisingly, this is slower than when I was using bit-vectors, at least for now.
<shrdlu68> I'm getting used to these kind of surprises these days.
JohnMS_WORK has joined #lisp
<no-defun-allowed> beach, jackdaniel: yes, i was wondering how a lisp system determines when a cache is no longer usable
<Shinmera> The lisp system has no fasl cache, that's all asdf
<Shinmera> and I already gave the answer for that
<no-defun-allowed> oh okay
<shrdlu68> Is it accurate to say that converting an integer to a bit-vector is a O(n) operation?
nowhere_man has quit [Ping timeout: 250 seconds]
<Shinmera> depends on what the implementation gives you.
<Shinmera> but if it's just standard, then yes
<no-defun-allowed> yeah, depends on the size of the vector and how it's managed.
<no-defun-allowed> worst case is probably O(n), best would be O(1) which would be achieved if it fits in a machine register
Cymew has joined #lisp
<no-defun-allowed> i don't understand the assumptions extend-quicklisp makes in roswell
<no-defun-allowed> some parts try to only do things if asdf is around using read-from-string and others just use asdf package symbols anyway
armo has joined #lisp
<armo> anyone around?
<Shinmera> no
<armo> crap
<jackdaniel> armo: Shinmera is a bot, it doesn't mean that anyone is around
scymtym has joined #lisp
<jackdaniel> oups
<armo> haha
<Shinmera> it's true
<armo> that's the biggest load of horse I heard the entire day lol
<shrdlu68> We're all automatons, true.
<no-defun-allowed> Shinmera: [ ] I am not a robot
<Shinmera> armo: The lesson is to just ask your question instead of asking to ask
<armo> can anyone help with racket?
<Shinmera> That would be a question for #racket or #scheme. This is common lisp.
<no-defun-allowed> this is a common lisp room
<no-defun-allowed> we don't have many resources for tennis equipment
<shrdlu68> Only commoners here.
armo has left #lisp [#lisp]
<no-defun-allowed> so i guess anything that mentions asdf gets the #+asdf macro
Cymew has quit [Ping timeout: 272 seconds]
<Shinmera> Huh?
<no-defun-allowed> if you look at roswell's lisp/extend-quicklisp source, it's quite unclear if it expects asdf to be around
<Shinmera> Ah
<no-defun-allowed> some parts have a weird (ignore-errors (read-from-string "ASDF:FOO")) guard and others do not
<no-defun-allowed> i've rewritten those guards to use #+asdf but i can't tell why the rest isn't guarded in a similar manner
<jackdaniel> sloppy programming maybe
<no-defun-allowed> presumably.
<no-defun-allowed> the only hunch i have is if there's some backwards compatibility issue but nothing seems to be complex enough for it to have not existed earlier
<loke> (find-symbol "FOO" "ASDF") is better.
<Shinmera> loke: That doesn't help with readtable case changes :/
<no-defun-allowed> #+asdf asdf:foo is even better in this case.
hiroaki has quit [Ping timeout: 252 seconds]
<loke> Shinmera: (find-symbol (symbol-name '#:foo '#:asdf))
<loke> oops
<loke> Shinmera: (find-symbol (symbol-name '#:foo) (symbol-name '#:asdf))
<no-defun-allowed> the phrase "just works" in roswell's description made me cringe though.
<Shinmera> right.
<jackdaniel> I had three approaches to rosweel
<jackdaniel> and it never "just worked" for variosu reasons
<jackdaniel> various*
<jackdaniel> roswell even
<Shinmera> I've used it only for CI and there it worked well enough
<no-defun-allowed> generally speaking, "just work" solutions have limited purpose and probably aren't oriented towards programmers
<Shinmera> no-defun-allowed: What? That's a stupid generalisation
<no-defun-allowed> it probably is, but i don't trust things to just work
<Shinmera> That doesn't mean solutions shouldn't be made to just work
ealfonso has quit [Ping timeout: 252 seconds]
<jackdaniel> hang on, I need to solder my RAM chip
<no-defun-allowed> lol, jackdaniel
<jackdaniel> and write kernel driver for it
<no-defun-allowed> well, not exactly what i had in mind
<shka_> question is
<no-defun-allowed> but beyond some level of complexity or design, there isn't a solution that fits all problems
<shka_> is there anything better then roswell?
siraben has joined #lisp
<no-defun-allowed> i suppose linux taught me to be a masocist so i won't comment further on software design
<Shinmera> shka_: roswell does lots of things. I'm not aware of another tool that can install a large variety of implementations with a single command
<Shinmera> shka_: But it also has build scripts and other stuff that I don't understand the need for
<shka_> ok
<Shinmera> no-defun-allowed: Sorry to hear that
<no-defun-allowed> it looks somewhat like an attempt to unixify lisp systems IMO
<Shinmera> it started as an implementation bootstrapper
nowhere_man has joined #lisp
hiroaki has joined #lisp
<beach> What is an "implementation bootstrapper"?
<no-defun-allowed> >
<no-defun-allowed> >Roswell is a Lisp implementation installer/manager, launcher, and much more!
<no-defun-allowed> it sets up your favourite CL implementation i guess
<no-defun-allowed> looks like the golang launcher/compiler/stuff commandline tool to me
<jdz> I just randomly created https://github.com/thephoeron/bit-smasher/pull/9, and looking at the output https://travis-ci.org/thephoeron/bit-smasher/jobs/436017531 made me very sad.
<jdz> Mainly because how the CI jobs download half of Qicklisp libraries.
<Shinmera> I tried fixing that by having travis cache things
<Shinmera> but any time I try to do literally anything with travis I end up with hours of lost time and lots of rage
<Shinmera> so I'm not suprprised that most don't bother beyond the basic setup
<jdz> I wonder if compiled FASLs could be cached, because I see ironclad as one of the systems, and it takes a while to compile that.
<jdz> Anyway, this looks like the very definition of bloat.
<jdz> Layers on top of layers, global warming be damned.
JohnMS has joined #lisp
<Shinmera> I really need to get to work on forge and autobuild
<dxtr> I just bought Practical Common Lisp
<Shinmera> Good!
<dxtr> Hehe
igemnace_ has quit [Remote host closed the connection]
JohnMS_WORK has quit [Ping timeout: 252 seconds]
<scymtym> many of those dependencies are due to the fact that cl-coveralls HTML-scrapes the coverage data from SBCL's coverage report (when i last checked, anyway)
<Shinmera> Yeah, I was puzzled to see lquery & team in there
pfdietz has quit [Ping timeout: 245 seconds]
pfdietz has joined #lisp
<Myon> svillemot: re cl-nibbles, there's a new release, but also another patch on top of it, not sure what makes sense to upload
razzy has quit [Ping timeout: 252 seconds]
nirved has quit [Ping timeout: 252 seconds]
razzy has joined #lisp
nirved has joined #lisp
esrse has quit [Ping timeout: 252 seconds]
heisig has quit [Remote host closed the connection]
heisig has joined #lisp
<dim> Shinmera: some people prepare docker images, publish them on some hub that travis can reach, and then have travis use that specified environment rather than their own moving target... I'm thinking of doing that next time I have to fix travis for pgloader
<dim> Myon: I don't have an answer for you unfortunately :/
<Shinmera> dim: I'm thinking I hate travis like the pest and want to develop my own CI to be free of its curse
jruchti has quit [Ping timeout: 268 seconds]
<dim> well travis still gives you free VMs
<Shinmera> VMs isn't really a big deal for me
<Shinmera> And yes yes there's jenkins and all that but it's all a mess.
quazimodo has quit [Ping timeout: 268 seconds]
<dim> do you run PR's code in your CI system? there's something about trust in using travis, aka not your own system, disposable VM
<Shinmera> I have no plans at the moment
<dim> fair enough then
<dim> Shinmera: did you have a look at https://circleci.com or some other competitors to Travis, btw?
<Shinmera> Haven't had the energy to, no
<Shinmera> Pretty much anything that requires me to push and wait to test my script is going to be as shitty as travis though
jruchti has joined #lisp
rumbler31 has joined #lisp
orivej has joined #lisp
<dim> though I didn't test CircleCI at all, it seems like to can run your own hosted CircleCI locally
<dim> anyway I feel I'm doing their advertising where I all want is for someone to take care of the CI for pgloader really, so I'll stop here ;-)
<Myon> dim: it's probably just a matter of trying to build pgloader and see if it works
rumbler31 has quit [Ping timeout: 252 seconds]
<dim> Myon: I just restarted https://travis-ci.org/dimitri/pgloader/jobs/426791620 to see what happens with the current QL distribution
<dim> we might have an answer in the next 5 to 15 mins
beach has quit [Ping timeout: 250 seconds]
<Myon> dim: looks like the debugger is waiting for someone to press a key
<dim> at least it was a fast answer
<dim> ironclad/2018-08-31/ironclad-v0.42.tgz doesn't work
<dim> nibbles/2018-08-31/nibbles-20180831-git.tgz might or might not work
<dim> is that the information you needed Myon?
<Myon> looks like, yes
iskander has quit [Quit: Quit]
beach has joined #lisp
iskander has joined #lisp
anewuser has joined #lisp
m00natic has joined #lisp
mkolenda has quit [Remote host closed the connection]
mkolenda has joined #lisp
marvin2 has joined #lisp
smokeink has joined #lisp
froggey has quit [Ping timeout: 252 seconds]
trittweiler has joined #lisp
vlatkoB has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
froggey has joined #lisp
vlatkoB has joined #lisp
Cymew has joined #lisp
beach has quit [Disconnected by services]
beach has joined #lisp
Essadon has joined #lisp
igemnace has joined #lisp
ggole has joined #lisp
rumbler31 has joined #lisp
rumbler31 has quit [Ping timeout: 252 seconds]
OMGOMG has joined #lisp
frgo has quit [Remote host closed the connection]
frgo has joined #lisp
xuxuru has joined #lisp
frgo has quit [Read error: Connection reset by peer]
frgo has joined #lisp
creat has quit [Ping timeout: 240 seconds]
creat has joined #lisp
SaganMan has quit [Ping timeout: 272 seconds]
orivej has quit [Ping timeout: 252 seconds]
Bike has joined #lisp
SaganMan has joined #lisp
rumbler31 has joined #lisp
xuxuru has quit [Quit: xuxuru]
kooga has joined #lisp
xuxuru has joined #lisp
warweasle has joined #lisp
rumbler31 has quit [Ping timeout: 252 seconds]
mkolenda has quit [Remote host closed the connection]
mkolenda has joined #lisp
dddddd has joined #lisp
smokeink has quit [Remote host closed the connection]
cage_ has joined #lisp
uint has quit [Remote host closed the connection]
uint has joined #lisp
charh has quit [Ping timeout: 252 seconds]
xuxuru has quit [Quit: xuxuru]
w37 has joined #lisp
nckx has joined #lisp
ebzzry has joined #lisp
JohnMS has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
nowolfer has quit [Ping timeout: 260 seconds]
nowolfer has joined #lisp
pierpal has joined #lisp
frgo has quit [Remote host closed the connection]
frgo has joined #lisp
eminhi has quit [Ping timeout: 252 seconds]
jack_rabbit has quit [Ping timeout: 252 seconds]
mkolenda has quit [Remote host closed the connection]
mkolenda has joined #lisp
frgo has quit [Ping timeout: 244 seconds]
flamebeard has quit []
frgo has joined #lisp
jruchti has quit [Remote host closed the connection]
dale_ has joined #lisp
rumbler31 has joined #lisp
dale_ is now known as dale
angavrilov has quit [Remote host closed the connection]
rumbler31 has quit [Ping timeout: 268 seconds]
beach has quit [Disconnected by services]
beach has joined #lisp
arbv has joined #lisp
frgo has quit [Remote host closed the connection]
frgo has joined #lisp
fortitude has joined #lisp
jruchti has joined #lisp
npr-work has quit [Ping timeout: 252 seconds]
frgo has quit [Ping timeout: 268 seconds]
DGASAU has quit [Read error: Connection reset by peer]
siraben has quit [Remote host closed the connection]
DGASAU has joined #lisp
siraben has joined #lisp
shrdlu68 has quit [Ping timeout: 252 seconds]
varjag has quit [Quit: ERC (IRC client for Emacs 24.5.1)]
shka_ has quit [Quit: WeeChat 1.9.1]
jkordani_ has joined #lisp
heisig has quit [Ping timeout: 250 seconds]
Bike has quit [Ping timeout: 256 seconds]
jkordani has quit [Ping timeout: 272 seconds]
charh has joined #lisp
robotoad has joined #lisp
angavrilov has joined #lisp
Kaisyu has quit [Quit: Connection closed for inactivity]
rippa has joined #lisp
shka_ has joined #lisp
angavrilov has quit [Read error: Connection reset by peer]
<shka_> good evening
<beach> Hello shka_.
sjl has joined #lisp
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
optikalmouse has joined #lisp
igemnace has quit [Quit: WeeChat 2.2]
Bike has joined #lisp
heisig has joined #lisp
heisig has quit [Client Quit]
jruchti has quit [Ping timeout: 252 seconds]
rumbler31 has joined #lisp
varjag has joined #lisp
makomo has joined #lisp
<phoe> I think I'm using a wrong kind of abstraction in my problem.
rumbler31 has quit [Ping timeout: 268 seconds]
<phoe> I have messages in my system, and there are three kinds of messages - FOO being a request, (OK FOO) being a successful response and (ERROR FOO) being an error.
<phoe> Each of them may have completely different slots.
<phoe> So I can't really define a single class FOO and set its slot STATUS to one of (NIL :OK :ERROR) because then my slots will be mismatched.
pjb has joined #lisp
<phoe> It's more like I need a dual kind of inheritance, one being FOO, BAR, BAZ, ... that are the different kinds of messages, and then the (NIL :OK :ERROR) that is the message status.
jkordani has joined #lisp
<ggole> Tag the info with symbols?
<ggole> eg, Greenspunning datatypes
<phoe> What do you mean?
jkordani_ has quit [Ping timeout: 268 seconds]
<ggole> If you have exactly three possible cases, you can indicate which one you have with a symbol
<phoe> Yes, that's what I am doing now
<phoe> And each possible case can have a different set of slots
<ggole> The symbol doesn't go in the class
<phoe> Oh, so you mean one more layer going in between
<ggole> Because it's the discriminant - you use it to determine which class you are looking at
<ggole> So the class value sits along side the symbol (in a cons or whatever)
jruchti has joined #lisp
<phoe> It's still pointless - FOO, (OK FOO), (ERROR FOO), BAR, (OK BAR), (ERROR BAR) are six different classes anyway
<phoe> All six may have different slots
<phoe> Right now I'm wishing I could name classes with two-element lists, but I can't have that
<pjb> phoe: actually, you can.
<pjb> You just need to implement this namespace yourself.
<phoe> Yes, that's what I'm thinking of.
<phoe> Time to take a dive into the MOP.
<pjb> You can also name it: (defclass |FOO BAR| …) (defclass |ERROR FOO| …) or even: (defclass |(ERROR FOO BAZ)| …) so you can (read-from-string (symbol-name (class-name (class-of (make-instance '|(ERROR FOO BAZ)|))))) #| --> (error foo baz) ; 15 |#
<phoe> Hm.
<Bike> mop doesn't really touch names
<phoe> Bike: yes, I don't want to deal with names.
<phoe> The standard states that class names are symbols, period.
<phoe> If I want to have my own naming convention, it means that I need to create a new subclass of STANDARD-CLASS that has a slot for this new naming method.
<phoe> And then rebuild half of the user interface to use this new naming method. The default DEFMETHOD won't work with it, for example.
<phoe> ...Lisp is a crazy language if it even allows me to think of redefining a half of the object system to suit my needs better
foom2 is now known as foom
<pjb> phoe: or you just map lisp objects to symbols (uninterned), and implement your own find-class.
<phoe> Hey, one second. I can still use the NAME slot on standard-class; I can just add a new slot named STATUS, which can be one of (NIL :OK :ERROR).
<phoe> And simply avoid defining them via DEFCLASS and instead resort to a custom mechanism of mine.
<phoe> (find-message-class '(:ok foo)) ;=> some class with name FOO and status :OK
nowhere_man has quit [Ping timeout: 252 seconds]
<phoe> And, once I have that, I need to implement my own DEFMETHOD that grabs class objects from my storage and not the class namespace.
optikalmouse has quit [Quit: optikalmouse]
<phoe> ........CLOS is completely and absolutely bonkers. I love it.
<djeis[m]> We forget sometimes just how flexible it really is.
m00natic has quit [Remote host closed the connection]
shifty has quit [Ping timeout: 252 seconds]
ggole has quit [Quit: ggole]
<oni-on-ion> how to examine class structure of clos with slime
<phoe> hm?
<phoe> inspect the class object
<phoe> (find-class 'standard-class)
<phoe> R-click the returned object, Inspect
<oni-on-ion> ah cool =) did (inspect ..) because no mouse
<oni-on-ion> ty
<|3b|> you can inspect it in slime inspector from keyboard with C-c C-I
LiamH has joined #lisp
wiselord has joined #lisp
varjag has quit [Ping timeout: 268 seconds]
npr-work has joined #lisp
varjag has joined #lisp
pfdietz has quit [Quit: pfdietz]
pfdietz has joined #lisp
jkordani_ has joined #lisp
anewuser has quit [Quit: anewuser]
zxcvz has joined #lisp
jkordani has quit [Ping timeout: 268 seconds]
shrdlu68 has joined #lisp
<fouric> would anyone happen to know why (format t "pushd ~/bin") => "Compilation failed: error in FORMAT: No matching closing slash" ?
<|3b|> ~ denotes format control, use ~~ for a literal ~ character
<fouric> oh, i'm an idiot
<fouric> thank you sir
<fouric> (it's really nice that that was caught at compile-time though)
<shrdlu68> What the time complexity of (length <list>)?
<shka_> linear
<fouric> i think it's O(n) in a naive implementation and O(1) in a clever one?
<|3b|> it has to walk whole list, so O(N) on length
<fouric> i recall something about SBCL being able to actually make some lists be vectors/arrays in some cases
<|3b|> can't be clever, since lists can share structure and be modified at any point internally
<shka_> as PCL put it
<fouric> RIP
<shka_> there are no lists
<|3b|> true, &rest 'lists' might be O(1) depending on how you use them in SBCL
* |3b| doesn't know of any other cases though
<fouric> that's unfortunate
<|3b|> doing much of anything with them will turn them into real lists as specified in clhs, so probably shouldn't rely on that either
<fouric> ...although i can imagine how difficult it would be to find lists that were guaranteed not to have either of those two things done to them
<dlowe> it can be fairly clever just with adjacent cons cells
edgar-rft has joined #lisp
<|3b|> also keep in mind a list has N sublists, so how would you know which if any needed optimized
<|3b|> &rest i think gets optimized as "vector of adjacent things on stack", since you are frequently giving it separate things anyway
<|3b|> but as soon as you treat it as a list (in a way visible to user code) it has to build a real list out of it
* |3b| has no idea what exactly you can do to it without triggering that, though i think LENGTH is safe
doubledup has joined #lisp
<dlowe> you can just build a vector of cons cells that is a real list, so that reads occur using aref unless/until a write occurs
orivej has joined #lisp
whaack_ has joined #lisp
<whaack_> Hello, I am trying to pass the result of a function into a macro. Right now i have to execute the function and copy and paste the code into the macro call. Is there a convention on how to do this?
<|3b|> convention is to not do that (at least without more info on what you are trying to do)
<dlowe> whaack_: are you clear on what exactly a macro does?
<|3b|> depending on context, possibly calling function from macro, or building macro form at runtime, or reader tricks could be applicable
<whaack_> dlowe: I think so, but maybe I do not know what I don't know. In my own words: A macro transforms an expression into another expression at compile time. So afaik what I'm trying to do is not possible / not normal because whenever I try to pass the result of the function to my macro it is just going to try to "transform my function" instead of evaluating it
<Bike> what macro isthis?
<|3b|> you can transform the function call, but not the output
<whaack_> The reason I am asking is because I am using the library cl-who, and it takes a lisp expression such as (:div (:a :href "www.mysite.com" "mysite")) and transforms it into html code <div><a href="www.mysite.com">mysite.com</a></div>
<whaack_> So I have this api where I can pass some lisp code representing html into a macro, but i want to be able to generate the lisp code that becomes html programmaticaly
orivej has quit [Ping timeout: 264 seconds]
<whaack_> Right now i can execute my function, generate my html, and then paste it into my macro, and get my html. I feel sad struggling and failing to encapsulate that process into a function/macro.
<whaack_> generate my html-as-lisp*
* |3b| got confused by trying to mix stuff with cl-who and switched to other libs :p
<|3b|> (not that i liked any of the other libs either)
<dlowe> whaack_: right, a macro runs before your program is running, so you can't take the "result" of a function
<dlowe> whaack_: however, you can generate code that calls the function and then does something with the result
sauvin has quit [Read error: Connection reset by peer]
<dlowe> and it's very easy to generate code that calls a function
creat has quit [Quit: ZNC - http://znc.in]
<whaack_> dlowe: right, but if that "something" is pass the result of the function to the parameter of a macro then i can't do it.
creat has joined #lisp
<Bike> i thought this is what the 'htm' thing in cl-who did
<Bike> i haen't used it, thou
<whaack_> Bike: ah yeah i saw an example of htm being used and it looked like what i wanted but i wasn't sure. i will look at it again right now
rumbler31 has joined #lisp
<dlowe> whaack_: I disagree. It will work fine.
<dlowe> (defun my-f (x) (1+ x)) (defmacro mac-a (e) `(1+ ,e)) (defmacro mac-b (e) `(1+ (mac-a ,e)))
<dlowe> (mac-b (my-f 5)) => (1+ (mac-a (my-f 5))) => (1+ (1+ (my-f 5))) => (1+ (1+ 6)) => 8
<Bike> whack is talking about a specific macro that they didn't write.
<dlowe> well, you can EVAL the macro if you want it during runtime
rumbler31 has quit [Ping timeout: 268 seconds]
<whaack_> ^ evaling the macro sounds like what i want
<Bike> don't do that
<Bike> we are talking about the specific case of generating some html
<Bike> there's no need to take a sledgehammer to it
* whaack_ looks into htm
<dlowe> Yes, basically by using EVAL, you are undoing whatever useful thing the macro was doing for you
<jasom> If we are using cl-who, just use functions, it works fine!
<whaack_> okay so i guess i can reduce my question to: how do i get cl-who to do its lisp-to-html transformation at runtime
<jasom> whaack_: I'm about to post an example of a function
<whaack_> jasom: tyvm
dvdmuckle has quit [Quit: Bouncer Surgery]
dvdmuckle has joined #lisp
<whaack_> jasom: tyvm x2.
<jasom> spinneret definitely has its advantages over cl-who (e.g. there's no way to have pretty-indentation with an example like this) but making encapsulations with cl-who is easier than most people think.
emaczen has quit [Remote host closed the connection]
nowhere_man has joined #lisp
whaack_ has quit [Read error: Connection reset by peer]
foom2 has joined #lisp
hiroaki has quit [Ping timeout: 246 seconds]
myrmidon has joined #lisp
<shrdlu68> (disassemble #'truncate) on SBCL is...interesting. Would it just translate to a div opcode for fixnums?
foom has quit [Ping timeout: 276 seconds]
<Bike> probably.
<Bike> truncate is the full function. most calls to truncate are probably reduced to not involve calling that function.
<Bike> if you M-. truncate, you'll see a number of DEFTRANSFORMs that carry that out.
cage_ has quit [Quit: Leaving]
warweasle has quit [Quit: rcirc on GNU Emacs 24.4.1]
doubledup has quit [Quit: Leaving]
<shrdlu68> Hmm, I see the deftransforms contain (unsigned-byte 64).
<shrdlu68> Does it apply the transform to (unsigned-byte 62)?
<shrdlu68> I thought we couldn't use full 64-bit registers...
<Bike> might unbox em
<shrdlu68> I've been working with uint62 all along.
<shrdlu68> What's "unboxing"?
<shrdlu68> Ah, I see.
<|3b|> we can use full 64bits, just have to be careful with it if you want to do so efficiently
<shrdlu68> Careful how?
<|3b|> for example passing them to a (full call of) a function, returning from a function, or storing it in an untyped container will require allocating it as a bignum and passing/storing a pointer to that
<|3b|> but within a function, or in specialized arrays or typed structs, you can use it as a 64bit value
<|3b|> within a function might require type checks/declarations
<|3b|> also be careful with overflow, since if it isn't sure whether an operation can overflow it will add checks
<shrdlu68> What happens when you use, say (unsigned-byte 47)?
<|3b|> (if you want C style overflow, sbcl optimizes cases where it knows you are only using the low N bits of the results, like (ldb (byte 64 0) (+ x y)), or similar with LOGAND, etc
<|3b|> unsigned-byte 47 could end up treated as a fixnum or unsigned-byte 64 depending on how you use it
<shrdlu68> I mean does it produce code any less efficient than it would've if you had used (unsigned-byte 64).
<|3b|> possibly more efficient
<|3b|> for example it is a subtype of fixnum, so can be passed to functions, etc as a fixnum
<|3b|> and adding 2 of those is (unsigned-byte 48), so it doesn't have to check for overflow when adding them in 64bit registers
<|3b|> so if you know a tighter bound for values, it helps to check/declare that bound
* |3b| is mostly talking about sbcl, other implementations may behave differently, though usually similar things apply
<|3b|> and i probably would try to avoid using an implementation that could do something useful with ub64 declaration, but not ub47, and didn't just expand the ub47 to ub64 :)
<shrdlu68> So as long as I declare my uint64s I'll avoid bignum arithmetic as long as I don't overflow. I'm mostly doing logxor and truncate.
shka_ has quit [Ping timeout: 252 seconds]
<|3b|> a bit more accurate to say "as long as the compiler can tell you don't overflow"
<|3b|> (or explicitly don't want any potential overflow)
<shrdlu68> Ok.
<|3b|> logxor is an example of something it can tell won't overflow
<|3b|> if it can't tell, it will add checks or possibly make full calls (though possibly still to more specialized functions)
<jasom> modular arithmetic it can also tell won't overflow
<|3b|> right, that's how you specify you don't want the overflow :)
vlatkoB has quit [Remote host closed the connection]
dented42 has joined #lisp
<jasom> it's surprisingly smart for how fast it runs.
<|3b|> if you compile the function with (optimize (speed 3)) declaration, it will tell you about places where it might have been able to generate faster code
<|3b|> at least once you figure out how to interpret what it says :)
<jasom> also inlining will prevent boxing at function-call boundaries.
knobo has joined #lisp
<knobo> I can not find any packages using package-inferred-system
<knobo> Doesn't anyone like it?
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<knobo> hmm... cl-docker is one.
warweasle has joined #lisp
smasta has joined #lisp
nirved has quit [Quit: Leaving]
shrdlu68 has quit [Ping timeout: 252 seconds]
scymtym has quit [Ping timeout: 240 seconds]
adam4567 has joined #lisp
knobo has quit [Quit: WeeChat 1.4]
knobo has joined #lisp
<knobo> Which system is a good example of using package-inferred-system?
warweasle has quit [Quit: rcirc on GNU Emacs 24.4.1]
<pjb> Perhaps one that has the same name for the system and the package?
<jeosol> morning guys.
orivej has joined #lisp
zxcvz has quit [Quit: zxcvz]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
kajo has joined #lisp
<jeosol> I am exploring converting speech to text/action using CL. Has any here used is aware such use. Or I may have to use other languages/frameworks to process the speech and then send action to CL side?
nowhere_man has quit [Ping timeout: 268 seconds]
<no-defun-allowed> I've used pocketsphinx to recognise speech.
<oni-on-ion> emacspeak ?
<no-defun-allowed> Yes.
<no-defun-allowed> I've used a pocketsphinx process's stdout pipe since I'm not too good with cffi or pocketsphinx.
dented42 has joined #lisp
<jeosol> thanks. I'll explore that. I hope what I am trying to do is possible. Just need to have speech command execute some CL functions/workflows.
trittweiler has quit [Ping timeout: 272 seconds]
Essadon has quit [Quit: Qutting]
edgar-rft has quit [Ping timeout: 252 seconds]
<oni-on-ion> some inspiration
shrdlu68 has joined #lisp
<shrdlu68> Is there a built-in function to set the a specific bit in an integer?
<no-defun-allowed> I guess the impractical is better for xahlee then getting emacs pinky.
<oni-on-ion> dunno. if you seen the vid it looks quite practical
<pjb> shrdlu68: integers are immutable.
<pjb> shrdlu68: (setf i (dpb 1 (byte 1 p) i))
<shrdlu68> Yeah apart from that one.
<no-defun-allowed> xahlee is a meme honestly
razzy has quit [Ping timeout: 244 seconds]
<pjb> shrdlu68: again, integers are immutable! (setf i (logior (ash 1 n) i))
<oni-on-ion> no-defun-allowed: dont know him myself =) i've seen the video linked from elsewhere
<oni-on-ion> did not really read the page when i linked it here just now
<no-defun-allowed> (hence why I want to know who would win in a fight between xahlee and mister quicklisp)
<no-defun-allowed> he's pretty trollish with his content
<oni-on-ion> that sounds like a meme itself , regardless of the real human person whomever it may be irl
<jeosol> oni-on-ion: thanks for the links looks interesting
<oni-on-ion> ie. i dont dislike or like trump because i know next to nothing about him, but i can see a lot of people dislike and a lot of people like. i can choose a crowd or remain not-knowing
<oni-on-ion> np i hope it leads to a fruitful quest
rumbler31 has joined #lisp
Inline has quit [Quit: Leaving]
rumbler31 has quit [Remote host closed the connection]
jeosol has quit [Ping timeout: 256 seconds]
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
slyrus1 has quit [Remote host closed the connection]
Roy_Fokker has joined #lisp
<jasom> shrdlu68: if integers were mutable you could do (setf 1 2). You clearly can't do that.
<shrdlu68> I understand that. I didn't mean in a mutable way, my wording fails me.
<jasom> (setf (ldb (byte 1 n) x) 1) ;; <-- that will set bit n
<oni-on-ion> clhs byte
<jasom> The format for the accessor is: (ldb bytespec place)
<jasom> clhs ldb
scymtym has joined #lisp
<jasom> shrdlu68: that lets you set arbitrary bit ranges to arbitrary values; a single bit is just the degenerate form.
<oni-on-ion> ah nested setf =P
shrdlu68 has quit [Ping timeout: 264 seconds]
<pjb> oni-on-ion: we say setf of a place, or generalised reference.
shrdlu68 has joined #lisp
<oni-on-ion> which can be anything as defined per set-setf (forget the defname)
Cymew has quit [Ping timeout: 268 seconds]
<pjb> defsetf or (defun (setf foo)) or other implementation dependent or standard specified accessors.
dented42 has joined #lisp
<oni-on-ion> yea the second one =) slots included right ?
rumbler31 has joined #lisp
rumbler31 has quit [Ping timeout: 268 seconds]
Bike has quit [Ping timeout: 256 seconds]
varjag has quit [Ping timeout: 245 seconds]
emaczen has joined #lisp
<emaczen> Can you return a cffi pointer from a defun?
<jasom> emaczen: yes?
<jasom> emaczen: I mean why not, you can return any object from a defun.
<emaczen> jasom: When I print the object from the function before returning I see a foreign pointer type
<emaczen> but when I print the object in the calling function, it is a list....
<jasom> emaczen: post the code?
varjag has joined #lisp
adam4567 has left #lisp ["ERC (IRC client for Emacs 24.5.1)"]
<jasom> emaczen: trivially (defun foo () (cffi:foreign-alloc :int)) returns a foreign pointer so it's obviously possible.
<emaczen> jasom: yep, I'm really stumped and am posting...
<emaczen> just when I thought I was getting the hang of C/Cffi
<emaczen> I'm having an issue with sin-addr
<jasom> is there a reason you use malloc rather than foreign-alloc?
<emaczen> jasom: I tried swapping them, and I still get the same error
<emaczen> what is so great about foreign-alloc?
<|3b|> any reason you return a pointer instead of just the value?
<|3b|> ah, i guess you are allocating and filling them?
<|3b|> probably better to let CFFI handle that for you
<emaczen> |3b|: Is there a more recommended way?
<|3b|> paste your struct def too
<emaczen> https://pastebin.com/uBCxBMUw -- struct def
<|3b|> but with the way you are doing it, the mem-ref is the problem
<emaczen> But don't I need a mem-ref since sin-addr isn't a pointer?
<|3b|> didn't you just say you are returning a pointer?
rumbler31 has joined #lisp
<emaczen> make-in-addr returns a pointer
<|3b|> but in that case, i'm not sure you want a pointer there
* |3b| might have to look at docs to see how nested structs works there
shrdlu68 has quit [Ping timeout: 268 seconds]
<emaczen> I tried cffi:foreign-slot-value also without success
moei has quit [Quit: Leaving...]
<|3b|> that looks like one of the type of structs cffi doesn't handle well without help :(
<emaczen> |3b|: how do I help it?
* |3b| is trying to remember how that stuff works
<jasom> emaczen: are you grovelling?
<jasom> emaczen: that's the easiest way; otherwise just write a C helper function to get the field(s) you need.
<emaczen> jasom: What is wrong with cffi:foreign-slot-value or cffi:with-foreign-slots?
<emaczen> jasom: I am not grovelling
<jasom> emaczen: that is fine, as long as your struct definition is correct; grovelling is the easiest way to get it correct.
<jasom> emaczen: but none of this should cause make-in-addr to not return a pointer. I deleted the with-foregin-slots and it works as expected.
<emaczen> jasom: well actually this is strange
<|3b|> ^ is closer to what i would do
<emaczen> man inet(4) specifies 4 fields for struct sockaddr_in
<|3b|> (or at least one way)
<emaczen> but the struct sockaddr_in definition in in.h has 5 fields
<jasom> emaczen: it specifies that those 4 fields must be present, not what order they are in of if there are others
<jasom> emaczen: this is why grovelling is done.
<emaczen> jasom: Oh...
<|3b|> (setf (mem-ref ...) ...) can translate from a lisp plist (or other things if you define some methods)
<|3b|> so you can just use that to initialize it
<|3b|> rather than interacting with slots directly
varjag has quit [Ping timeout: 268 seconds]
<jasom> emaczen: if this isn't for didactic purposes, basic-binary-ipc does most of this already (though IIRC it's missing ipv6 support)
<|3b|> note the nested (s-addr 0) works fine
<emaczen> |3b|: You are using the byte offsets?
<jasom> and if this is for didactic purposes, pick a library less annoying than BSD sockets to work with.
<|3b|> aside from the sin-zero slot, i'm letting cffi translate it entirely from a plist
<|3b|> no offsets or anything
<jasom> If you look up "cruft" in the dictionary there is a picture of the BSD sockets API.
<|3b|> other part that i do differently is to try to avoid manual pointer allocation and passing them around between functions, since that is a good way to get leaks :)
<|3b|> if possible, use cffi:with-... macros, and keep things in lisp forms outside of those, unless performance or something requires you to keep pointers around for longer times
<jasom> oh, but don't use cffi:with- macros for large allocations since SBCL unconditionally stack allocates those (boo!)
<emaczen> what was wrong with my code?
<|3b|> ouch :/
* jasom has a with-foreign-heap-alloc macro in several files
<|3b|> emaczen: from your definition, the sin-addr struct is included directly in sockaddr-t, so you can't set it with a pointer
<|3b|> so allocating a pointer to store there is wrong and will leak the way you used it
<emaczen> what is sockaddr-t?
<|3b|> sorry, -in
<|3b|> just a sec, i'll try to debug it a bit so i can give a concrete answer
lemoinem has quit [Killed (verne.freenode.net (Nickname regained by services))]
lemoinem has joined #lisp
<emaczen> Why can't I allocate a pointer there and then dereference it?
<emaczen> You are talking about the (setf sin-addr ...) form right?
<|3b|> well, you can, but it is silly, and nothing will free it
<|3b|> also i think you ran into one of the bad spots of cffi API :/
<|3b|> yeah, not sure you can actually set that slot properly :/
kajo has quit [Ping timeout: 252 seconds]
<emaczen> |3b|: So whose fault is it?
<|3b|> ok, apparently cffi does require you to alloc some foreign memory just so it can copy that to some other foreign memory :/
Bike has joined #lisp
* |3b| would write a function to fill it rather than allocate, since as mentioned before i don't like passing pointers around :p
<|3b|> and setf mem-ref is enough to fill in-addr, since it is simple
LiamH has quit [Quit: Leaving.]
<|3b|> or without extra allocations (but with extra verbosity) https://gist.github.com/3b/fa74e58f3bf297ee8cd95010b54141bd#gistcomment-2722453
<|3b|> which gets a pointer to the struct in-addr inside the sockaddr-in, and sets the slot on that directly
<|3b|> but i think if i were wrapping that, i'd define translators so i could just set/read the whole struct at once with mem-ref and (setf mem-ref)
<emaczen> |3b|: Can you give me a clearer synopsis?
Bike is now known as orangegluon
<emaczen> I still just don't understand why my original code won't work? Why can't I allocate and then dereference in that location?
orangegluon is now known as orangehiggsboson
<emaczen> And whose fault is it that I can't do that?
<|3b|> you don't want to dereference
robotoad has quit [Quit: robotoad]
<|3b|> you shouldn't need to allocate, it is cffi's fault you need to
<emaczen> |3b|: why? the struct def wants the struct not the pointer?
<|3b|> sec, let me check man page to make sure your defs are right
<pjb> emaczen: sin-addr is a variable length field.
<emaczen> pjb: Where do you get that from? structin_addr sin_addr; <-- is the definition from in.h
<pjb> I wouldn't use high level cffi to manipulate sockaddr-in…
<|3b|> the way you defined it (which looks right), the memory for the in-addr struct is contained in the sockaddr-in… struct. it doesn't store a pointer
orangehiggsboson is now known as Bike
<|3b|> so the memory for sockaddr-in looks like aabbccccdddddddd where aa is sin_family, bb is sin_port, cccc is sin_addr.s_addr
<|3b|> so in C, you would just do foo.sin_addr.sin_addr = address; without any extra allocation
<emaczen> |3b|:
<emaczen> Yes
<|3b|> cffi's api for nested structs/arrays is broken though, so depending on the context it does various confusing and/or broken things :/
<|3b|> just very verbose
<|3b|> something like (&(foo.sin_addr))->sin_addr = address; if i can remember C at all
<|3b|> and really, foo->sin_addr too, since we can't have foo as a local in cffi, so we need to store it as a pointer
<|3b|> but it does the same thing as the c code :p
<|3b|> so for this specific part of the brokenness, cffi by default dereferences a pointer to a struct as a plist
<pjb> Usually, it's better to just use memref and compute the offset yourself.
<|3b|> and you can use (setf mem-ref) to assign that plist back to the struct
<pjb> Notably for #pragma pack is not dealt with by cffi, but other complex structures may need it too.
<|3b|> so we can do (cffi:with-foreign-object (s '(:struct in-addr)) (list (cffi:mem-ref s '(:struct in-addr)) (setf (cffi:mem-ref s '(:struct in-addr)) '(s-addr 12345)) (cffi:mem-ref s '(:struct in-addr))))
<|3b|> and get something like ((S-ADDR 4098117524) (S-ADDR 12345) (S-ADDR 12345))
<|3b|> that part is reasonable and convenient
<|3b|> unfortunately, when you have a nested struct or array, it returns a pointer to that member when you do mem-ref
<|3b|> sorry, those are both wrong
<|3b|> when you have a nested struct, it returns a nested plist, and nested array returns a nested array
<emaczen> |3b|: I tried your verbose code
<|3b|> when you have a :count foo field, it returns a pointer
<emaczen> (cffi:foreign-slot-value ptr '(:struct sockaddr-in) 'sin-addr) --> (s-addr 0)
<emaczen> Why is it returning a list?
<|3b|> thats what i said about returning a plist when you dereference a struct
<|3b|> and when you try to assign to a struct with nested struct, nested plist works. but nested array doesn't, nor for :count
<emaczen> |3b|: Okay, so this is all cffi fault?
<|3b|> and as you see, foreign-slot-value returns a plist for nested struct, but you can't assign a plist to it
<|3b|> it is cffi's fault i can't give you a nice answer easily :)
<emaczen> What is the solution? I'm starting to understand, but it is really messed up...
myrmidon has quit [Quit: leaving]
<|3b|> and responding to what pjb said, i'd still use the high-level API, but specify offsets in the structure definition if the cffi defaults were incorrect
<|3b|> (possibly using a groveller for APIs where struct layouts might be different on every platform)
edgar-rft has joined #lisp
<|3b|> emaczen: https://gist.github.com/3b/179ef479250186f1a96b47d03339701d is probably how i'd start
<|3b|> the translate-into-foreign-memory is close to what cffi would make on its own, but with custom defaults
<|3b|> and with working assignment to whole thing
<|3b|> (i think)
* |3b| is starting to get confused too :/
<emaczen> Is CFFI supposed to return plists for nested structs?
<emaczen> I'm just trying to make sure that I have correct field values since I get an invalid argument error when I try to call bind
r1b has joined #lisp
<|3b|> i think returning nested plist for nested struct is correct
siraben has quit [Ping timeout: 240 seconds]
<|3b|> what does your current code look like?
<emaczen> I just reverted back to what I had before without the mem-ref and (cffi:foreign-slot-value addr '(:struct sockaddr-in) 'sin-addr) --> (s-addr 0)
<|3b|> whole thing, including the call to bind
kslt1 has joined #lisp
<emaczen> Is the '(s-addr 0) just for lisp? How would C code use sin-addr if it is a cons?
<|3b|> just for lisp
<|3b|> C is just seeing the 0
<emaczen> |3b|: Well in that case, the only problem I really had was the mem-ref
<|3b|> and the memory leak? :)
<emaczen> Why can't I free it now?
<|3b|> where is the pointer to it?
<emaczen> (setf sin-addr (make-in-addr addresss)) -- can't I free sin-addr?
<emaczen> |3b|: Oh I see
<emaczen> I guess I don't really have the pointer...
<|3b|> sin-addr isn't really a pointer
<emaczen> |3b|: Okay, I'll use with-foreign-object then
<emaczen> but in terms of bind I've just been trying to use the REPL to make a socket, create a sockaddr-in and then bind them
<jasom> might be easier to use getaddrinfo and treat the sockaddr structs as black-boxes, FWIW
robotoad has joined #lisp
dale has quit [Quit: dale]
warweasle has joined #lisp
nowolfer has quit [Ping timeout: 260 seconds]
rumbler31 has quit [Remote host closed the connection]
<jasom> note that it gets the struct sockaddr_in definition via the groveller.
<jasom> because that's the only portable way to do it.
nowolfer has joined #lisp
dented42 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Copenhagen_Bram has joined #lisp
dented42 has joined #lisp
dented42 has quit [Client Quit]