[plt-scheme] units and rightward drift

From: Neil W. Van Dyke (neil at neilvandyke.org)
Date: Mon Apr 28 23:46:26 EDT 2003

I tenaciously cling to the 79-columns rule of code formatting, so I'm
interested in syntax for reducing rightward drift in unit definitions.

Currently, I do something like this, which results in a 6-space indent
baseline for the definitions (assuming the popular indentation convention):

    |(module foo-unit mzscheme
    |
    |  (require (lib "unitsig.ss")
    |           "foo-sig.ss")
    |
    |  (define foo@
    |    (unit/sig foo^
    |
    |      (define (f1) ...
    +----------------------------
    |123456(

If adding "define-unit/sig" syntax were appropriate, the indent baseline
is reduced to 4, which is a precious gain:

    |(module foo-unit mzscheme
    |
    |  (require (lib "unitsig.ss")
    |           "foo-sig.ss")
    |
    |  (define-unit/sig foo@ foo^
    |
    |    (define (f1) ...
    +----------------------------
    |1234(

I'm guessing reducing it to 2 requires special support to be added to
the MzScheme module loader, which is unfortunate:

    |(module/unit/sig foo-unit mzscheme foo@ foo^
    |
    |  (require (lib "unitsig.ss")
    |           "foo-sig.ss")
    |
    |  (define (f1) ...
    +----------------------------
    |12(

I won't argue for reducing it to 0 (although it isn't entirely wacky,
considering that the module loader seems to want exactly one "module"
form per file, so the file constitutes a syntactic scope or extent):

    |(file-module/unit/sig foo-unit mzscheme foo@ foo^)
    |
    |(require (lib "unitsig.ss")
    |         "foo-sig.ss")
    |
    |(define (f1) ...
    +----------------------------

So... is "define-unit/sig" and/or "module/unit/sig" a good idea?

-- 
                                             http://www.neilvandyke.org/


Posted on the users mailing list.