chicken-users
[Top][All Lists]
Advanced

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

Re: What are the long-term goals for R7RS in Chicken?


From: Lassi Kortela
Subject: Re: What are the long-term goals for R7RS in Chicken?
Date: Sun, 18 Jul 2021 15:02:54 +0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

Currently you can switch to R7RS more by installing the egg and running csc
with "-R R7RS -X R7RS", which is a mouthful, and could be abbreviated, that
doesn't look to me like too much hassle.

Anybody for a "-r7rs" option that does the above?

+1 for an easy command line flag!

Gauche and Sagittarius Scheme have an "-r" flag so you can run "sagittarius -r 6" or "gosh -r 7". Using one flag gives simple upward compatibility to "-r 8", "-r 9" in the future, and also non-RnRS standards or modes, should the need arise. Neither csc nor csi is yet using the "-r" flag for anything, so the uniformity would be nice. It also has nice symmetry with the upper case "-R" flag for extensions.

A good question. I think the Chicken "native" language and module system
is likely to be used more often than a R7RS mode, so I don't think there are
any attempts to make Chicken "more R7RS". As you say, the differences
are not that substantial.

If there are few substantial differences, it would be a boon to writing portable code if the same syntax is eventually used as for standard R7RS libraries, and the same filename conventions are supported as other R7RS implementations (the .sld filename extension for an R7RS library is becoming a de facto standard). You already support (include "...") and (cond-expand ...) in a similar manner as R7RS.

Here's how a typical module would look, before:

;;-----------------------------------------------------------------------------
(module lowdown

  (markdown->sxml
   markdown->sxml*
   markdown-sxml->html-sxml
   markdown->html
   markdown-html-conversion-rules*)

  (import scheme)

  (cond-expand
   (chicken-4
    (import chicken)
    (use data-structures
         irregex
         srfi-1
         clojurian-syntax
         comparse
         sxml-transforms
         lowdown-lolevel))
   (chicken-5
    (import (chicken base)
            (chicken irregex)
            (scheme)
            (srfi 1)
            (clojurian syntax)
            (comparse)
            (lowdown lolevel)
            (sxml-transforms))))

  ...code here...)
;;-----------------------------------------------------------------------------

And after:

;;-----------------------------------------------------------------------------
(define-library (lowdown)
  (export markdown->sxml
          markdown->sxml*
          markdown-sxml->html-sxml
          markdown->html
          markdown-html-conversion-rules*)
  (cond-expand
   (chicken-5
    (import (scheme base)
            (chicken base)
            (chicken irregex)
            (srfi 1)
            (clojurian syntax)
            (comparse)
            (lowdown lolevel)
            (sxml-transforms))))
  (begin ...code here...))
;;-----------------------------------------------------------------------------

Functors could use the existing syntax:

(functor (squaring-functor (M (multiply))) (square)
  (import scheme M)
  (define (square x) (multiply x x)))

or spell it `define-functor` for consistency.

It should be possible to preserve the old (module ...) and (functor ...) syntax for backward compatibility so current modules keep working with no code changes.



reply via email to

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