Here's how you might write a library in r7rs draft 8 using s-expressions:

(define-library (amkg meow)
(export meow)
(import (scheme base))

(begin

(define (meow) (cat "meow" "meow"))

(define (cat . xs)
  (for-each
    (lambda (x)
      (display x) (newline))
    xs))

) ; begin
) ; define-library

With proposed 0.7 semantics, it can be expressed in t-exprs as:

<* define-library \\ (amkg meow)
export meow
import (scheme base)

<* begin

define meow() $ cat "meow" "meow"

define cat(. xs)
  for-each
    lambda (x)
      display x \\ newline()
    xs

*>
*>

I'm proposing, however, that the COLLECTINGLISTEND tokens should be
*optional*, since we expect the "large" usage of collecting lists to
encompass entire files.

That way, we can say in style guidelines for R7RS t-exprs:

--

*  To create an R7RS library out of a bunch of definitions in a file,
simply put something like the following at the top of your file; there
is no need to change your existing formatting of existing definitions:

<* define-library \\ (your library name)
export
  your-definition
  rename internal:your-definition external:your-definition
  ...
import
  (scheme base) ; you likely need this
  (some other library)
  ...
other-library-declaration-such-as-include-or-cond-expand
...

<* begin

define your-definition ...
...

* To create R6RS libraries, use something effectively similar to the
above, except you can only use "export" and "import", and exactly in
that order, make sure to import "(rnrs base (6))" instead of "(scheme
base)", and use "library" instead of "define-library".

--

Basically, we allow the user to remove trailing *> if the collecting
list is the last thin of importance in a file.  This is important
since in R7RS a library definition will have two trailing close parens
(one for the begin containing the definitions, the other for the
define-library) and we need two extra lines to contain the trailing *>
(I'm not sure what happens with "*> *>" on a line by itself; maybe
that'll work too, but still...)

I feel this reduces some of the line-noisiness of collecting lists
while allowing a more flexible indenting / spacing of library
definitions.

What you think?

Sincerely,
AmkG

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss

Reply via email to