Re: guile-user Digest, Vol 216, Issue 15

2020-11-24 Thread Aleix Conchillo FlaquƩ
Hi Tim,

yes, you should definitely checkout Chickadee. There are some cool demos in
the examples directory.

Best,

Aleix

On Mon, Nov 23, 2020, 5:55 PM Tim Meehan  wrote:

> Ok - I'm very new to Guile, and had run across "Sly" (game framework) by
> dthomson? (My assumption, based on checking out a couple of links:
> https://github.com/guildhall/guile-sly,
> http://www.draketo.de/proj/py2guile/
> at bottom of page) ...
>
> I'm interested in learning how to do games (Guile is a hobby, games are
> fun).
> Based on the recent announcement of Chickadee 0.6.0, I'm assuming I should
> check that out instead of Sly?
>
> On Fri, Nov 20, 2020 at 11:02 AM  wrote:
>
> > Send guile-user mailing list submissions to
> > guile-user@gnu.org
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> > https://lists.gnu.org/mailman/listinfo/guile-user
> > or, via email, send a message with subject or body 'help' to
> > guile-user-requ...@gnu.org
> >
> > You can reach the person managing the list at
> > guile-user-ow...@gnu.org
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of guile-user digest..."
> >
> >
> > Today's Topics:
> >
> >1. Chickadee 0.6.0 released (Thompson, David)
> >2. getting to know the FFI ... (Tim Meehan)
> >
> >
> > --
> >
> > Message: 1
> > Date: Thu, 19 Nov 2020 21:11:09 -0500
> > From: "Thompson, David" 
> > To: Guile User 
> > Subject: Chickadee 0.6.0 released
> > Message-ID:
> >  > trzabkhhz2ov+efemqopzdbfjfn68ty...@mail.gmail.com>
> > Content-Type: text/plain; charset="UTF-8"
> >
> > Hey everyone,
> >
> > I just released Chickadee 0.6.0.  Chickadee is a game programming
> > library for Guile. It handles window management,
> > keyboard/mouse/controller input, hardware-accelerated rendering,
> > audio, scripting, and more.
> >
> > Most notably it now supports OpenGL 2 (rejoice, old thinkpad users!),
> > can render TrueType/OpenType fonts, and has preliminary support for 2D
> > vector graphics.
> >
> > See the link below for full release details and download links:
> > https://dthompson.us/chickadee-060-released.html
> >
> > - Dave
> >
> >
> >
> > --
> >
> > Message: 2
> > Date: Thu, 19 Nov 2020 21:02:51 -0600
> > From: Tim Meehan 
> > To: guile-user@gnu.org
> > Subject: getting to know the FFI ...
> > Message-ID:
> >  > bse2p...@mail.gmail.com>
> > Content-Type: text/plain; charset="UTF-8"
> >
> > I figured that I would try and do something simple-ish to see how well I
> > understood the FFI. I found this GTK tutorial, written in Chez Scheme:
> > https://github.com/jhidding/lyonesse/blob/master/gtk-tutorial/window.scm
> > I just tried to replace the Chez FFI calls with Guile FFI calls.
> >
> > I'm not sure how to tell GTK about a callback that is written in Guile.
> > I'm not sure how to pass a string to GTK ...
> >
> > Cheers,
> > My bug-ridden source follows:
> >
> > ; The original code was in Chez Scheme, link below:
> > ;
> https://github.com/jhidding/lyonesse/blob/master/gtk-tutorial/window.scm
> >
> > ; I gather that it just pops up a window?
> > ; He didn't connect the "X" to the destroy action,
> > ; so the window might be hard to get rid of.
> >
> > (use-modules (system foreign))
> >
> > (define libgtk (dynamic-link "libgtk-3"))
> > (define libgdk (dynamic-link "libgdk-3"))
> > (define libgio (dynamic-link "libgio-2.0"))
> > (define libgobject (dynamic-link "libgobject-2.0"))
> >
> > ;; GtkApplication* -> GtkWidget*
> > (define gtk-application-window-new
> > (pointer->procedure
> > '*
> > (dynamic-func "gtk_application_window_new" libgtk)
> > (list '*)))
> >
> >
> > ;; GtkWindow*, gchar* -> void
> > (define gtk-window-set-title
> > (pointer->procedure
> > void
> > (dynamic-func "gtk_window_set_title" libgtk)
> > (list '* '*)))
> >
> >
> > (define gtk-window-set-default-size
> > (pointer->procedure
> > void
> > (dynamic-func "gtk_window_set_default_size" libgtk)
> > (list '*)))
> >
> >
> > ;; GtkWidget* -> void
> > (define gtk-widget-show-all
> > (pointer->procedure
> > void
> > (dynamic-func "gtk_widget_show_all" libgtk)
> > (list '*)))
> >
> >
> > ;; gchar*, GApplicationFlags -> GtkApplication*
> > (define gtk-application-new
> > (pointer->procedure
> > '*
> > (dynamic-func "gtk_application_new" libgtk)
> > (list '* int))) ; FIXME guess
> >
> >
> > ;; GApplication*, int, char ** -> int
> > (define g-application-run
> > (pointer->procedure
> > int
> > (dynamic-func "g_application_run" libgio)
> > (list '* int '*)))
> >
> >
> > ;; gpointer, gchar*, GCallback, gpointer, GConnectFlags -> gulong
> > (define g-signal-connect-object
> > (pointer->procedure
> > unsigned-long
> > (dynamic-func "g_signa

Re: [EXT] Re: guile-user Digest, Vol 216, Issue 15

2020-11-24 Thread Thompson, David
Hello Tim,

On Mon, Nov 23, 2020 at 8:56 PM Tim Meehan  wrote:
>
> Ok - I'm very new to Guile, and had run across "Sly" (game framework) by
> dthomson? (My assumption, based on checking out a couple of links:
> https://github.com/guildhall/guile-sly, http://www.draketo.de/proj/py2guile/
> at bottom of page) ...
>
> I'm interested in learning how to do games (Guile is a hobby, games are
> fun).
> Based on the recent announcement of Chickadee 0.6.0, I'm assuming I should
> check that out instead of Sly?

Yes, you should. Sly was an old experiment that I've since abandoned.
Chickadee is actively maintained and can do much more than Sly ever
could. Just keep in mind that it's alpha software so it is a little
rough around the edges.

Enjoy!

- Dave



Re: guile-user Digest, Vol 216, Issue 19

2020-11-24 Thread Tim Meehan
Matt - thanks for the help making the FFI pointers work!

On Sun, Nov 22, 2020 at 10:44 PM  wrote:

> Send guile-user mailing list submissions to
> guile-user@gnu.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.gnu.org/mailman/listinfo/guile-user
> or, via email, send a message with subject or body 'help' to
> guile-user-requ...@gnu.org
>
> You can reach the person managing the list at
> guile-user-ow...@gnu.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of guile-user digest..."
>
>
> Today's Topics:
>
>1. Re: Question about data structures (Tim Van den Langenbergh)
>2. broken link on "Learn" page (Tim Meehan)
>3. Re: Guile dynamic FFI, C function expecting pointer (Matt Wette)
>4. Re: Question about data structures (Taylan Kammer)
>5. Re: Question about data structures (John Cowan)
>
>
> --
>
> Message: 1
> Date: Sun, 22 Nov 2020 23:50:47 +0100
> From: Tim Van den Langenbergh 
> To: guile-user@gnu.org
> Subject: Re: Question about data structures
> Message-ID: <4033601.nszuQzh3Xh@terra>
> Content-Type: text/plain; charset="utf-8"
>
> On Sunday, 22 November 2020 19:48:24 CET Zelphir Kaltstahl wrote:
> > Hello Guile Users!
> >
> > I have a question about data structures.
> >
> > Recently I read a file and the lines in the file would become a list in
> > my Guile program. The file was not super big or anything. However, I
> > usually try to avoid having to use `append` or `reverse`, whenever
> > possible, considering, that they are O(n) operations and in principle I
> > do not want to write code, that uses lists in inefficient ways, when
> > there is a more efficient way. That said, I hit a little snag:
> >
> > When I am reading a file and do not know how many lines there are in the
> > file, I can use a normal list and construct it using recursive calls
> > like `(cons line (iter ...))` where `iter` is the recursive call and.
> > Could also be called `process-next-line` or simply `next`. Since I am
> > building a recursive data structure, it is OK to have a non-tail
> > position recursive call. Then I would return that list and work with it.
> > However, what if I ever need to add a list entry and the order of list
> > entry matters? I would either have to use `append`, to add it to the
> > end, which would be O(n), or I would have to initially construct the
> > list of lines in reversed order from initially, so that I can add by
> > simply using `(cons new-entry lines)`. However, when I use the list in
> > reverse and ever need to output the lines in the list in their original
> > order, I would first need to `reverse` the list again.
> >
> > OK the whole reversing would not be a problem, if I used a vector to
> > store the lines. However, then I would need to know the number of lines
> > in the file ahead of time or look at the file once for counting the
> > lines, then create the vector of that length and then store the lines in
> > it. This seems inelegant again, because I look at the lines of the file
> > twice. I could read it in as a list and then use `list->vector`, but
> > that will also be an additional O(n) for converting every entry to
> > vector element.
> >
> > If I now think about Python, then I have Python lists (actually arrays?)
> > and those can be easily appended to in O(1) and random access is also
> > O(1) according to https://wiki.python.org/moin/TimeComplexity. This
> > means I do not need to think much about how I will use the lines of a
> > file, when reading in the file. A Python list will be appropriate.
> >
> > So in Guile I sometimes feel some mental overhead of thinking about the
> > choice of data structure, which I do not feel in Python. Generally I
> > like Guile a lot more, so I would like to know how others deal with
> > this. Here are some ideas for it:
> >
> > 1. I could create some abstraction layer for the "sequence of read
> > lines", which I use inside the procedure, which reads in the lines and
> > all other code, that works with the lines, so that I can rather easily
> > later exchange the data structure. A data abstraction. However, that
> > might only hide the complexities of some operations behind the
> > abstraction and not reduce them.
> >
> > 2. Perhaps I want Guile's arrays? (Can they be expanded in O(1)? I do
> > seem to remember reading, that Guile vectors are only a special case of
> > Guile arrays, so that would mean they are not expandable in O(1).)
> >
> > 3. Just convert list to vector after reading in the file until I hit a
> > problem, where that additional O(n) really becomes a problem. (In my
> > current project it is not realistically a problem.) But this does not
> > satisfy me. I should learn how to solve the problem in general and use
> > the best way to do things.
> >
> > 4. Perhaps I need to write another data structure, that creates a new