Changeset 40510 in project


Ignore:
Timestamp:
09/10/21 18:24:10 (13 days ago)
Author:
felix winkelmann
Message:

updated r7rs-tasks page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/r7rs-tasks

    r32262 r40510  
    33== R7RS Tasks
    44
    5 ''(first draft, by felix)''
     5=== General structure
     6
     7The [[/eggref/5/r7rs|r7rs egg]] has been implemented and provides basic
     8support for R7RS features not already implemented in the core system.
     9There are still a number of incompatibilities and some missing functionality.
     10
     11Open is also whether more features should move to the core system or
     12whether support of the language as an egg provides integration enough
     13to not annoy users who simply want to code in R7RS with minimal effort.
     14
     15The remaining document tries to reflect the current status of R7RS Scheme
     16support on CHICKEN.
    617
    718''comments by John Cowan marked with JC:''
    8 
    9 === General structure
    10 
    11 I currently assume that R7RS support will be provided by an egg and a
    12 minimal set of core enhancements for performance-sensitive
    13 functionality or features that would require extensive customization
    14 of existing code.
    15 
    16 R7RS library names (lists) can be mapped to module names by
    17 concatenating the constituents of a library name, separated by "."
    18 (dot), for example:
    19 
    20   (foo bar baz)   ->   foo.bar.baz
    21 
    22 The egg needs to provide a compile-time layer for the expansions of
    23 library forms and import-resolution in addition to a full set of
    24 standard libraries. Using the {{r7rs}} egg (for example with
    25 {{require-extension}}) will automatically load and import all r7rs
    26 standard libraries into the toplevel environment. On the other hand
    27 R7RS modules defined with "define-library" will have initially only
    28 {{import}}, which will be needed to expand imports (strictly speaking,
    29 the initial module environment should be empty, but this is how the
    30 module system currently works).
    31 
    32 There is probably no way around including the full numeric tower -
    33 providing a mode with a restricted set of numeric types would
    34 complicate the R7RS support quite considerably. The
    35 [[/eggref/4/numbers|numbers]] egg is likely to need some enhancements
    36 ({{equal[=]?}} with handling of circular data, see below).
    37 * JC: I don't understand why things would be complicated with CHICKEN's default fixnum/flonum support.  There is no {{equal=?}} in R7RS, and {{equal?}} should not be affected.
    38 * JC: What about making full Unicode support the default?  R7RS does not require it, but it might be better so.
    39 
    40 Full type-declarations for all exports should be provided, both for
    41 error checking and performance. It would also be worthwhile to
    42 identify small inlinable R7RS primitives and generate ".inline" files
    43 for all standard libraries, if candidates for global inlining exist.
    44 
    45 Some R7RS primitives are partially or completely provided by SRFI-1
    46 and SRFI-13, but I think it would be better to implement them
    47 directly, to make them as efficient as possible. The existing code is
    48 in many cases not tuned to the implementation and makes assumptions
    49 about Scheme code performance that may have been valid 30 years ago
    50 but aren't anymore nowadays.
    5119
    5220=== Todo
     
    6028* {{equal?}} must not diverge
    6129* {{with-exception-handler}} thread safety
     30* Feature identifiers as in Appendix B (see below)
    6231
    6332Nice to haves:
     
    7847; (?) : Needs to be clarified
    7948
    80 === Changes that are likely to be implemented in the core system
     49=== Currently unimplemented changes
    8150
    8251==== 2.1. Identifiers
     
    8453* {{|...|}} needs support for {{\x...;}} escape syntax, which is not fully compatible to the existing {{\xXX}} format. A backwards-compatible change should be possible but will have ambiguous cases like {{|\x12;|}}. (X)
    8554
    86 * {{#!fold-case}}, {{#!no-fold-case}}. Do these apply over files? (for example when used inside included files) (+)
    87 ** JC: They apply only to the file in which they appear, not to any included or including file, because they work at a lower level (that is, {{read}} implements them).
    88 ** PB: This is a problem, because our "case-sensitive" parameter is global, not bound to the port.  Here's a test case that I came up with for this (it can go into tests/r7rs-tests.scm):
    89 ** EH: Pushed to egg under {{(scheme read)}}.
    90 
    91 <enscript highlight="scheme">
    92 (SECTION 2 1)
    93 
    94 (test '(mooh qux blah foo BAR)
    95       (append
    96        (with-input-from-string
    97            "#!fold-case mooh QUX blah #!no-fold-case foo BAR" read-file)))
    98 
    99 ;; #!(no-)fold-case "affect the reading of subsequent data *from the same port*"
    100 (test '(foo bar downcased UPCASED)
    101       (append
    102        (with-input-from-string
    103            "#!fold-case foo BAR" read-file)
    104        (with-input-from-string
    105            "downcased UPCASED" read-file)))
    106 </enscript>
    107 
    108 From what I can see, this means a flag needs to be added to the
    109 *port*, so that repeated invocations of READ can communicate this to
    110 eachother.
    111 
    112 ==== 4.2.2. Binding constructs
    113 
    114 * {{letrec*}}. Change all internal uses of {{letrec}} to {{letrec*}} and add a correct implementation of {{letrec}}. This will produce a bootstrapping problem (the compilation of syntactic forms that expand into uses of {{letrec*}} will require a compiler with support for {{letrec*}}), which can be solved but needs to be done with care. (+)
    115 ** JC: In R7RS (though not in R6RS), {{letrec*}} ''is'' a valid implementation of {{letrec}}, which retroactively approves CHICKEN's strategy.  So nothing needs to be done except to add {{letrec*}} as a synonym for {{letrec}}.
    116 ** EH: Pushed to core.
    117 
    118 ==== 4.2.5. Delayed evaluation
    119 
    120 * {{delay-force}}. I don't know how this works, it may be useful to have this in the core-system, though. (?)
    121 ** JC: See SRFI 45.  The R7RS {{delay}}, {{force}}, {{delay-force}}, and {{make-promise}} in R7RS correspond exactly to {{delay}}, {{force}}, {{lazy}}, and {{eager}} in that SRFI.
    122 ** EH: Pushed to core.
    123 
    124 * {{make-promise}}: expose wrapper for {{##sys#make-promise}}. (+)
    125 ** EH: Pushed to core.
    126 
    127 ==== 4.3.2. Pattern language (syntax-rules)
    128 
    129 * "Underscores also match arbitrary input elements but are not pattern variables ...": is this currently the case? (?)
    130 ** PB: Not currently the case, underscore is treated like any other identifier. Patch posted to -hackers to change this.
    131 ** EH: Pushed to egg.
    132 
    133 * {{(<ellipsis> <template>)}}. This is currently not available, IIRC. (? *)
    134 ** PB: Indeed not available yet. Patch posted for that as well.
    135 ** EH: Pushed to egg.
    136 
    137 ==== 6.3. Booleans
    138 
    139 * Add {{#true}}, {{#false}}. (+)
    140 ** EH: Pushed to egg.
    141 
    142 (BTW, I find these depressing. Is it really so difficult for newcomers to learn {{#t}} and {{#f}}?)
    143 
    144 JC: The theory is that {{#t}} and {{#f}} are too easily mistaken for each other by a human reader.  I don't find it so, but apparently others do.
    145 
    146 ZB: I would also suggest {{#one}} and {{#ell}} to prevent further ambiguity.  Repeat recursively for {{#ell}} as needed.
    147 
    148 AS: ZB: Actually, programmers I know fairly universally avoid using single lowercase "l" as a variable name for precisely that reason.
    149 
    15055==== 6.6. Characters
    151 
    152 * Additional named chars ({{#\alarm}}, ...) (+)
    153 ** PB: Implemented and pushed to core.
    154 
    155 * Can someone explain to me what {{char-foldcase}} does? (?)
    156 ** JC: On an ASCII platform, {{char-foldcase}} and {{string-foldcase}} are the same as {{char-downcase}} and {{string-downcase}} respectively.  For Unicode, {{char-foldcase}} implements [[http://www.unicode.org/Public/UNIDATA/CaseFolding.txt|Unicode case folding]], specifically the table entries marked with "C" and "S", but not those marked with "F" or "T".  {{string-foldcase}}, on the other hand, implements the table entries marked with "C" and "F", but not those marked with "S" or "T".
    157 ** EH: Pushed to egg (ASCII-only).
    158 
    159 * Extend {{char=?}}, {{char<?}} et al. to accept arbitrarily many arguments. (+)
    160 ** EH: Pushed to egg.
    16156
    16257==== 6.7. Strings
    16358
    164 * {{\a}} escape syntax. (+)
    165 ** PB: Implemented and pushed to core.
    166 
    167 * {{\<Intraline whitespace>}}. (+)
    168 ** PB: Implemented and pushed to core.
    169 
    17059* {{\x...;}} syntax. The same issues as in {{|...|}} identifier names. (X)
    171 
    172 * Extend {{string=?}}, {{string<?}} et al. to accept arbitrarily many arguments. (+)
    173 ** EH: Pushed to egg.
    174 
    175 
    176 ==== 6.8. Vectors
    177 
    178 * Self-evaluating vectors.
    179 ** PB: Implemented and pushed to core.
    180 
    181 (My heart bleeds)
    182 
    183 
    184 ==== 6.9. Bytevectors
    185 
    186 * Self-evaluating u8vectors.
    187 ** PB: Implemented and pushed to core.
    188 
    189 * Note for future hackers:  it's right to implement bytevectors as u8vectors, not as blobs, for better compatibility with pre-R7RS CHICKEN code.  You just can't do enough with blobs.
    190 
    191 ==== 6.13.3. Output
    192 
    193 * {{write}}. Support for labels and circle-detection. This probably needs to be implemented in the core reader or will require ugly hooks that we probably want to avoid. (*)
    194 ** EH: Pushed to egg.
    19560
    19661==== Appendix B
    19762
    198 * Without a canonical list of features and their exact meaning this is mostly useless. (?)
     63* Without a canonical list of features and their exact meaning this is mostly useless.
    19964** JC: The ones that CHICKEN should provide are {{r7rs}}, {{ieee-float}}, and either {{posix}} or {{windows}} as the case may be.  If the full numeric tower is provided, add {{exact-closed}}, {{exact-complex}}, and {{ratios}}.  If Unicode is provided, add {{full-unicode}}.  This should be integrated with the CHICKEN native {{(features)}} list.
    200 
    201 === Implementations in the r7rs egg that override core functionality
    202 
    203 ==== 4.1.7. Inclusion
    204 
    205 * Multi-argument {{include}}, {{include-ci}} (+)
    206 ** EH: Pushed to egg.
    207 
    208 ==== 4.2.1. Conditionals
    209 
    210 * {{=>}} in {{case}} constructs (+)
    211 ** PB: Pushed to core.
    212 
    213 * {{cond-expand}} needs support for {{library}}. This may need to scan available modules (i.e. query the repository for installed extensions) (*)
    214 ** JC: Just so.
    215 ** EH: Pushed to egg.
    216 
    217 ==== 4.2.6 Dynamic bindings
    218 
    219 * There is no problem with using CHICKEN parameters directly as R7RS parameters.
    220 
    221 ==== 5.2. Import declarations
    222 
    223 * {{import}}. A library name may not begin with a modifier-keyword like {{only}}, right? (? *)
    224 ** JC: Right.  The important thing here is that in an R7RS library or program, {{import}} is CHICKEN's {{use}}.
    225 ** EH: Pushed to egg.
    226 
    227 ==== 5.3.3. Multiple-value definitions
    228 
    229 By having {{letrec*}} semantics for internal definitions, this implementation of {{define-values}}
    230 by Alex Shinn is sufficient for handling toplevel and local multiple-value definitions (special
    231 handling in lambda-body expansion is not necessary anymore):
    232 
    233 <enscript highlight=scheme>
    234 (define-syntax define-values
    235   (syntax-rules ()
    236     ((_ (var  ...) expr)
    237      (define-values-sub () (var ...) () expr))
    238     ((_ . else)
    239      (syntax-error "malformed define-values" (define-values . else)))
    240     ))
    241 
    242 (define-syntax define-values-sub
    243   (syntax-rules ()
    244     ((_ (tmp ...) (last-var) (var ...) expr)
    245      ;; place the last var at the start of the list
    246      (define-values-sub (tmp1 tmp ...) () (last-var var ...) expr))
    247     ((_ (last-tmp tmp ...) () (last-var var ...) expr)
    248      (begin (define var #f) ... ;(undefined)
    249             (define last-var
    250               (receive (tmp ... last-tmp) expr
    251                 (set! var tmp) ...
    252                 last-tmp))))
    253     ((_ (tmp ...) (v v2 ...) (var ...) expr)
    254      (define-values-sub (tmp ... tmp1) (v2 ...) (var ... v) expr))
    255     ))
    256 </enscript>
    257 
    258 ==== 5.5. Record-type definitions
    259 
    260 * {{define-record-type}}. Is generative (*)
    261 ** EH: Pushed to egg.
     65** FW: This should be implemented in the core system.
    26266
    26367==== 5.6.1. Library syntax
     
    26569* The {{export}} declaration will require renaming, which is currently not available in the module system. Requires a bit of work. (*)
    26670
    267 ==== 5.7 The REPL
    268 
    269 * Doing {{(use r7rs)}} at the REPL should import {{(scheme base)}}, but it doesn't.
    270 
    27171==== 6.1. Equivalence predicates
    27272
    27373* {{eqv?}} may have some corner cases for funny IEEE values (nan, etc.). (?)
    27474
    275 * {{equal?}} must handle circular data. Change this in core? Probably, since this needs to be fast. Applies to {{equal=?}} as well. (? *)
    276 
    277 ==== 6.4. Pairs and lists
    278 
    279 * {{make-list}}. See SRFI-1. (+)
    280 ** EH: Pushed to egg.
    281 
    282 * 3-argument {{member}} and {{assoc}}. See SRFI-1. (+)
    283 ** EH: Pushed to egg.
    284 
    285 ==== 6.7. Strings
    286 
    287 * {{string->list}} with start/end arguments. (+)
    288 ** EH: Pushed to egg.
    289 
    290 * {{string-copy}}, {{string-copy!}} and {{string-fill!}} with start/end arguments. See SRFI-13. Provide specializations for case when limits are not given. (+)
    291 ** EH: Pushed to egg (w/o specializations ATM).
    292 
    293 ==== 6.8. Vectors
    294 
    295 * {{vector->list}}, {{list->vector}} and {{string->vector}} with start/end arguments. Provide specializations. (+)
    296 ** EH: Pushed to egg (w/o specializations ATM).
    297 
    298 * {{vector-copy!}} and {{vector-fill!}} with start/end arguments. (+)
    299 ** EH: Pushed to egg.
    300 
    301 ==== 6.10. Control features
    302 
    303 * {{string-map}} and {{string-for-each}} are not compatible with SRFI-13 version. (+)
    304 ** EH: Pushed to egg.
     75* {{equal?}} must handle circular data. Change this in core? Probably, since this needs to be fast. Applies to {{equal=?}} as well.
    30576
    30677==== 6.11. Exceptions
     
    31283* Implementing {{guard}} correctly will need some thought, due to the wild jumping between dynamic environments. (*)
    31384
     85=== List of R7RS features that are provided by the [[/eggref/5/r7rs|r7rs egg]]
     86
     87==== 2.1. Identifiers
     88
     89* {{#!fold-case}}, {{#!no-fold-case}}.
     90
     91==== 4.1.7. Inclusion
     92
     93* Multi-argument {{include}}, {{include-ci}}.
     94
     95==== 4.2.1. Conditionals
     96
     97* {{cond-expand}} support for {{library}}.
     98
     99==== 4.3.2. Pattern language (syntax-rules)
     100
     101* "Underscores also match arbitrary input elements but are not pattern variables ..."
     102
     103* {{(<ellipsis> <template>)}}. This is currently not available, IIRC.
     104
     105==== 5.2. Import declarations
     106
     107* {{import}}. A library name may not begin with a modifier-keyword like {{only}}.
     108
     109==== 5.5. Record-type definitions
     110
     111* {{define-record-type}}, generative.
     112
     113==== 6.3. Booleans
     114
     115* {{#true}}, {{#false}}
     116
     117==== 6.4. Pairs and lists
     118
     119* {{make-list}}. See SRFI-1.
     120
     121* 3-argument {{member}} and {{assoc}}. See SRFI-1.
     122
     123==== 6.6. Characters
     124 
     125* {{char-foldcase}} currently only supports ASCII
     126
     127* Extend {{char=?}}, {{char<?}} et al. to accept arbitrarily many arguments
     128
     129==== 6.7. Strings
     130 
     131* Extend {{string=?}}, {{string<?}} et al. to accept arbitrarily many arguments.
     132
     133==== 6.7. Strings
     134
     135* {{string->list}} with start/end arguments.
     136
     137* {{string-copy}}, {{string-copy!}} and {{string-fill!}} with start/end arguments. See SRFI-13.
     138
     139==== 6.8. Vectors
     140
     141* {{vector->list}}, {{list->vector}} and {{string->vector}} with start/end arguments. Provide specializations.
     142
     143* {{vector-copy!}} and {{vector-fill!}} with start/end arguments.
     144
     145==== 6.10. Control features
     146
     147* {{string-map}} and {{string-for-each}} are not compatible with SRFI-13 version.
     148
    314149==== 6.12. Environments and evaluation
    315150
    316 * {{environment}}. Not sure how to do this. (? *)
    317 ** JC: The point of these environments is that they can be passed to {{eval}}; they are parallel to the environments returned by {{scheme-report-environment}}, {{null-environment}}, and {{interaction-environment}}.
    318 ** EH: Pushed to egg.
    319 
    320 * Clarify immutability of environments. Can we just ignore this requirement? (?)
    321 ** JC: In practice, yes.
    322 ** EH: Pushed to egg (by way of doing nothing at all).
     151* {{environment}}.
    323152
    324153==== 6.13.1. Ports
    325154
    326 * {{get-output-string}}. Does it clear the buffer, as it does in SRFI-whatever? (?)
    327 ** No, it doesn't, as in SRFI 6.
    328 ** EH: Pushed to egg (by simply reexporting {{get-output-string}}).
     155* {{get-output-string}}.
    329156
    330157==== 6.13.3. Output
    331158
    332 * {{write-string}} with start/end arguments. (+)
    333 ** EH: Pushed to egg.
     159* {{write-string}} with start/end arguments.
     160
     161* {{write}}. Support for labels and circle-detection.
    334162
    335163==== 6.14. System interface
    336164
    337 * 2-argument {{load}}. (?)
    338 ** JC: The second argument is passed along to {{eval}}.
    339 ** EH: Pushed to egg.
     165* 2-argument {{load}}.
    340166
    341 * {{exit}} with boolean arguments. (+)
    342 ** EH: Pushed to egg.
    343 
    344 * What the heck should be used as {{jiffy}}? On which platforms? (?)
    345 ** JC: Seconds or milliseconds as you see fit.
    346 ** EH: Pushed to egg (with milliseconds as jiffies).
     167* {{exit}} with boolean arguments.
Note: See TracChangeset for help on using the changeset viewer.