Post by Joshua BransonYou can play with Guile without much C knowledge and I dare to say that you
need little of C with things like guile-bytestructures or nyacc's ffi-helper
to use the full power of GNU Guile.
Can you elaborate on guile-bytestructures and nyacc's ffi-helper?
To get started, with guile foreign function interface [0]. You can
dynamically
load shared libraries .so files and access its content as pointers. You
can
convert pointers to scheme procedures or bytevectors. Playing with
function pointers
as procedures is very easy and is demonstrated in the manual page in
dynamic ffi [0].
[0] https://www.gnu.org/software/guile/manual/html_node/Dynamic-FFI.html
Playing with bytevectors ie. memory region ie. struct ie. arrays is
another story.
That's where guile-bytestructures comes in. With guile-bytestructures
you can
describe the layout of a memory region aka. a struct and they access
that struct
from guile. guile-bytestructures supports struct, arrays, function
pointers, unions
and packing!
Basically guile-bytestructures allows to represent and manipulate C
struct in Scheme.
A good live example of using guile-bytestructures is
https://gitlab.com/guile-git/guile-git
Here is another more recent example (ie. that SHOULD have learned from
previous mistake)
use of guile-bytestructures. It's not packaged in guix yet. It's way
more simpler that
guile-git bindings because it only has to deal with structures and there
is not memory
management or other weird stuff to do. Look into guile-sqlite for a
simple use of ffi.
Or gnunet-guile2
https://gnunet.org/git/gnunet-guile2.git/tree/gnunet.scm or guile-gdbm.
nyacc ffi-helper is built on top of a C parser written in guile and
guile-bytestrucutres.
The process to build a binding library in guile (and in most languages)
is to take the C
header file with .h extension associated with the shared library and go
through everything
that is defined in that file and code in Scheme the glue that is
required to access and
manipulate them. This is OK task for simple libraries like function-only
libraries that
manipulates basic data types like string, integers. But for more
complicated libraries
it's rather painful and more importantly it's a task that is very
repetitive.
That's why nyacc ffi-helper was created. nyacc ffi helper will read
header files and write
a guile scheme module glue code that will help in the process of
creating bindings. I imagine
that in some cases you only need that glue code to have _good_ Guile
bindings.
Beware that I did not try recently nyacc ffi-helper. The maintainer of
nyacc did several
demos of getting it working. I believe it requires more love and use.
That's why I write
about it.
If you show enough interest I might create a self contained example use
of
guile-bytestructures (and nyacc ffi helper).
Post by Joshua BransonIs that a recommended/portable way to use guile to call C functions?
guile-bytestructures is reported to be portable across scheme
implementation,
but I only used it on GNU/Linux with Guile.
Yes, I recommend the use of guile-bytestructures when it makes sens ie.
when
you have to deal with C structures.
It's not in Guile stdlib because I don't know why. Most recent bindings
make use of it.
Post by Joshua BransonPost by Joshua BransonIs there a programming resource for
userspace/kernel software
what do you mean by kernel software?
My short term goal right now is to be able to write GNU/Hurd
translators
in guile. My long term goal is to be a GNU/Hurd developer.
Sorry, I don't know what is a GNU/Hurd translators.
Post by Joshua BransonPost by Joshua Bransonas good as w3schools.com?
You might not be aware that w3schools has a bad reputation of being
"loosy". That said I find it
convenient as quick and dirty reference. I recommend to check mozilla
developer network aka. mdn
when it comes to web stuff.
What do you mean by "loosy?"
Sorry, I just repeated what I read elsewhere. What I should have said is
that w3cshools is not the
only source of information regarding web. But say, for instance, its
xpath tutorials are nice. Nowdays
I use MDN more often than w3cschools.
Post by Joshua BransonWhat do you want to make?
It would be cool to help work on an official GNU distro, using a kernel
that is NOT linux. Linux is cool and good, but I'm not a fan of its monolithic nature.
Monolitihc has its advantages whatever you think monolith means. See for
instance,
this convo and article https://news.ycombinator.com/item?id=17499137
I can not stop you from looking into Hurd, but I can not help you. Maybe
try
hurd mailing list or guix-help.
See you around!