Re: Two questions regarding 'native'

2017-10-24 Thread Alexander Williams

This looks pretty good.

If it helps, I've written a few 'native' tutorials, at 
https://picolisp.a1w.ca


+1 for choosing a liberal license as well (CC0).


AW

On 17-10-24 11:06 AM, Alfonso Villén wrote:


I've created a public Bitbucket repository with my work so far,
including some examples.
https://bitbucket.org/alfonsovillen/picolispffi


--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Two questions regarding 'native'

2017-10-24 Thread Alfonso Villén
Hello Mike,

I've just made the Reddit post:
https://www.reddit.com/r/lisp/comments/78iy7w/sdl2_and_opengl_33_on_picolisp_64bit/

2017-10-24 13:35 GMT+02:00 Mike Pechkin :

> ​Alfonso,
>
> Make a post on reddit.com/r/lisp​
>
>
>
>
>> I've created a public Bitbucket repository with my work so far, including
>> some examples.
>> https://bitbucket.org/alfonsovillen/picolispffi
>>
>> I don't know if someone will be interested in it, but I'm having fun
>> doing it.
>>
>
>


Re: Two questions regarding 'native'

2017-10-24 Thread Mike Pechkin
​Alfonso,

Make a post on reddit.com/r/lisp​




> I've created a public Bitbucket repository with my work so far, including
> some examples.
> https://bitbucket.org/alfonsovillen/picolispffi
>
> I don't know if someone will be interested in it, but I'm having fun doing
> it.
>


Re: Two questions regarding 'native'

2017-10-24 Thread Alfonso Villén
Hello,

finally, I could display a triangle using OpenGL 3.3. I translated the code
from the C tutorial at:
https://learnopengl.com/#!Getting-started/Hello-Triangle.

Thanks again for your help, Alex.

Unfortunately I'm running into difficulties again because after translating
the next tutorial, nothing is rendered. Maybe I'll post a question about it
later.

I've created a public Bitbucket repository with my work so far, including
some examples.
https://bitbucket.org/alfonsovillen/picolispffi

I don't know if someone will be interested in it, but I'm having fun doing
it.

Bye,
Alfonso V.

2017-10-21 15:34 GMT+02:00 Alexander Burger :

