<beneroth>
razzy, type is a list of classes, while class is a single symbol (complying to the structure expected from a class symbol, so not every symbol is a class but every class is a symbol following a certain structure)
<beneroth>
order of classes in a type matters. last/most right class is kinda the most significant class, the "base class", while the classes in front/left of it are called "prefix classes", they prefix/decorate the base class
<beneroth>
so (rel foo (+String)) is declaring a relation for property 'foo with type (+String)
<beneroth>
and in (rel foo (+Ref +String)) the +Ref is a prefix class, altering the behavior so that whenever 'foo gets set with a value, a non-unique index is automatically maintained
<beneroth>
and in (rel bar (+List +String)) the +List is a prefix class altering the behavior so you can have multiple +String values stored in the property 'bar
beneroth has quit [Quit: Leaving]
<razzy>
Good morning to all!
<razzy>
Regenaxer: I want to have search-able number representing "strength" of a +Joint. I do not know good way of doing it. (rel outs (+List +Ref +Number +Joint) ins (+Nr)) was my guess.
<razzy>
aw- has joined #picolisp
<Regenaxer>
Good morning!
<Regenaxer>
razzy, a +Number relation handles a number, and a +Joint handles a Symbolic value (another external symbol)
<Regenaxer>
So you need two separate values (= properties)
<Regenaxer>
You can use two separate relations, or a +Bag relation with several values
<Regenaxer>
But: A +Joint does not work well in a +Bag (due to its automatisms) and is not recommended
<Regenaxer>
+Link is ok in +Bag
<Regenaxer>
after all, a +Joint is nothing more than two +Link's
<razzy>
Regenaxer: Thank you. I missed +Bag.
Hunar has joined #picolisp
beneroth has joined #picolisp
v_m_v has joined #picolisp
<Hunar>
Hello :D .. Regenaxer, three days ago you said (Normally structures are passed by pointer), so I thought nobody (other than me) will think otherwise .. but it turns out that aloot of math libraries do, when passing vectors and matrices :( .. BUT I had faith in myself and started trying raylib library using native as an initial step to make a
<Hunar>
pil binding for it :) , everything went fine, and with minimal effort I got the simple hello world from their website and it worked :) https://pastebin.com/dfys4tHM
<Hunar>
BUUUT raylib uses a struct of (unsigned char r,g,b,a) for colors, and all the functions that need a color expect a Color struct by value, so the code above creates the window background and the text with random colors each time I run it.. I searched alot yesterday to see how people passed struct by value to a function when using libffi, here
<Hunar>
Most of it went over my head, but I think you can find it useful, the only thing I understood it that: I have to create a pointer (setq P (%@ "malloc" 'P 4)) fill it (struct P NIL 255 255 255 255) dereference the pointer and pass that to native (which I don't know if I can right now) then free the pointer.. to pass the dereferenced pointer
<Hunar>
I edited @src/lib.c , at line 611 there is ffi_call(&p->cif, p->fun, &rc, ptr); I changed ptr to *ptr with an ugly hack that lets me chose when to use one or the other .. It kinda worked, except it only passed 2 items to the function when I tried it with a custom struct that had 4 integers.
<Hunar>
I really hope you can help me, or maybe extend pil a little bit to allow passing struct by value, or you have another workaround for this issue, because I DO NOT want the end user to download a custom .so , I want my binding to be a single picolisp file
<Regenaxer>
OK, four color bytes bytes can easily be passed as a "structure", it is simply a 32-bit number :)
<Regenaxer>
Or do you know of a case where *real* structures are copied?
<Hunar>
Unfortunately i'm like 60% familiar with the C langauge :) how large of a struct is still counted as non*real* structures?
<Regenaxer>
RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
<Regenaxer>
seems correct
<Regenaxer>
SetTargetFPS also
<Regenaxer>
WindowShouldClose does not return a byte
<Regenaxer>
I think C functions never return a byte, at least an int
<Regenaxer>
but we need bool
<Regenaxer>
I think 'I is better than 'A
<Regenaxer>
'B I mean
<Regenaxer>
In any case, did (0= in the while loop work?
<Regenaxer>
See? it says // Color, 4 components, R8G8B8A8 (32bit)
<Regenaxer>
so you need to pass an int
<Regenaxer>
With (4 (B . 4)) native creates a struct on the stack and passes a *pointer* to the function
<Hunar>
Sorry, some office work interrupted me
<Regenaxer>
np
<Regenaxer>
so you need to pass (hex "FF00000000") for red
<Hunar>
I thought an int is too large for a bool :) so I chose a byte
<Hunar>
(In any case, did (0= in the while loop work?) yes it did work
<Regenaxer>
In C a boolean is usually a typedef to 'int'
<Hunar>
(hex "FF00000000") that is actually much better
<Hunar>
Oh, that's a waste of bytes :|
<Regenaxer>
which one?
<Regenaxer>
a waste
<Hunar>
typedef to 'int'
<Regenaxer>
no, cause the machine uses words anyway
<Hunar>
Ah, I see :)
<Regenaxer>
when passing to or returning from functions
<Regenaxer>
registers
<Regenaxer>
If you want arrays of booleans, better use individual bits
<Regenaxer>
masking
<Regenaxer>
anyway, DrawText has the same Color issue
<Regenaxer>
EndDrawing is no problem
<Regenaxer>
So the only problems were Color values
<Hunar>
yes, because only color had the (passing struct by value) problem.. should I come back everytime I encounter a new (passing struct by value) problem :) or there is a general workaround
<Regenaxer>
I think you never find such a case
<Regenaxer>
It is simply too inefficient for a C programmer
<Hunar>
Great :) thank you very much .. now I have a more mysterious (at least for me) problem
<Regenaxer>
Good :)
<Hunar>
Let me remember what I wrote at home, I think it was (de raylib V (apply 'native (cons "libraylib.so" V))) for shortening (native "libraylib.so" ...) to (raylib ...) but it didn't work.. I'm sure it's a simple problem
<Regenaxer>
'(de raylib V' do you really want a FEXPR ?
<Regenaxer>
well, yes, makes sense
<Regenaxer>
But I think this is not so useful
<Regenaxer>
and apply and cons at runtime
<Regenaxer>
better use varargs, to get normal evaluation
<Regenaxer>
(de raylib @ (pass native "libraylib.so"))
<Regenaxer>
that's all
<Hunar>
Oh, I haven't encountered pass before :) thanks
<tankf33der>
why you make private X? And not other symbols?
<tankf33der>
AAaa, ok.
<tankf33der>
np
<beneroth>
talking about vip and using different editors
<Regenaxer>
tankf33der, I look later
clacke has quit [Remote host closed the connection]
<Regenaxer>
tankf33der: X is private because it might be bound to itself
<Regenaxer>
if it is somewhere in 'Lst'
beneroth has quit [Quit: Leaving]
razzy has quit [Ping timeout: 260 seconds]
alexshendi has joined #picolisp
<alexshendi>
Good night.
<Regenaxer>
Hi alexshendi!
<alexshendi>
Hi Regenaxer, how are you? How is life?
<Regenaxer>
Thanks! It is all OK so far :)
<alexshendi>
Regenaxer: Do you still use a tablet with a custom keyboard for programming?
<Regenaxer>
Not tablet, but a normal smartphone
<Regenaxer>
since 3 years now
<Regenaxer>
I developed all pil21 on that phone
<alexshendi>
A phone? But with an external display and keyboard?
<Regenaxer>
nope
<Regenaxer>
just the phone
<Regenaxer>
also this here I'm writing on that phone
<Regenaxer>
A OnePlus 6T
<Regenaxer>
If you had attende
<Regenaxer>
d PilCon, you'd have seen
<alexshendi>
I admire that! I have bought a Linux phone, but the display and the virtual keyboard proved too much for my elderly eyes and "Wurstfinger".
<Regenaxer>
:)
<Regenaxer>
luckily, my eyes are not too bad yet
<Regenaxer>
though not as good as in young years
<alexshendi>
I'm writing this on an Android phone too, tough....
<Regenaxer>
good
<alexshendi>
But you use the virtual keyboard of the phone?
<Regenaxer>
no, not the normal one
<Regenaxer>
this is indeed impossible to use for programming
<Regenaxer>
I use PentiKeyboard
<alexshendi>
Ah, ok.
<alexshendi>
I have bought a Chromebook with an AZERTY (french) keyboard. I can't get used to it....
<Regenaxer>
Can you not change the layout?
<alexshendi>
Either US or german Keyboard is OK.
<Regenaxer>
yes
<Regenaxer>
but not possible?
<Regenaxer>
in Chromebooks?
<alexshendi>
It's a physical keyboard. I could of course tell ChromeOS that the layout is german, but then the labeling of the keys would be wrong. And that's a problem for me.
<Regenaxer>
Ah, right!
<Regenaxer>
When I still used normal keyboards years ago, I always used US layout no matter what the labls were
<Regenaxer>
I typed blindly anyway
<alexshendi>
I can't type blindly. I'm a lousy typist.
<Regenaxer>
Now with Penti there is no such problem anyway
<Regenaxer>
ok :)
<alexshendi>
I would like to use pil more, but everything I do seems to require floating point.
<Regenaxer>
you can do all with fixpoint I believe
<Regenaxer>
needs more care though
<Regenaxer>
What kinds of things are these?
<alexshendi>
Floating point numbers are just cleverly scaled Integers anyway, simplifying greatly. What matters isst Hard ware support in the CPU.
<Regenaxer>
yes, so in pil I call native C libs for such float stuff
<Regenaxer>
so it goes into the hardware
<alexshendi>
Basically reading stuff from result files from a FEM calculation. And then some calculations with the data. Nothing too complex, just some matrix algebra
<Regenaxer>
cool
<alexshendi>
The data is large. Matrix size is 150 000 by 150 000 with ca. 180 000 nonzero entries.
<Regenaxer>
wow
<alexshendi>
The picolisp approach would probably be to write it in C and call it via native...
<Regenaxer>
yes, separate the hard-core calculations from the application logic
<alexshendi>
Regenaxer: What is your preferred method of doing 2D graphics? I have found 3 alternatives. 1. Web Browser/HTML5 canvas, 2. Tcl/ Tk (photo widget) 3. VT340 terminal emulation 4. Something like gtk-server or etd.
<alexshendi>
s/etd/ezd/
<Regenaxer>
Currentl I do it in Canvas, and some things in SVG
<Regenaxer>
Browser/HTML5 canvas
<Regenaxer>
Getting sleepy
<Regenaxer>
Good for today I think
<alexshendi>
And how do you transfer data between the Browser and pil?
<Regenaxer>
was a busy day
<Regenaxer>
yes, using plio
<alexshendi>
Yes, thank you for the chat. Good night. Sleep well.
<Regenaxer>
Thanks!
<Regenaxer>
you too! :)
<alexshendi>
Tanks.
<alexshendi>
Thanks.
<Regenaxer>
Let's continue next time
<Regenaxer>
:)
<alexshendi>
Ok :)
alexshendi has quit [Quit: -a- IRC for Android 2.1.59]