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
clacke has quit [Remote host closed the connection]
clacke has joined #picolisp
razzy has joined #picolisp
kuao has quit [Quit: Connection closed for inactivity]
razzy has quit [Ping timeout: 268 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 250 seconds]
razzy has joined #picolisp
mario-go` has joined #picolisp
inara` has joined #picolisp
m42e has joined #picolisp
inara has quit [Ping timeout: 260 seconds]
clacke has quit [Ping timeout: 260 seconds]
mabi has quit [Ping timeout: 260 seconds]
mario-goulart has quit [Ping timeout: 260 seconds]
razzy has quit [Quit: Lost terminal]
schulze has joined #picolisp
aw- has quit [Quit: Leaving.]
Hunar has joined #picolisp
<Hunar> Hello Regenaxer :) I needed to pass varargs to native, there was only two so i didn't bother modifying clang.l this time.. I used something like this instead   (de pf (A . @) (apply '%@ (make (link "printf") (link NIL) (link A) (while (args) (link (next))))))    I just wanted to make sure that there isn't an official way for varargs in native
<Hunar> calls right?
<Regenaxer> Not sure. The only varargs function I tried is printf()
<Regenaxer> (native "@" "printf" 'I "abc%d%s^J" (+ 3 4) (pack "X" "Y" "Z"))
<Regenaxer> abc7XYZ
<Regenaxer> -> 8
<Regenaxer> Don't know where the limits are
<Regenaxer> Or do you ask for the Lisp-side?
<Regenaxer> not the 'native' call per se?
<Regenaxer> On Lisp you use 'pass' normally for such cases
<Hunar> Ah, you told me that and I forgot again
<Regenaxer> (de pf (A . @) (pass native "printf" 'I))
<Regenaxer> without 'A'
<Regenaxer> (de pf @ (pass native "printf" 'I))
<Regenaxer> lib is missing of course
<Hunar> I think there is a bug
<Regenaxer> : (de pf @ (pass native "@" "printf" 'I))
<Regenaxer> -> pf
<Regenaxer> : (pf "ab %d cd\n" (* 3 4))
<Regenaxer> ab 12 cd
<Regenaxer> -> 9
<Hunar> start a new pil repl .. paste that function .. call it with (pf "%d %d\n" 1 2)  it works    ... close it and reopen a pil repl, paste the function again then call it with (pf "%d\n" 1)  it prints 1 but now change the call to (pf "%d %d\n" 1 2) now it prints 1 0    the second number isn't passed for some reason
<Regenaxer> That's what I meant "on the 'native' side
<Regenaxer> There is something cached
<Regenaxer> The ffi structures are built once and reused
<Regenaxer> you need (de pf1 and (de pf2
<Regenaxer> I think there is true varargs support in libffi but pil does not interface to it
<Regenaxer> no syntax for that
<Regenaxer> I forgot the internals of libffi
<Regenaxer> in pil64 this was not a problem, it did not use libffi
<Hunar> I needed it for this raylib function      RLAPI void TraceLog(int logLevel, const char *text, ...);     I don't think I can define multiple functions since I don't even know how this function is going to be used
<Regenaxer> ffi_prep_cif_var must be used instead of ffi_prep_cif
<Regenaxer> Ugly solution: (de pf (A B C D E F G) (native "@" "printf" 'I A B C D E F G))
<Regenaxer> Very ugly ;)
<Hunar> This cheat will solve the issue for most cases (de pf (A B C D E F G H) (%@ "printf" 'I A B C D E F G H))  but that only works for printf i think
<Hunar> We thought the same :)
<Regenaxer> indeed
<Regenaxer> Even the same symbols almost
<Hunar> but in this case the first argument determines how many arguments it should use, in case of TraceLog I don't know if it would work
<Regenaxer> Vararg functions generally ignore additional arguments
<Hunar> :)
<Regenaxer> Because the *first* arg determines at how many to look at
<Regenaxer> The disadvantage is using more stack space
<Hunar> I'll go with it then, in the future people can make an issue on github if they needed a better implementation.. I have 900+ lines to bind :) lets not waste time
<Regenaxer> yeah :)
<Regenaxer> One other possibility is to dispatch on the Lisp side *before* calling native
<Regenaxer> hmm, no, forget it
mario-go` is now known as mario-goulart
<Hunar> :)
<Regenaxer> Needs many glue functions, and a dispatch on the Lisp side
<Regenaxer> it is even more inefficient
mario-goulart has quit [Changing host]
mario-goulart has joined #picolisp
<Hunar> One general question, should language bindings have comments? I'm currently keeping all the comments from the original raylib.h which made the lines veeery wide, should i just redirect the users to the original file?
<Regenaxer> This is general, yes. I personally dislike comments if they disturb the read flow
<Regenaxer> So I would rather point to the original sources
<Hunar> Let me give you an example   I really hate it   https://ibb.co/DKCPwjn
<Regenaxer> yes, that's too long
<Regenaxer> (I have only 48 colums in my terminal! ;)
<Hunar> Ah, so even the code wouldn't fit
<Regenaxer> yes :(
<Regenaxer> Vip can scroll horizontally relatively comhortable though
<Hunar> I'll gladly delete all the comments .. it's raylib's fault that the names are all too long
<Regenaxer> But now as you already wrote it, I would keep it
<Hunar> I didn't write it, just copied the whole line and prepended the binding code
<Regenaxer> ok :)
Hunar94 has joined #picolisp
Hunar has quit [Ping timeout: 256 seconds]
Hunar94 is now known as Hunar
<Hunar> One more question.. back at university we had a program that used input files for some calculation.. some numbers in it were tedious to edit and run each time, so I made a python script to create the file but change some parts to a python variable then ran the program .. what is the equivalent of that in pil? I need something similar to what (here)
<Hunar> does but while still letting me have parts of it be a pil variable then create a file with it.. the (call) part is easy
<Regenaxer> It is a file with many data items, but *some* should be variables?
<Hunar> yes
<Regenaxer> with the values in the end?
<Hunar> let me give you the actual code :)
<Regenaxer> You could just 'eval' the 'read' items
<Regenaxer> (make (while (read) (link (eval @))))
<Regenaxer> The file has arbitrary s-expressiosn
<Regenaxer> Most are numbers
<Regenaxer> but may as well be symbols or complicated expressions
<Regenaxer> The above 'make' gives you a list of values
<Regenaxer> http://ix.io/3Gcs
<Regenaxer> 'load'ing this file gives -> (9 8 1 7 6 12 5 2 4 3)
<Regenaxer> So you write the variable values on *top*
<Hunar> http://ix.io/3Gcr  this is one of the calculation files that i made .. the input file has to be inside the .l file, like this file.. the input start at line 9 after f'''  .. and at line 51 there is {length} which is replaced by python before creating a file out of it
<Hunar> Ah your code is great :) but can I write normal code again after it?
<Regenaxer> yes, if you put a NIL
<Regenaxer> after the data
<Regenaxer> NIL and also EOF return NIL in (read)
<Regenaxer> You can also put comments of course
<Regenaxer> # ... or #{...}#
<Hunar> THAT'S GREAT :D how can I print it to a file, will the text structure be preserved?
<Regenaxer> You mean if you have some template file?
<Hunar> I want the input file to be inside the .l file without changing anything, and be printed to a file also untouched in terms of its shape
<Hunar> the only difference to be that some part of it is now different
<Regenaxer> You need only the input file, no need to create another file
<Regenaxer> (make (read) ... 1 2 3 NIL (further Lisp code) ...
<Regenaxer> (setq *Data (make (while (read) ...))) 1 2 3 NIL (further Lisp code) ...
<Regenaxer> further Lisp code may use data
<Regenaxer> or you put all logic on top and all data in the end
<Regenaxer> must stop, bbl
<Hunar> Sorry it's too late :( .. I'll logout after sending the message, read the message tomorrow :) ...  Let me create a very tiny example suppose I have a bash script file that I must use $bash file.sh     to run it .. it contains    echo 3        I want a lisp program to have the bash script within it, then change the number 3 to 4 5 6
<Hunar> etc, while each time creating a file file.sh and run it (call "bash" "file.sh") .. the file creation is needed because there is a physics simulation package that requires a file with a specific name and structure .. It's literally how clang.l makes the .c file but the difference is that I want some parts to be lisp variables
Hunar has quit [Quit: Client closed]
schulze has quit [Quit: nyaa~]
<Regenaxer> ret
<Regenaxer> To "edit" a file, i.e. replace patterns within it, I often used (while (echo "pat1" "pat2" ..) )
<Regenaxer> It is always the same pattern
<Regenaxer> I find many cases in my sources, here two snippets from arbitrary projects: http://ix.io/3GcS
<Regenaxer> 'echo' in a while loop with a matching 'case'
<Regenaxer> This is very fast, because 'echo' is a tight loiop
<Regenaxer> This pattern in general replaces tokens in a stream
<Regenaxer> Lets think about it tomorrow. I stop for today
<Regenaxer> お休み
kuao has joined #picolisp