guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scheme-defined smobs


From: Paul Jarc
Subject: Scheme-defined smobs
Date: Mon, 03 Nov 2003 12:39:38 -0500
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

It seems pointless at first, but I think it might be useful.  The
attached file (tested as an extension with 1.6.4) provides Scheme
bindings for defining smobs - i.e., the "print" and "equalp" functions
can be defined in Scheme.  This might be useful for adding
user-defined cases to equal?.  But I admit my real motivation for
writing this was to enable this gruesome hack:

guile> (define (printer smob-data port state) (system smob-data))
guile> (define generator (make-smob-type "smob-name" printer #f))
guile> (define ls (generator "ls"))
guile> (ls)
"ls"
guile> (ls "ls -a")
guile> (ls)
"ls -a"
guile> ls

... which shows me the output of "ls -a".  So I can use Guile as a
shell with a bit less typing.

Is there interest in adding this to libguile?  (Regardless, I think
the three snarfing macros at the top (along with corresponding
SCM_SMOB_FREE, SCM_SMOB_PRINT, and SCM_SMOB_EQUALP) would be useful
additions to smob.h, though perhaps the name SCM_ SMOB_APPLY is too
similar to the existing SCM_SMOB_APPLY_*.)


paul

Attachment: dynsmob.c
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]