guile-devel
[Top][All Lists]
Advanced

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

Re: Guile Assembler


From: Panicz Maciej Godek
Subject: Re: Guile Assembler
Date: Wed, 24 Jun 2015 23:54:38 +0200



2015-06-24 11:44 GMT+02:00 Panicz Maciej Godek <address@hidden>:

I could prepare a smaller version of the module that perhaps could make it into the official distribution, if guile maintainers have nothing against, and send a patch

I include the aforementioned.
It is not a patch though, but just a separate module called (ice-9 nice-9) that is meant to be placed in the "ice-9" directory (e.g. "/usr/share/guile/2.0/ice-9").

It would definitely need a more elaborate documentation, but the quick note is that it:

* allows to destructure arguments to lambda, e.g.

(map (lambda ((a . b)) (+ a b)) '((1 . 2)(3 . 4)(5 . 6)))

* blends named-let with match-let and srfi-71-style let for multiple values, legalizing usages like

(let loop ((a (b c) (values 1 (list 2 3))))
  ...
  (loop (values 4 (list 5 6))))

(although this may not seem to be a good way of programming, I think that imposing artificial limitations on how the language can be used would be even worse)

* blends match-let* with srfi-71-style let* for multiple values

* blends srfi-2 and-let* with pattern matcher, so that one can finally do things like

(and-let* (((a b c d) '(1 2 3)))
  (+ a b c d))

(which evaluates to false, of course)

* allows to use curried definitions like (ice-9 curried-definitions), but such that are already blended with the pattern-matching lambda

(define ((f (a b)) (c))
  (list a b c))

* in addition, it re-exports "match" from (ice-9 match) and "every", "any" and "count" from (srfi srfi-1)


I think that this set of extensions is non-controversial and it is handy to gather them in a single module. It only allows to use the commonly used features that would otherwise be illegal, and it does so in a predictable way.

I re-export "every" and "any" because they are used by some of the macros. I also re-export "count" in order to make the count of (re)exported symbols equal 9, so that the module deserves its name, but this is mostly for a pun.

Also, I just copied and modified the macros in order to get rid of some dependencies, but I only tested the code superficially

Best regards

Attachment: nice-9.scm
Description: Text Data


reply via email to

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