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
aw- has joined #picolisp
aw- has quit [Quit: Leaving.]
aw- has joined #picolisp
clacke has joined #picolisp
Hunar has joined #picolisp
<Hunar> Hello :)   ... I have two small questions .. one from rosetta code which says  "PicoLisp has no specific word size. Numbers grow to arbitrary length. Therefore, bitwise NOT, logical (non-arithmetic) SHIFTs, and rotate operations do not make sense" so what should I do to flip the 1s and 0s of a number? or I'll probably never need it :)
<aw-> hunar: hi :)
<Hunar> ‌Hello aw- :)
<razzy> Good morning i wish to all!
<Hunar> Good morning razzy :)
<Regenaxer> Hi hunar, aw-!
<Regenaxer> you can fill, but must decide some word size
<Regenaxer> e.g. 64 bits
<Hunar> Ah, ok .. I'll play with it to see how it goes :)
<Hunar> Second question is this.. (setq V 'A) now this is true (= V 'A) but this is false (= V A) But if i use (case) it's the other way around (case V ('A (prinl "true"))) returns NIL, but this returs true (case V (A (prinl "true")))
<Regenaxer> (case V ('A is not meaningful
<Regenaxer> 'case' does not evaluate the clauses
<Regenaxer> it uses '=='
<Hunar> Ahaa, I see :)
<Regenaxer> You must remember that 'A is actually (quote . A)
<Regenaxer> so it compares with 'quote'
<Hunar> Thanks :D
<Regenaxer> :)
<Regenaxer> 'case' accept lists:
<Regenaxer> : (case 2 ((1 2 3) 'OK))
<Regenaxer> -> OK
<Regenaxer> so if the item is a 'member', it fires
<Regenaxer> thus (case 'quote ('A would fire
<Regenaxer> : (case 'quote ('A 'OK))
<Regenaxer> -> OK
<Regenaxer> $: (case 'qute ('A 'OK))
<Regenaxer> -> NIL
<razzy> I want to change database layout (Classes and relations) after I have data in. Is there recommended way? any problems?
<Regenaxer> It depends. Some changes are simple, some need to change or rebuild the DB
<Regenaxer> *Adding* a new relation is never a problem
<Regenaxer> only the size may get larger
<razzy> Thank you. rebuild means exporting all data, modifying data, changing layout importing all data?
<Regenaxer> not necessarily
<Regenaxer> write a program which transforms it
<Regenaxer> depends very much on the situation
<Regenaxer> Sometimes it is easier to make a new rel, then del the old
<razzy> so, make new layout, transform old into new, test new, delete old
<Regenaxer> (for This (list of objects) (put> This 'new (: old)) (put> This 'old))
<Regenaxer> 'forall' is also good
<razzy> I like it. Thank you
<Regenaxer> :)
<Regenaxer> If only the type of index changed, 'rebuild' is enough
<razzy> Regenaxer: what rebuild means?
<Regenaxer> The function
<Regenaxer> @lib/too.l
<Regenaxer> During development I always load that file
<Regenaxer> on the command line
<Regenaxer> I think I fixed the form.js problem yesterday
<Regenaxer> Simplified
<razzy> i will look at too.l
<Regenaxer> not sure if it breaks somewhere else now
<razzy> Regenaxer: cool, i was thinking about your bug
<Regenaxer> thanks!
<razzy> I bet your younger self had reason to write it in a way it was.
<Regenaxer> looks like
<Regenaxer> But it was wrong anyway, Some other changes since then broke it
<Regenaxer> So this was probably never used
<razzy> :]
<Hunar> What name should I give to my picolisp binding for the raylib library :)  I have PicoRay  and  PicoRaylib in mind .. here are all the "50+" other language bindings for it for inspiration https://github.com/raysan5/raylib/blob/master/BINDINGS.md
<Regenaxer> Cool names! :)
<Regenaxer> pilrays? or raypils?
<Regenaxer> or should the name contain some "lib"?
<Hunar> I'm not sure, since the library itself isn't related to rays that much
<Hunar> but someone called dray for the D language so I think we can ignore lib if we want :)
<Regenaxer> true
<Hunar> Java is jaylib, maybe we call it Paylib :D
<Regenaxer> I think just P is not enough
<Hunar> I'll wait 24 hours to see everyone's suggestion :)
<Regenaxer> good idea!
<Hunar> Yeah, you're right
<Regenaxer> people think of python
<Hunar> yeah,   I just saw python it's pyraylib ..   do you like capital letters in names? like you said pilrays instead of PilRays
<Regenaxer> I think for library names all lowercase is better
<Regenaxer> Not sure
<Hunar> I like pilrays alot, but the final 's' came from nowhere, but i like it with the 's'
<Regenaxer> yeah, "rays" sound so powerul
<Regenaxer> ful
alexshendi has joined #picolisp
<Hunar> Regenaxer, it happened again in raylib :/     this time the struct Vector2 holds two floats   typedef struct Vector2 { float x,y; } Vector2;    and the function   DrawCircleV   takes vector by value        RLAPI void DrawCircleV(Vector2 center, float radius, Color color);
v_m_v has joined #picolisp
<alexshendi> I'd have said "Good Morning", except it's slready noon...
<Regenaxer> Two floats fit into 64 bits, right
<Regenaxer> Good nood alexshendi!
<Regenaxer> but floats are hard to build as a number :(
<Hunar> But how to encode floats into (hex)
<Hunar> yeah
<aw-> alexshendi: noon for you, 8:30pm for me ;)
<Regenaxer> Can you print the typedef of Vector2 here?
aw- has left #picolisp [#picolisp]
<Hunar> I did print it above
aw- has joined #picolisp
<Regenaxer> ah, right
<alexshendi> I hear it's always morning when you logon in timezone UGT..,
<Hunar> Oh my god there is this thing      RLAPI void SetShaderValueMatrix(Shader shader, int locIndex, Matrix mat);         which takes Matrix by value, it contains 16 floats
<Regenaxer> Really? Can't believe
<Regenaxer> Isn't Matrix defined as a struct* ?
<alexshendi> What kind of API is that?
<Regenaxer> 16 floats is strange
<Hunar> nope
<alexshendi> hunar: thx
<Hunar> :D
<Regenaxer> Matrix is not defined in that link
<Regenaxer> ?
<Regenaxer> ah
<Regenaxer> found it
<Hunar> line 212
<Regenaxer> T
<Regenaxer> You need a glue libary then
<Hunar> :(
<alexshendi> It is, as a struct, not a pointer to a struct. Also different compilers will pad the struct diffetently
<Regenaxer> I think it is not possible with 'native'
<Regenaxer> not sure if libffi can do it
<Hunar> but, what about other people who did it with libffi, like in the links I gave .. let me get them
<Regenaxer> true
<Regenaxer> Should study the docs of libffi
<Hunar> Cant get the links, libera.irclog.whitequark.org is down
<Hunar> Where are the docs? I couldn't find any
<alexshendi> I think the best way would be to write a small C routine that takes a list of 16 nums, converts them to floats, then fills in the struct.
<Regenaxer> alexshendi, yes, glue functions
<Regenaxer> libffi can do it
<Regenaxer> 2.3.2 Structures
<alexshendi> Then call that fn via native
<Regenaxer> passing structures back and forth
<Hunar> I also had the links somewhere else
<Regenaxer> So libffi can do it, but not supported by Pil
<Hunar> not supported, yet? :)
<Regenaxer> hmm, I don't want to do that
<Regenaxer> needs a whole new syntax
<Regenaxer> Mappig from/to Lisp expressions
<Regenaxer> native is already now very complicated
<Regenaxer> I think no room for that
<Hunar> Would my other in theory trick work? I cant access the log so here is a short version ..   allocating memory then creating a struct with (struct) then hacking  @src/lib.c  and changing ptr in (line 611)   ffi_call(&p->cif, p->fun, &rc, ptr);    to *ptr      to dereference the pointer before sending it, of course only doing this in custom
<Hunar> calls to native
<Regenaxer> This would work, just cannot mix calls to other libs then
<Regenaxer> What about writing a glue lib?
<Regenaxer> Could be on the fly
<Regenaxer> using @lib/clang.l
<Hunar> (What about writing a glue lib?) I want a pure binding   ..... (Could be on the fly) I'm interested to know how but I think the other solution would be more compact and general
<Regenaxer> This does a lot of matrix calculations: https://software-lab.de/rcsim.tgz
<Regenaxer> not 1:1 glues though
<Hunar> I like to learn more because I'll definitely be using it in the future.. but now I want to avoid it :)  too much stuff to learn in parallel .. I'll do some tinkering but will come back for some help in editing @src/lib.c :)
<Regenaxer> ok, good :)
<Regenaxer> Perhaps there could indeed be a *simple* syntax extension
<Regenaxer> like a 'T' somewhere in the struct expression
<Regenaxer> causing some internal on-the-fly glue mechanism
<Hunar> I hope :)   I'll think about some potential syntaxes for my problem
<Regenaxer> (V ... struct ...) now has a ret spec
<Regenaxer> (NIL ... is no ret
<Regenaxer> so (T ... could be a copy
<Hunar> :D  I like where this is going
<Regenaxer> :)
<Regenaxer> it is kind of consistent
<Regenaxer> and it is pil style
<Regenaxer> 'T' being a special value
<Regenaxer> and 'T' should never be a var for the returned struct
v_m_v has quit [Remote host closed the connection]
<Regenaxer> But still difficult I think
<Regenaxer> cause libffi needs detailed info about the structure elements
<Hunar> My edit/hack was kind of funny .. I said if the argument of (native) was 10 then pass *ptr instead of ptr .. then passed some junk input to trigger it
<Regenaxer> :)
<alexshendi> Regenaxer: could you point me to some docs about pilio?
<Regenaxer> I think there is no dedicated doc, but (doc 'pr) and (doc 'rd)
<Regenaxer> A simplified C lib is here https://software-lab.de/plio.tgz
<Regenaxer> A Java version is in PilBox
<Regenaxer> A one-way-only version is in @lib/plio.js
alexshe21 has joined #picolisp
alexshe35 has joined #picolisp
<Regenaxer> alexshe21, I wrote some points about plio, please check the irc log
<Regenaxer> must go, afp
alexshendi has quit [Ping timeout: 260 seconds]
alexshe21 has quit [Ping timeout: 256 seconds]
Hunar has quit [Quit: Client closed]
<alexshe35> Regenaxer: Thx
<aw-> alexshe35: what do you want to know about plio? maybe i can explain some things
alexshendi has joined #picolisp
alexshe35 has quit [Ping timeout: 240 seconds]
aw- has quit [Ping timeout: 268 seconds]
alexshendi has quit [Quit: -a- Connection Timed Out]
alexshendi has joined #picolisp
aw- has joined #picolisp
beneroth has joined #picolisp
Hunar has joined #picolisp
aw- has quit [Ping timeout: 240 seconds]
<Hunar> A quick simple question,  (cut) takes a variable, what function is like cut but takes lists? (cut 3 (1 2 3 4 5))
<Regenaxer> 'head'
<Hunar> Ah thanks, now that you mention it i feel I asked this before :|
<Regenaxer> I do not remember :)
<Regenaxer> probably not yet
alexshendi has quit [Ping timeout: 268 seconds]
alexshendi has joined #picolisp
alexshendi has quit [Ping timeout: 240 seconds]
razzy has quit [Ping timeout: 240 seconds]
<Hunar> I figured out that native only allows upto 8 bytes as an argument, so (hex "FFFFFFFFFFFFFFFF") is the limit, so Vector2 was the limit even if we figured out how to encode floats
<beneroth> probably because the word size is 64 bits
<beneroth> so everything bigger would in picolisp be a bignum (stored in multiple cells, not one single cell), which is not compatible/understandable for the program communicated to with (native)
<Hunar> Ah, I see
<Regenaxer> Thats why I think this lib has a non-C-ish design
<Regenaxer> Pointers are natural in C, because efficient
<Regenaxer> args and return values are the malhine's word size
<Hunar> Regenaxer, I want to have a try at implementing what you thought of, one question... which variable in @src/lib.c  holds the return spec of struct.. I'm searching around line number 590 but I cant find it
<Regenaxer> I think there is none
<Hunar> Oh.. :|
<Regenaxer> a struct is passed by pointer, so the contents are irrelevant to libffi
<Regenaxer> they just must match the callee
<Regenaxer> in case of pil's native in the programmer's head
<Hunar> Sorry just to make sure.. I'm referring to this   '(V (4 I) -4)   (so the car of this list) that we pass as argument in native, you said It can be a variable or NIL.. you are talking about that here right?
<Regenaxer> Passinng structs by value is really bad. The whole memory area needs to be copied each time, instead of passing y pointer in a register
<Regenaxer> yes, exactly
<Regenaxer> V
<Regenaxer> should never be T
<Hunar> :(
<Regenaxer> ('T' would work, but then its value get overwritten)
theruran has quit [Ping timeout: 268 seconds]
<Regenaxer> or is it checked?
razzy has joined #picolisp
<Hunar> Was that a question for me? because I only want to check if it's T or not, then treat it as if it was NIL
<Regenaxer> No, question to myself ;)
<Hunar> :)
<Regenaxer> Usually protected symbols are checked
<Regenaxer> : (set T 7)
<Regenaxer> !? (set T 7)
<Regenaxer> T -- Protected
<Regenaxer> ?
<Regenaxer> Not sure in case of struct variables
<Regenaxer> I don't remember. Too long ago
<Regenaxer> I don't remember the details of 'native' implementation
<Hunar> I'll scratch my head for afew more days while asking questions :) then probably create a glue code instead, I don't feel like my idea would result in a change in pil21, but i'll still try :D
<Regenaxer> Yes, this is good for sure
<Regenaxer> But I feel it is perhaps not worth the effort
<Hunar> I don't know, I've seen alot of libraries pass struct by value, maybe it's because my interests (I'm a Physicist) we like simple notations so Var.x instead of Var->x would make us happy :) .. So for me personally a single change in pil's native would result in reduction of alot of glue code in each library that I'm planning to create bindings for
<Regenaxer> I understand
<Regenaxer> I made a test for a glue function. In this case, a glue to printf()
<Regenaxer> http://ix.io/3FIi
<Hunar> Looks a bit cryptic :) So this gets compiled with clang each time this file is run?
<Regenaxer> yes, when 'load'ed
<Regenaxer> Note that it is just 'printf' on Lisp level again. No name conflict with built-in printf()
<Hunar> is clang just a name or it actually needs the clang compiler instead of gcc
<Regenaxer> I don't know if gcc is compatible
<Regenaxer> Pil is built with clang/llvm
<Hunar> right
<Regenaxer> So the disadvantage is that it needs a C compiler at runtime
<Hunar> Does this have more flexibility than writing the glue code and compiling it to an .so file? so that the use of pilrays ;) only has to download two files .l & .so
<Hunar> the user*
<Regenaxer> A glue library would need a prefix
<Regenaxer> (rayglue:printf ...)
<Regenaxer> well, no
<Hunar> The problem is I haven't written any glue code before, yet another thing to learn
<Regenaxer> the prefix is needed if you write a PilSrc .so
<Regenaxer> In this example, the user also needs only one file
<Regenaxer> the one above in ix.io
<Regenaxer> It has both Lisp and C
<Regenaxer> The stuff after the line /**/ is Lisp again
<Hunar> Wait, the user would have already installed clang if pil21 was installed, right? ignoring prebuild linux package managers
<Regenaxer> yep
<Hunar> :D
<Regenaxer> so he needs raylib and your glue .l file
<Regenaxer> When .l is loaded, the .so is created in (tmp)
<Hunar> Great :)
<Regenaxer> :ok 123 bla
<Regenaxer> : (dir (tmp))
<Regenaxer> -> ("rg" "rg.c")
<Hunar> what is this weird syntax #{"-lraylib"}#
<Regenaxer> That is a comment
<Regenaxer> You include the libs
<Regenaxer> in z3d.l :
<Regenaxer> (clang "z3d" '("-L/usr/X11R6/lib" "-lXext" "-lX11")
<Regenaxer> It links to three libraries
<Regenaxer> X11
<Regenaxer> no
<Regenaxer> 2 libs
<Regenaxer> The first is the directory path
<Hunar> Which part was the comment, -lraylib is linking so it cant be the comment
<Regenaxer> My example links nothing
<Regenaxer> it is only printf
<Regenaxer> #{is a nestable comment in pil}#
<Hunar> Ah, I see
<Hunar> So do I write everything like this? or use native and only use the weird structs this way
v_m_v has joined #picolisp
<Regenaxer> yep :)
<Regenaxer> @lib/clang.l is more powerful
<Regenaxer> it combines a C compiler with 'native'
<Regenaxer> inline-C
<Hunar> Ok you got me, I'll stop the hacking and start learning to use clang.l
<Hunar> :)
<Regenaxer> :)
<Regenaxer> you can mix it of course
<Regenaxer> your .l file may contain also direct native calls
<Regenaxer> just where glue is needed ...
<Hunar> Can you give me a simple example.. is it for simplicity? since using clang.l is verbose for simple stuff
<Regenaxer> The printf example is not simple enough?
<Hunar> No I mean a simple example (verbally) for using direct native calls instead of everything written with clang.l
<Regenaxer> ah
<Regenaxer> everything that does not pass a struct by value
<Regenaxer> so probably most raylib functions
<Hunar> So your ( yep :) ) was for my second question
<Regenaxer> "only use the weird structs"?
<Regenaxer> yes
<Hunar> Ah, I misunderstood :)
<Regenaxer> hmm, or I
<Regenaxer> yep was for "write everything like this"
<Regenaxer> anyway, doesn't matter :)
<Hunar> regarding performance it doesn't matter?
<Regenaxer> Not measuably, the glue has a little call overhead
<Hunar> It uses clang during execution or only once at the start?
<Regenaxer> only once to compile the inline-C
<Hunar> Great :D thank you very much
<Regenaxer> welcome :)
Hunar has quit [Quit: Client closed]
v_m_v has quit [Remote host closed the connection]
theruran has joined #picolisp
v_m_v has joined #picolisp
beneroth has quit [Quit: Leaving]
Hunar has joined #picolisp
Hunar has quit [Client Quit]
Hunar has joined #picolisp
<Hunar> Sorry It's definitely too late, small question for tomorrow.. when using clang.l  (cons X 1.0) passes X as double, what about floats? the rcsim example didn't have floats to learn from
Hunar has quit [Quit: Client closed]
v_m_v has quit [Remote host closed the connection]
<Regenaxer> No problem. Float takes a negative scale -1.0
clacke has quit [Remote host closed the connection]