ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Picolisp latest found at http://www.software-lab.de/down.html | check also http://www.picolisp.com for more information
PurpleMessenger[ has left #picolisp ["Kicked by @appservice-irc:matrix.org : removing from IRC because user idle on matrix for 30+ days"]
brandelune has joined #picolisp
<brandelune> good morning
brandelune has quit [Quit: This computer has gone to sleep]
karswell_ has joined #picolisp
karswell has quit [Ping timeout: 240 seconds]
orivej has quit [Ping timeout: 248 seconds]
<tankf33der> hi
<tankf33der> how is better check if first 5 elements of list is 0?
<Regenaxer> Hi tankf33der!
<Regenaxer> interesting question
<Regenaxer> (fully =0 (head 5 Lst)) ?
<Regenaxer> not sure
<Regenaxer> I'd prefer to avoid the 'head'
<Regenaxer> as it copies elements just for a check
<tankf33der> ok
<Regenaxer> You see a better way?
<tankf33der> maybe via mappings, i will try and show
<Regenaxer> ok
<Regenaxer> or (do 5 (NIL (=0 (++ L))) T)
<tankf33der> yea
alexshendi has quit [Read error: Connection reset by peer]
<Regenaxer> afp
orivej has joined #picolisp
alexshendi has joined #picolisp
freeemint has joined #picolisp
orivej has quit [Ping timeout: 248 seconds]
aw- has joined #picolisp
<aw-> hi all
dtornabene has joined #picolisp
<Regenaxer> ret
<Regenaxer> Hi aw-!
<aw-> hi
<aw-> Regenaxer: why do you hate CL?
<Regenaxer> It is too bloated
<Regenaxer> and clumsy in terms of semantics and syntax
<aw-> it looks similar
<aw-> from a quick glance i can't tell what's wrong with it :\
<Regenaxer> yes, looks
<Regenaxer> cause of the parens
<Regenaxer> You must try to use it in praxis to get a feeling
<aw-> ok i see
<Regenaxer> or compare solutions in rosettacode.org
<aw-> unrelated, i have an issue with (native)
<Regenaxer> ok
<aw-> I'm trying to do this C equivalent in Pil: open("filename", O_RDWR|O_CREAT|O_EXCL, 0400) ..
<aw-> or something like that
<aw-> (native "@" "open" 'I "alex.test" (| (hex "0002") (hex "0100") (hex "0200")) (hex "0400"))
<aw-> always returns -1
<Regenaxer> Are the constants correct?
<aw-> i looked in the headers on my arm64 machine, and O_RDWR = 0x0002, O_CREAT = 0x0100, O_EXCL = 0x0200
<Regenaxer> ok, good
<aw-> yes i think they are correct
<aw-> not 100% certain
<Regenaxer> hmm, looks good
<Regenaxer> What does (errno) return?
<Regenaxer> : (native "@" "strerror" 'S (errno))
<aw-> hmmm
<aw-> (native "@" "strerror" 'S (errno))
<aw-> -> "No such file or directory"
<Regenaxer> Then O_CREAT must be wrong
<aw-> haha i didn't know about (errno)
<tankf33der> i can try help with native tomorrow
<Regenaxer> You can look into the defs.l file
<aw-> aarch64-linux-gnu/bits/fcntl-linux.h:# define O_CREAT 0100/* Not fcntl. */
<aw-> one sec
<Regenaxer> eg src64/sys/arm64.linux.defs.l says src64/sys/arm64.linux.defs.l
<tankf33der> i'm interested in any native experience
<Regenaxer> ah!
<aw-> what am I looking for?
<Regenaxer> I know
<Regenaxer> you wrote 'hex' but have octals in the strings
<aw-> yes
<aw-> oh
<aw-> those are octal?
<aw-> hahahaa oops
<Regenaxer> 0100 octal is 64
<Regenaxer> above I did a wrong paste
<Regenaxer> wanted to write:
<Regenaxer> eg src64/sys/arm64.linux.defs.l says (equ O_CREAT 64)
<aw-> ahh you're right! it works now
<Regenaxer> So either pass 64 or (oct "0100")
<Regenaxer> :)
<aw-> sweeeet
<aw-> yes i did that
<aw-> (native "@" "open" 'I "alex.test" (| (oct "0002") (oct "0100") (oct "0200")) (oct "0400"))
<Regenaxer> I find it rather inconvenient that C and also bash and vim still carry that legacy octal stuff
<Regenaxer> In vip I changed that
<aw-> so this creates a file atomically
<Regenaxer> Incrementing 07 gives 08 and not 010
<aw-> if you run the same command again, it returns -1
<aw-> how can I get the value of O_CREAT from defs.l ?
<Regenaxer> (equ O_CREAT 64)
<Regenaxer> or run src64/sysdefs
<Regenaxer> on the target machine
<aw-> i dont have that
<Regenaxer> (cd src64; make sysdefs)
<aw-> got it
<Regenaxer> emu builds it implicitly
<aw-> (call "@lib/../src64/sysdefs")
<Regenaxer> why the ..?
<aw-> hmm
<Regenaxer> (call "@src64/sysdefs")
<aw-> i don't understand the (equ)
<aw-> yes my bad
<Regenaxer> It is traditional asm syntax
<Regenaxer> an assignment
<aw-> how do I get the value of O_CREAT after running sysdefs?
<Regenaxer> sysdefs should output all to stdout
<aw-> yes i saw that
<aw-> oh, i should parse it?
<Regenaxer> you could (load "@src64/sysdefs") but then you get *all*
<Regenaxer> oops, no
<aw-> hmmm
<Regenaxer> (load '("@src64/sysdefs"))
<Regenaxer> does this work?
<Regenaxer> ie load from a pipe
<Regenaxer> The the value of O_CREAT will be 64 or whatever
<aw-> hmmm doesnt work
<aw-> can't i just define (equ) and then (load "@src64/sysdefs") ?
<Regenaxer> I don't have a sysdefs here atm
<Regenaxer> ah, right, 'emu' is defined in the asm sources
<Regenaxer> (load "@src64/lib/asm.l" '("@src64/sysdefs"))
<aw-> hmmm ok
<aw-> seems a bit excessive
<Regenaxer> tested, pipe in 'load' works
<aw-> yes it works
<aw-> : O_CREAT
<aw-> -> 64
<Regenaxer> yes, so just do (setq O_CREAT 64) :)
<aw-> but that's platform specific
<Regenaxer> or (in '("@src64/sysdefs") (from "O_CREAT") (read))
<Regenaxer> I tried:
<Regenaxer> : (in "@src64/sys/arm64.android.defs.l" (from "O_CREAT") (read))
<Regenaxer> -> 64
<Regenaxer> So the pipe should work too
<aw-> oh yeah
<aw-> that's probably better
<Regenaxer> I think this is the best way
<aw-> (in '("@src64/sysdefs") (from "O_CREAT") (read)) <-- works well
<Regenaxer> But you need several of these definitions I presume
<aw-> yes i'll write a function to fetch them
<Regenaxer> you can do several 'from's + 'read's in a row
<Regenaxer> if you observe the right order
<aw-> yeah that's a bit difficult to predict
<Regenaxer> The order won't change, it is coded in sysdefs.c
<aw-> i'd rather just run (in '("@src64/sysdefs") (from "O_CREAT") (read)) multiple times at the top of my script
<aw-> with different constants
<aw-> (setq
<aw-> O_CREAT (in '("@src64/sysdefs") (from "O_CREAT") (read))
<aw-> O_RDWR (in '("@src64/sysdefs") (from "O_RDWR") (read)) )
<aw-> O_EXCL (in '("@src64/sysdefs") (from "O_EXCL") (read))
<Regenaxer> yes, it just feels bad to read the same file so many times
<aw-> oh right
<aw-> hmmm
<Regenaxer> I think the order wont change
<aw-> well in that case I can load them all with asm.l as you showed earlier
<Regenaxer> it is the same in the */defs.l files
<Regenaxer> yeah, but that's even more overhead I think
<aw-> perhaps yes, but **if** the order changes then my code breaks and it'll take me a week to figure out why
<Regenaxer> asm.l is not small an builds a lot of data structures
<Regenaxer> you could put an 'assert'
<Regenaxer> if all values are numeric
<Regenaxer> If the order would change, then at least one of the values will be NIL
<Regenaxer> you just check (from)
<aw-> ok wait
<Regenaxer> (setq SYM (or (from "SYM") (quit "Erroorrrrrr!"]
<aw-> perhaps i can just (in ... (while .. with a (cond) ?
<Regenaxer> not needed
<Regenaxer> (setq SYM (if (from "SYM") (read) (quit "Erroorrrrrr!"]
<Regenaxer> That should suffice
<aw-> why quit?
<aw-> i can't do that in my code it's horrible
<Regenaxer> 'quit' is an error
<aw-> yes i don't want to throw an error
<Regenaxer> *the* error handler in pil
<Regenaxer> But what will you do then if you don't trust sysdefs?
<Regenaxer> The value could be missing
<aw-> i trust it, i don't want to rely on the ordering in the file
<Regenaxer> if the order can change
<aw-> yes but it's much easier to track down an error from a missing value, than an error from a value that was moved up 2 lines
<Regenaxer> if the order changes, unneeded symbols might be as well deleted
<Regenaxer> no, the same
<Regenaxer> (setq SYM (if (from "SYM") (read) (quit "Erroorrrrrr!"]
<Regenaxer> this will give an error if the order was changed
<Regenaxer> because it will be skipped
<aw-> ok
<Regenaxer> or, you make your own (short) version of sysdefs.c
<Regenaxer> The point is only that C is needed to parse the includes
<Regenaxer> There is perhaps a simpler way
<Regenaxer> gcc has an option to only preprocess
<Regenaxer> I forgot
<Regenaxer> and you can supply a single C line via a pipe
<aw-> hmmm
<Regenaxer> so you send #define A O_CREAT to gcc
<aw-> i think simplest is better
<Regenaxer> and read the output line
<aw-> i only wanted to do one little thing
<aw-> this is getting too complex
<Regenaxer> yes
<Regenaxer> it is a one-liner in Pil
<aw-> my code is a one-liner
<aw-> i will just hardcode the values of O_CREAT, O_RDWR, O_EXCL for now
<Regenaxer> ok, but this is worse than relying on the order in sysdefs
<aw-> on Linux the values are all the same anyways
<Regenaxer> yeah
<Regenaxer> true
<aw-> and my code isn't written to run on freebsd/openbsd so it's fine
<aw-> anyways, thanks for your help
<aw-> the octal thing tripped me up
<Regenaxer> :)
<aw-> it's nice to see the flags in sysdefs though
<aw-> it will be helpful for future (native) things which require those
<aw-> i swear i spent maybe 3 hours yesterday trying/failing with this :(
<Regenaxer> oh ;)
<Regenaxer> As I said, this octal legacy stuff from PDP11 is nonsense today
<Regenaxer> nobody needs octal any more
<Regenaxer> But in C or bash or vim a leading zero goes in the way always
<aw-> yeah
<aw-> i have a cold too, so difficult to focus :\
<Regenaxer> oh
<aw-> ok i will go home for the day, continue tomorrow hopefully if i'm better.
<aw-> thanks again!
<Regenaxer> Take care!
aw- has quit [Quit: Leaving.]
dtornabene has quit [Ping timeout: 260 seconds]
freeemint has quit [Quit: Leaving]
alexshendi has quit [Ping timeout: 268 seconds]
brandelune has joined #picolisp
orivej has joined #picolisp
michelp has quit []
michelp has joined #picolisp
brandelune has quit [Quit: This computer has gone to sleep]
libertas has quit [Quit: Lost terminal]
libertas has joined #picolisp
alexshendi has joined #picolisp
alexshendi has quit [Ping timeout: 276 seconds]
DerGuteMoritz has quit [Ping timeout: 260 seconds]
DerGuteMoritz has joined #picolisp
jibanes has quit [*.net *.split]
viaken has quit [*.net *.split]
viaken has joined #picolisp
jibanes has joined #picolisp
joebo has quit [Ping timeout: 260 seconds]
joebo has joined #picolisp
shpx has joined #picolisp
shpx has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shpx has joined #picolisp