> On Sat, Oct 21, 2017 at 02:38:18PM +0200, Alfonso Villén wrote:
> > The function arguments don't work as you expected. That C function needs
> > some weird information such as an array of integers giving the length of
> > the strings in the other array if those don't end with null bytes...
>
> Ah, I see. Didn't know that. Then it is probably something like:
>
>
>(de glShaderSource (Shader Strings)
>   (let
>  (Lst
> (mapcar
>'((Str) (cons (native "@" "strdup" 'N Str) 8))
>Strings )
> Len (length Strings) )
>  (native `*GlutLib "glShaderSource" NIL
> Shader
> Len
> (cons NIL (list (* 8 Len)) Lst)
> (cons NIL (list (* 8 Len))
>(mapcar
>   '((Str) (- (length Str)))
>   Strings ) ) )
>  (mapc '((X) (native "@" "free" NIL (car X))) Lst) ) )
>
>
> > I'm also having problems with other function, and in all of them there
> are
> > pointer arguments involved. But I hope I'll be able to figure the
> solution
> > myself.
> >
> > When I get some examples working I'd like to share the code with you all.
>
> Great, thanks! Perhaps we can add them to @lib/openGl.l then.
>
> ♪♫ Alex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Two questions regarding 'native'

2017-10-21 Thread Alexander Burger
On Sat, Oct 21, 2017 at 02:38:18PM +0200, Alfonso Villén wrote:
> The function arguments don't work as you expected. That C function needs
> some weird information such as an array of integers giving the length of
> the strings in the other array if those don't end with null bytes...

Ah, I see. Didn't know that. Then it is probably something like:


   (de glShaderSource (Shader Strings)
  (let
 (Lst
(mapcar
   '((Str) (cons (native "@" "strdup" 'N Str) 8))
   Strings )
Len (length Strings) )
 (native `*GlutLib "glShaderSource" NIL
Shader
Len
(cons NIL (list (* 8 Len)) Lst)
(cons NIL (list (* 8 Len))
   (mapcar
  '((Str) (- (length Str)))
  Strings ) ) )
 (mapc '((X) (native "@" "free" NIL (car X))) Lst) ) )


> I'm also having problems with other function, and in all of them there are
> pointer arguments involved. But I hope I'll be able to figure the solution
> myself.
> 
> When I get some examples working I'd like to share the code with you all.

Great, thanks! Perhaps we can add them to @lib/openGl.l then.

♪♫ Alex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Two questions regarding 'native'

2017-10-21 Thread Alfonso Villén
Hello,

thank you very much, Alex. It seems to work, but I have to test more
thoroughly.

The function arguments don't work as you expected. That C function needs
some weird information such as an array of integers giving the length of
the strings in the other array if those don't end with null bytes...

I'm also having problems with other function, and in all of them there are
pointer arguments involved. But I hope I'll be able to figure the solution
myself.

When I get some examples working I'd like to share the code with you all.

Alfonso Villén

Am 21.10.2017 10:08 schrieb "Alexander Burger" :

> Hi Alfonso,
>
> > I'm exploring Picolisp as a hobby for a while now, and I find it
> absolutely
> > amazing. I'm experimenting with 'native', trying to make some bindings
> for
> > SDL2 and OpenGL.
>
> I assume you found the OpenGL library in the distribution too, right? Just
> for
> the records, it is in "@lib/openGl.l".
>
>
> > I want to call this OpenGL function with 'native':
> >
> > void glShaderSource(
> > GLuint shader,
> > GLsizei count,
> > const GLchar **string,
> > const GLint *length)
> >
> > I have a problem with the third argument. I can't figure out if and how a
> > pointer to an array of string pointers can be passed to the function
> using
> > 'native'.
>
> An array of string pointers basically boils down to a structure in C.
>
> However, this case is indeed tricky, because the string array must first be
> created. I would call strdup() to get a list of pointers.
>
> Assuming you have {"abc", "def", "ghi"), this would be
>
>(mapcar
>   '((Str) (cons (native "@" "strdup" 'N Str) 8))
>   '("abc" "def" "ghi") )
>
> That is, it creates a list (( . 8) ( . 8) ( .
> 8)).
> The '8' values are needed for the 'native' struct definition (as the
> reference
> says "a pair (num . cnt) where 'num' is stored in a field of 'cnt' bytes").
>
> Note that you must also call free() on the results of strdup() when done.
>
>
> > My other question is about the fourth argument. Is there a way (other
> than
> > allocating some memory with 'malloc') so you can pass a C pointer to a
> > Picolisp symbol's value using 'native'?
>
> You can pass a pointer simply as a number. But this doesn't make sense
> here,
> because where should that pointer come from?
>
> So one way is to call 'malloc' as you said, but you can better let
> 'native' do
> the alloction for you, as another structure which holds a single pointer
> and
> which returns its value. The following passes the number 3 in a
> single-element
> 'int' array, receiving the possibly modified value in the variable 'Len':
>
>(Len (8 . I) -3)
>
> If you are not interested in a return value, and just want to pass 3:
>
>(NIL (8) -3)
>
>
> With all that, your function would be:
>
>(de glShaderSource (Shader Count Strings)
>   (let
>  (Lst
> (mapcar
>'((Str) (cons (native "@" "strdup" 'N Str) 8))
>Strings )
> Len (length Lst) )
>  (native `*GlutLib "glShaderSource" NIL
> Shader
> Count
> (cons NIL (list (* 8 Len)) Lst)
> (list 'Len (8 . I) (- Len)) )
>  (mapc '((X) (native "@" "free" NIL (car X))) Lst)
>  Len ) )
>
> You call it as (glShaderSource 3 4 '("abc" "def" "ghi")).
>
> I haven't checked the OpenGL docs if this makes sense, and haven't tested
> the
> above. It assumes that 'length' holds the number of strings in 'string'
> (and not
> 'count'!). And it assumes that you want to return the length in 'Len'. So
> the
> above must perhaps be modified.
>
> Indeed rather messy ;)
>
> ♪♫ Alex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Two questions regarding 'native'

2017-10-21 Thread Alexander Burger
Hi Alfonso,

> I'm exploring Picolisp as a hobby for a while now, and I find it absolutely
> amazing. I'm experimenting with 'native', trying to make some bindings for
> SDL2 and OpenGL.

I assume you found the OpenGL library in the distribution too, right? Just for
the records, it is in "@lib/openGl.l".


> I want to call this OpenGL function with 'native':
> 
> void glShaderSource(
> GLuint shader,
> GLsizei count,
> const GLchar **string,
> const GLint *length)
> 
> I have a problem with the third argument. I can't figure out if and how a
> pointer to an array of string pointers can be passed to the function using
> 'native'.

An array of string pointers basically boils down to a structure in C.

However, this case is indeed tricky, because the string array must first be
created. I would call strdup() to get a list of pointers.

Assuming you have {"abc", "def", "ghi"), this would be

   (mapcar
  '((Str) (cons (native "@" "strdup" 'N Str) 8))
  '("abc" "def" "ghi") )

That is, it creates a list (( . 8) ( . 8) ( . 8)).
The '8' values are needed for the 'native' struct definition (as the reference
says "a pair (num . cnt) where 'num' is stored in a field of 'cnt' bytes").

Note that you must also call free() on the results of strdup() when done.


> My other question is about the fourth argument. Is there a way (other than
> allocating some memory with 'malloc') so you can pass a C pointer to a
> Picolisp symbol's value using 'native'?

You can pass a pointer simply as a number. But this doesn't make sense here,
because where should that pointer come from?

So one way is to call 'malloc' as you said, but you can better let 'native' do
the alloction for you, as another structure which holds a single pointer and
which returns its value. The following passes the number 3 in a single-element
'int' array, receiving the possibly modified value in the variable 'Len':

   (Len (8 . I) -3)

If you are not interested in a return value, and just want to pass 3:

   (NIL (8) -3)


With all that, your function would be:

   (de glShaderSource (Shader Count Strings)
  (let
 (Lst
(mapcar
   '((Str) (cons (native "@" "strdup" 'N Str) 8))
   Strings )
Len (length Lst) )
 (native `*GlutLib "glShaderSource" NIL
Shader
Count
(cons NIL (list (* 8 Len)) Lst)
(list 'Len (8 . I) (- Len)) )
 (mapc '((X) (native "@" "free" NIL (car X))) Lst)
 Len ) )

You call it as (glShaderSource 3 4 '("abc" "def" "ghi")).

I haven't checked the OpenGL docs if this makes sense, and haven't tested the
above. It assumes that 'length' holds the number of strings in 'string' (and not
'count'!). And it assumes that you want to return the length in 'Len'. So the
above must perhaps be modified.

Indeed rather messy ;)

♪♫ Alex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Two questions regarding 'native'

2017-10-20 Thread Alfonso Villén
Hello,

I'm exploring Picolisp as a hobby for a while now, and I find it absolutely
amazing. I'm experimenting with 'native', trying to make some bindings for
SDL2 and OpenGL.

I want to call this OpenGL function with 'native':

void glShaderSource(
GLuint shader,
GLsizei count,
const GLchar **string,
const GLint *length)

I have a problem with the third argument. I can't figure out if and how a
pointer to an array of string pointers can be passed to the function using
'native'.

My other question is about the fourth argument. Is there a way (other than
allocating some memory with 'malloc') so you can pass a C pointer to a
Picolisp symbol's value using 'native'?

I'd be very glad if someone could answer.

Alfonso Villén


Re: Two questions

2016-05-08 Thread Jeronimo Pellegrini
On Mon, May 09, 2016 at 12:08:42AM +0200, andr...@itship.ch wrote:
> 2. I don't know of anyone running pil on this vocore device or even
> under OpenWRT distro, so you might have to try out yourself. Post your
> experiences with it here and/or on the wiki for other users. :-)

