summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <mail@jao.io>2022-07-31 04:32:35 +0100
committerjao <mail@jao.io>2022-07-31 04:36:04 +0100
commitb1c520f57da0131cec7a32fc0f4df4fcd1549899 (patch)
treea3f0a567df4dfd24f5a5e4acdb7fe5f8f48dccc1
parent101a4b081648bad9332a644dbb6bf5f7b0f4cd1f (diff)
downloadblog-b1c520f57da0131cec7a32fc0f4df4fcd1549899.tar.gz
blog-b1c520f57da0131cec7a32fc0f4df4fcd1549899.tar.bz2
playing with eli's toys
-rw-r--r--img/mzfam.pngbin0 -> 57336 bytes
-rw-r--r--posts/playing-with-elis-toys.org54
2 files changed, 54 insertions, 0 deletions
diff --git a/img/mzfam.png b/img/mzfam.png
new file mode 100644
index 0000000..2dbd39e
--- /dev/null
+++ b/img/mzfam.png
Binary files differ
diff --git a/posts/playing-with-elis-toys.org b/posts/playing-with-elis-toys.org
new file mode 100644
index 0000000..27185a1
--- /dev/null
+++ b/posts/playing-with-elis-toys.org
@@ -0,0 +1,54 @@
+#+title: playing with eli's toys
+#+date: <2007-05-20 02:41>
+#+filetags: programming auld norss
+
+Some weeks ago, as a way to give a serious try to the PLT environment, i wrote
+my first (and only so far) PLT package, [[http://planet.plt-scheme.org/package-source/jao/mzfam.plt/1/2/html/mzfam.html][MzFAM, a File Alteration Monitor for
+MzScheme]]. MzFAM consists of a set of PLT-scheme modules providing utilities to
+monitor and react to filesystem changes. It exports a high-level interface
+consisting of monitoring tasks that run as independent threads and invoke
+callback procedures each time a file alteration is detected. These high-level
+tasks are implemented using either Linux's [[http://oss.sgi.com/projects/fam/][FAM]]/[[http://www.gnome.org/~veillard/gamin/][Gamin]] monitors or, in systems
+where it is not available, a pure Scheme fall-back implementation. (A native
+implementation for BSD systems, based on the [[http://www.madison-gurkha.com/publications/kqueue/][kevent/kqueue]] system calls (see
+also [[http://people.freebsd.org/~jlemon/papers/kqueue.pdf][this nice article]] to learn more), is on the works.)
+
+As you'll see in the link above, i took the time to (try to) write a decent
+user manual, using [[http://www.ccs.neu.edu/home/dorai/tex2page/][tex2page]] (which is included in the PLT distribution, but
+can be used as a standalone program), a nice tool to write HTML manuals using
+TeX markup and, if you're so inclined, embedded Scheme directives.
+
+MzFAM's implementation served me as an introduction to a couple of wonderful
+Scheme libraries, both of them authored by Eli Barzilay. In the first place, i
+needed a foreign function interface to access FAM's C library. Eli's [[http://download.plt-scheme.org/doc/360/html/foreign/foreign.html][FFI]] is
+just a piece of beauty: aided by the magic of /dlopen/ and friends, one can
+access C libraries without writing a single line of C code. See, for instance,
+[[http://hacks-galore.org/darcs/darcs?r=mzfam;a=headblob;f=/kevent.ss][this wrapper]] of the kevent/kqueue system calls, which will hopefully work as a
+non-trivial example while you read the [[http://download.plt-scheme.org/doc/360/html/foreign/foreign.html][FFI manual]]. Will Farr has also put the
+FFI to [[http://wmfarr.blogspot.com/2007/04/linear-algebra-in-plt-scheme.html][pretty good use recently]].
+
+[[https://jao.io/img/mzfam.png]]
+
+MzFAM has to choose at run time among several underlying implementations of
+the monitoring, and i've used generic functions to fulfil this need. No
+rocket science here: run-of-the-mill polymorphism is enough, but i took the
+chance to play with the second of Eli's jewels, namely, his implementation of
+CLOS for Scheme, [[http://barzilay.org/Swindle/][Swindle]]. Now, Scheme object systems are a dime a dozen, and
+many of them claim some degree of resemblance to [[http://www.dreamsongs.com/CLOS.html][CLOS]], but Swindle is, by a
+long stretch, the closest to the real thing i've used--why, there're even some
+syntactical spots where it is actually nicer than CLOS itself, and is the only
+(besides Dorai Sitarm's [[http://www.ccs.neu.edu/home/dorai/scmobj/scmobj.html][ScmObj]]) Scheme object system i know of that provides
+before/after/around advising. Swindle also comes with a fairly complete MOP
+implementation, and i'm looking forward to using it after reading [[http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=10443][Andreas
+Paepcke's book]] on CLOS (which, incidentally, i bought after reading its freely
+available chapter 3, [[http://infolab.stanford.edu/~paepcke/shared-documents/mopintro.ps][User-Level Language Crafting: Introducing the CLOS
+Metaobject Protocol]] (PS)). All that said, please don't take MzFAM as a good
+example of putting CLOS to work: i'm just a beginner.
+
+Finally, let me mention another nice PLT feature i've used (although this one
+is not, as far as i know, an Eli's hack): the [[http://planet.plt-scheme.org/][PLaneT Package
+Repository]]. Extremely convenient, and a breeze to set up, both from the user's
+and the developer's perspective, and yet another reason for giving PLT a
+serious try.
+
+Happy monitoring!