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
razzy has quit [Ping timeout: 250 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 250 seconds]
TeddyDD has quit [Ping timeout: 260 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 250 seconds]
razzy has joined #picolisp
clacke has joined #picolisp
schulze has quit [Ping timeout: 240 seconds]
razzy has quit [Ping timeout: 240 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 250 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 250 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 240 seconds]
razzy has joined #picolisp
Hunar has joined #picolisp
<Hunar> Hello :)   I haven't used the symbol @ before to get rid of temporary variables ... in the following code @ gives NIL instead of the result of the previous expression.. what is my problem
<Hunar> (de getMousePosition NIL
<Hunar>    (prog2
<Hunar>       (native (tmp "raylib-pil") "PilGetMousePosition" 'P)
<Hunar>       (struct @ (vec2))
<Hunar>       (%@ "free" NIL "PilGetMousePosition")) )
<Regenaxer> right, in 'prog2' the value of '@' is set to the second expression
<Regenaxer> So here it is not set yet
<Regenaxer> (prog1 (foo) (bar @)) here @ is (foo)
<Regenaxer> (prog2 (foo) (muble) (bar @)) here @ is (mumble)
<Hunar> Ah ... I thought @ was the result of the last  (  ) being executed
<Hunar> Is there another trick or I'll have to use   let
<Regenaxer> No, always the result of the "relevant' expression ;)
<Regenaxer> 'prog1' would do in the above case
<Regenaxer> But then *that* value is returned
<Regenaxer> Is '@' meaningful here?
<Hunar> But I want the result of struct why use prog1?
<Regenaxer> Why not (struct (native (tmp ...)) ?
<Hunar> I want to free it afterwards
<Regenaxer> yes, so prog1
<Regenaxer> (prog1 (struct (native (tmp ...))) (free))
<Hunar> AAa, now I get what I'm doing wrong ..
<Hunar> :)  thanks
<Regenaxer> :)
razzy has quit [Ping timeout: 250 seconds]
razzy has joined #picolisp
<Hunar> Weird, if I call this function two times it crashes
<Regenaxer> ah
<Regenaxer> (tmp "name") is not a good idea
<Regenaxer> it creates a *new* transient symbol each time
<Hunar> I'll fix it now
<Regenaxer> 'native' wants to keep the pointer in the value
<Regenaxer> But I would not expect a crash
<Regenaxer> just slower execution because the lib is re-opened each time
<Regenaxer> Perhaps some leak?
<Regenaxer> opening the handle too often?
<Hunar> I don't know :/   here is the relevant code  http://ix.io/3HG5   I'm trying to solve the structs that were returned by value
<Hunar> If I didn't free the pointer then it doesn't crash, but I'll have a memory leak
<Regenaxer> You free the function pointer
<Regenaxer> %@ "free" NIL "PilGetMousePosition")
<Regenaxer> this calls it (native Lib "PilGetMousePosition")
<Regenaxer> I don't quite get it, but I would not malloc() in the callee
<Regenaxer> Better do it in Lisp
<Regenaxer> using 'buf'
<Hunar> bbl
<Regenaxer> Do you know sizeof(Vector2)?
<Regenaxer> ok
schulze has joined #picolisp
<Hunar> I found the problem :)   I copied the code from your solution (Wait, this is better: http://ix.io/3GeQ) But I only now noticed that its     '"printf"    instead of     "printf"   that was my error
<Hunar> using a quote doesn't cause crash
<Regenaxer> ok, but still I would use 'buf'
<Regenaxer> much more efficient, and no 'free' is needed
<Hunar> Ah, I was about to ask that :)  I don't like using free
<Hunar> I'll try that then
<Regenaxer> good
<Regenaxer> also because (%@ "free" NIL "PilGetMousePosition") is strange, right?
<Regenaxer> "PilGetMousePosition" is the function handle
<Regenaxer> not the malloc'ed memory
<Hunar> T
<Hunar> Does (%@ "free" ...) know how many bytes to free?
schulze has quit [Quit: nyaa~]
schulze has joined #picolisp
<Regenaxer> yes
<Regenaxer> The heap is maintained by linked structures
razzy has quit [Ping timeout: 268 seconds]
razzy has joined #picolisp
Hunar has quit [Quit: Client closed]
razzy has quit [Ping timeout: 260 seconds]
razzy has joined #picolisp
aw- has quit [Ping timeout: 252 seconds]
TeddyDD has joined #picolisp
razzy has quit [Ping timeout: 260 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 268 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 250 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 268 seconds]
TeddyDD has quit [Quit: WeeChat 3.3]