I do run PicoLisp on an OpenWRT router, but I haven't updated the
OpenWRT pil packages in a while. However, it should be relatively easy
to apply the patches to new versions of PicoLisp:

http://aleph0.info/jp/software/lisp-forth-openwrt/

J.

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


RE: Two questions

2016-05-08 Thread andreas
1. sudo apt-get install picolisp; pil -> (version) -> see for yourself

The version in the distribution package repositories are usually (naturally) a 
bit outdated.
To compile your own picolisp version during hand-install you require a usable 
picolisp version already installed (or java runtime as last resort), so you 
want to apt-get install picolisp anyway.

As changes in releases are usually tiny and almost never (just almost, but hey) 
breaking existing functionality/usage, even an a bit older version of picolisp 
is sufficient.
The introduction page of the new website is obviously directed at picolisp 
beginners, so this should be alright.

JUST DO IT dude, you are pondering too much...

2. I don't know of anyone running pil on this vocore device or even under 
OpenWRT distro, so you might have to try out yourself. Post your experiences 
with it here and/or on the wiki for other users. :-)

Picolisp is tiny both in storage size and memory footprint, so it does great on 
these tiny computers and is in fact used for embedded computing by a number of 
people.


- Original Message -
From: Lawrence Bottorff [mailto:borg...@gmail.com]
To: picolisp@software-lab.de
Sent: Sun, 8 May 2016 11:44:48 -0400
Subject: Two questions

