Re: Array avoidance example
Hi Kashyap, > Could you please share the example where you shared how native code > interface could be used to malloc a section of the heap? I believe you > shared this in the last PiCon. I don't remember exactly, but it could have been something like (using pil21): # Allocate 99 bytes : (setq P (%@ "malloc" 'P 99)) -> 512227229696 # Store a long integer -1 (or ) : (struct P NIL (-1 . 8)) -> NIL # Read a list of 8 bytes : (struct P '(B . 8)) -> (255 255 255 255 255 255 255 255) # Store 3 bytes : (byte P 65) (byte (inc P) 66) (byte (+ P 2) 0) -> 0 # Read 8 bytes again : (struct P '(B . 8)) -> (65 66 0 255 255 255 255 255) # Read the same as a string : (struct P 'S) -> "AB" # Free the memory : (%@ "free" NIL P) -> NIL Instead of heap malloc() / free() you can (again, pil21) also use a local buffer on the stack: : (buf P 99 (byte P 65) (byte (inc P) 0) (struct P 'S) ) -> "A" ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Call native wrapper function with double argument
Hi Thorsten, welcome back! :) > I'm playing around with the native function again (after a long long time > ;-) and somehow I don't manage to call a native wrapper with double arg. > > Using rmath from R, random value from poisson distribution:^ > ## double› rpois(double); > ... > This works > : (native "libRmath.so" "rpois" 1.0 (2.567 . 1.0)) > ... > but this dumps > : (de rpois (X) (native "libRmath.so" "rpois" 1.0 (X . 1.0) ) ) > ... > When I debug it, X=3 when the function is called. The problem is (X . 1.0), it calls 'X' as a function. So this would work: : (de rpois (X) (native "libRmath.so" "rpois" 1.0 (cons X 1.0) ) ) ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Array avoidance example
Hi Alex, Could you please share the example where you shared how native code interface could be used to malloc a section of the heap? I believe you shared this in the last PiCon. Regards, Kashyap
Call native wrapper function with double argument
Hello List, Hi Alex, I'm playing around with the native function again (after a long long time ;-) and somehow I don't manage to call a native wrapper with double arg. Using rmath from R, random value from poisson distribution:^ ## double› rpois(double); This works : (native "libRmath.so" "rpois" 1.0 (2.567 . 1.0)) -> 5 : (native "libRmath.so" "rpois" 1.0 (2.567 . 1.0)) -> 2 This works too: ## int› imax2(int, int); : (de imax2 (X) (native "libRmath.so" "imax2" 'I 3 6)) -> imax2 : (imax2 3 6) -> 6 but this dumps : (de rpois (X) (native "libRmath.so" "rpois" 1.0 (X . 1.0) ) ) -> rpois : (rpois 2.567) Segmentation fault When I debug it, X=3 when the function is called. So probably my function call is wrong? Cheers Thorsten
subscribe
Re: Announcing: Posix Message Queues with PicoLisp
Very nice, Alexander, thanks for sharing / pointing to those repos. I never thought to think about PMQ, but the way you documented the work and the easy entry with checks and tutorials allured me to have a look and perhaps I would go deeper because there was some (so far non-picolisp-)script which I realized with named pipes I'll see. The presentation of your work is inspiring, too, thanks for the efforts and showing that. Regards, Olaf On 10.11.20 05:30, Alexander Williams wrote: > Hi, > > I've published some code for interacting with Posix Message Queues[1] > directly in PicoLisp (using 'native'). > > https://github.com/aw/picolisp-posixmq/ > > It's a _very_ small library with quite comprehensive documentation[2] > (WIP). > > And for those who aren't aware, there's also a list of all my PicoLisp > projects available[3]. > > - [1]: https://man7.org/linux/man-pages/man7/mq_overview.7.html > - [2]: https://github.com/aw/picolisp-posixmq/tree/master/docs > - [3]: https://picolisp.a1w.ca/ > > Cheers, > > > AW > -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe