beneroth changed the topic of #picolisp to: PicoLisp language | The scalpel of software development | Channel Log: https://libera.irclog.whitequark.org/picolisp | Check www.picolisp.com for more information
geri has joined #picolisp
<geri> hey, im trying to translate https://0x0.st/XP2E.c into picolisp rn; here's what i've got so far: https://0x0.st/XP2E.c
<geri> do i gotta go into the code defining sockaddr_un and see the sizes of sun_family and sun_path to make a struct in pil?
<geri> that's what i did for AF_UNIX but i might be stupid :D
<geri> (also gotta check if i can reuse pil's network builtins with sockfd created like that)
<geri> (following native C calls docs but kinda poorly haha)
<abu[7]> Yeaa, it is tough ;)
<geri> it also trips me up that structs in pil seem to not indicate the name of the variable but be positional or somehting
<abu[7]> "what i've got so far" is wrong paste
<abu[7]> T, just offsets
<abu[7]> as in C
<geri> my bad
<geri> (i forgot an 'I in socket call
<geri> )
<abu[7]> You are on the right way
<geri> now just gotta figure out the struct and connect() part
<geri> actually the struct is only used once, could say "only the connect() part"
<abu[7]> You could build a 'sysdefs' for the proper offsets
<geri> like write my own @lib/sysdefs? 🤔
<abu[7]> Not in @lib
<geri> like an ini-style file with definitions
<abu[7]> You can pass your own as the second arg to 'sysdefs'
<geri> oh cool
<abu[7]> compile @src/sysdefs.c
<abu[7]> Unfortunately Makefile does not preserve it
<abu[7]> It should better keep it in @bin/sysdefs
<geri> oh, that's how lib/sysdefs comes to be?
<abu[7]> T
<geri> so the idea is i declare my struct in a C file and extract it using builtins?
<abu[7]> I will change Makefile
<abu[7]> Yes
<geri> nasty, but let's try
<geri> :D
<abu[7]> It just needs a *.h file
<abu[7]> Hmm
<abu[7]> but this is not included by sysdefs.c then
<abu[7]> So a general sysdef is not possible this way
<abu[7]> You need your own sysdefs.c
<abu[7]> That's why Makefile removes it ;)
<geri> i'm confused but okay :D
<abu[7]> Yeah, overkill
<abu[7]> Your way with setq is OK
<abu[7]> or 'de'
<geri> wait, there's a connect builtin
<geri> lets see...
<geri> what does let do if you give it uneven amount of args?
<geri> like let in (vi 'connect)
<abu[7]> The last sym is bound to NIL
<geri> wouldn't it anyway be interned as nil?
<geri> i don't understand why it's getting "declared"
<abu[7]> Yes, but it may already be interned and bound
<geri> so you ensure its unset just in case?
<abu[7]> Not unset, but bound to NIL
<geri> i meant that yes
<abu[7]> You could use 'use' here
<abu[7]> The value NIL of Sd is never used here
<abu[7]> It is set in the loop
<abu[7]> But (use Sd ..) is longer ;)
<geri> how is use different from let
<abu[7]> (use X (setq X 7) is equivalent to (let X 7
<abu[7]> 'let' saves AND binds
<geri> why does it exist then 🤔
<abu[7]> (use (A B C) is needed sometimes
<abu[7]> You often need use local variables which are bound later
<abu[7]> *need to
<geri> so syntactic sugar, got it :D
<abu[7]> 'let' is just a convenience
<abu[7]> 'let' is syntactic sugar, yes
<abu[7]> 'use' is the "real" thing
<geri> very bizzare :D
<geri> okay, brb in 10-30 minutes
<abu[7]> ☺/
beneroth_ has quit [Quit: Leaving]
beneroth has joined #picolisp
<geri> (or way more)
<geri> :D
<abu[7]> No worries :)
<abu[7]> )
<abu[7]> upsi
<geri> okay so C says my struct's size is 110...
<geri> (of god knows what)
<geri> 2 for the family and 108 for path...
<geri> doesn't do anything :D
<geri> msg has to end with newline to be processed, forgetting that is usually why my stuff breaks
<geri> but it seems to be there
<abu[7]> why not *call* (msg ...)?
<abu[7]> or (out sockfd ...
<geri> im just translating literally
<geri> instead of write?
<abu[7]> ok
<abu[7]> T
<geri> bad fd
<geri> hmm
<geri> so probably something before then is still broken
mario-goulart has quit [Remote host closed the connection]
mario-goulart has joined #picolisp
geri has quit [Remote host closed the connection]
Iacob has quit [Quit: IRCNow and Forever!]
Iacob has joined #picolisp
Iacob has quit [Remote host closed the connection]
Iacob has joined #picolisp
Iacob has quit [Remote host closed the connection]
Iacob has joined #picolisp