1. The new spiffy (flotte?) Website says just go ahead, Ubuntu users, and
do an apt-get install picolisp. Good, but is that a nice, recent version --
or would it be better to hand-install?

2. Does picolisp run on this little guy: http://vocore.io/ . . . In
general, what's picolisp's track record on all these tiny computers?

LB




Re: Two questions

2016-05-08 Thread O.Hamann

Hey Lawrence,

if you are new to picolisp and want to get an impression of how it works 
an try some of the examples, I think "sudo apt-get install picolisp" is 
the perfect way to reach "picoLand" and start exploring it's 
beautifulness immediately.


If you then feel the need of the things, that changed since the (3.1.5 
?) release, that your ubuntu offers you, it's rather easy to install 
additional picolisp-releases side by side (no need for su permissions 
for these local userspace installs, as far as I know).


No need to bother long time which would be the best way - just tap sudo 
apt-get install und look around :-)

Decide later, which release to work with.


Answers to the second question might be found in the maillist archive, 
as there were questions concerning special hardware before.


Picolisp offers a number of flavors out-of-the-box (mini-picolisp, 
ersatz, 32bit, 64bit, (?) , pilOS)

which are different in the way of system ressources they need,
the way they are written in (some in C, 64bit in Assembler, ersatz in Java),
and the features the specific flavor offers
(- but I'm just reading that, I do not know anything real about that -)
so that I always get the impression of 'there should be one way to get 
picolisp run on my desired hardware'.


Hopefully there will be a more precise answer from the list concerning 
your question.


Wish you have much fun with picolisp,

O.



On 08.05.2016 17:44, Lawrence Bottorff wrote:
1. The new spiffy (flotte?) Website says just go ahead, Ubuntu users, 
and do an apt-get install picolisp. Good, but is that a nice, recent 
version -- or would it be better to hand-install?


2. Does picolisp run on this little guy: http://vocore.io/ . . . In 
general, what's picolisp's track record on all these tiny computers?


LB




Two questions

2016-05-08 Thread Lawrence Bottorff
1. The new spiffy (flotte?) Website says just go ahead, Ubuntu users, and
do an apt-get install picolisp. Good, but is that a nice, recent version --
or would it be better to hand-install?

2. Does picolisp run on this little guy: http://vocore.io/ . . . In
general, what's picolisp's track record on all these tiny computers?

LB