[gambit-list] SRFI-41 and syntax-case

R. P. Dillon rpdillon at gmail.com
Wed Sep 29 10:25:13 EDT 2010


Actually, that help a lot!  I've been struggling to figure out the right
approach, and found the page on schemewiki about syntactic closures, so this
gives me a way learn more while solving the problem.

I've surveyed a few implementations of scheme that I wanted to work with,
and Gambit seems to be both popular and well-documented.  But my one gripe
was a lack of the core functional libraries I'm used to using in other
languages like Clojure and Scala.  Various SRFIs provide these, but it seems
quite a few are missing (like SRFI 41) in Gambit.  So, as I encounter
missing SRFIs, I'd like to try to bring them into blackhole if possible.

It's great to hear that you're working on a package system.  As I learn
more, I'd like to write (or port!) some libraries that could be made
available through such a system (http servers and clients, graphics
libraries and bindings, etc.)  I'm not sure how the effort relates to Snow,
but Snow seems quite outdated, so I've been focusing on blackhole instead
for the time being.

Thanks for the excellent reply.

On Wed, Sep 29, 2010 at 1:32 AM, Per Eckerdal <per.eckerdal at gmail.com>wrote:

> I would not recommend using (load "~~/lib/syntax-case") and blackhole at
> the same time. Both of these systems work by overriding Gambit's macro
> system and implementing their own. Interaction between these systems will
> not be pretty. At the moment, Blackhole doesn't have support for
> syntax-case. It's possible that it might be implemented in the future, but
> it would require changing a fundamental part of what a macro function is
> because of the stupid way syntax-case is specified. (It requires a macro to
> be a function that takes exactly one argument, ignoring the normal way of
> having macro function "creators" that abstract the macro system
> implementation, like syntax-rules, sc-macro-transformer,
> er-macro-transformer).
>
> The "blackhole way of doing it" would be to rewrite the macro to use
> syntactic closures, which is the macro system that blackhole is based on. It
> is hygienic and is also powerful enough to do everything that syntax-case
> can do. Using syntactic closures is usually easy and feels somewhat similar
> to define-macro macros. Googling on the term should bring up info on how to
> use them.
>
> One more thing that I should say is that I have been working on creating a
> package system for blackhole, which is supposed to replace blackhole-libs.
> Creating a standard library is a much more ambitious task than
> blackhole-libs ever was, and I believe that a package system would offer
> much greater flexibility and also make it easier to share code that isn't
> appropriate in a standard library. The only libraries that will stay in
> Blackhole are SRFIs, which will be bundled. So blackhole-libs will become
> obsolete. So work with SRFIs is not wasted as it's easy to move that into
> Blackhole itself.
>
> Hope this helps.
>
> 29 sep 2010 kl. 03.37 skrev R. P. Dillon:
>
> OK, I kind of suspected that was the case (i.e. there was a reason
> syntax-case was used in the first place).  Given that, is there any guidance
> on how to make a blackhole module dependent on ~~/lib/syntax-case?  Is it
> acceptable to simply use (load "~~/lib/syntax-case")?  That's the approach
> that I'm using now, and I wanted to confirm that it was an acceptable
> approach.
>
> Thanks,
> Rick
>
> On Tue, Sep 28, 2010 at 11:17 AM, Phil Bewig <pbewig at gmail.com> wrote:
>
>> Syntax-case is required because the macro binds an identifier.
>>  Syntax-rules is not powerful enough to specify that operation.
>>  Define-macro lacks hygiene and should not be considered.
>>
>> On Tue, Sep 28, 2010 at 1:05 PM, R. P. Dillon <rpdillon at gmail.com> wrote:
>>
>>> I've worked with lisps for a couple of years, but am new to the various
>>> incarnations of macro systems for Scheme (and am by no means proficient with
>>> lisp macros in general).  I'm using the "jump right in" method to learn
>>> more.
>>>
>>> I'm interested in bringing more libraries to blackhole-libs, and SRFI-41
>>> (streams) is the first I was interested in working with in my project that
>>> I'm developing in Gambit.  I've extracted the reference implementation from
>>> the SRFI, and have it working (at least in the Gambit interpreter) with just
>>> a couple of modifications.  But a problem has emerged.
>>>
>>> SRFI-41 makes use of syntax-rules, which Gambit appears to be OK with.
>>> It also has one instance of the more-general syntax-case, which appears to
>>> be a problem unless I (load "~~/lib/syntax-case") or use the "-:s" option on
>>> the command line (this is documented in the manual -- thank you!).  If I
>>> distribute the SRFI for use in e.g. blackhole, my understanding is that use
>>> of (load ...) is brittle and is Considered Harmful in modules.
>>>
>>> Is there a good approach to addressing this?  Should I attempt to
>>> re-write the syntax-case macro with either syntax-rules (I assume
>>> syntax-rules is not sufficiently powerful enough for this) or with
>>> define-macro (macros are intimidating enough as is; I worry about use of a
>>> non-hygienic variety as a newcomer...)?  Or, is there a way to require the
>>> use of the portable syntax-case implementation when the SRFI-41 module is
>>> loaded that doesn't make use of a brittle mechanism like load?
>>>
>>> I didn't want to progress too much farther without verifying this hasn't
>>> already been done or is too difficult a task.  I didn't see it in SLIB or
>>> Blackhole, and I don't think it was in Snow or the Dumping Grounds, but I
>>> might have missed it.  It seems that everything else in blackhole has
>>> avoided the use of syntax-case, but define-macro has been used in at least
>>> one place.
>>>
>>> Thanks,
>>> Rick
>>>
>>> _______________________________________________
>>> Gambit-list mailing list
>>> Gambit-list at iro.umontreal.ca
>>> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>>>
>>>
>>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20100929/18b46ddc/attachment.htm>


More information about the Gambit-list mailing list