Changes between Version 5 and Version 6 of Keywords


Ignore:
Timestamp:
05/06/11 10:37:52 (6 years ago)
Author:
alaric
Comment:

Added more detail, and drew some conclusions

Legend:

Unmodified
Added
Removed
Modified
  • Keywords

    v5 v6  
    1 There seems to be a serious issue with how we handle keywords (by which we mean, things like the `else` in `cond`). R5RS was vague on the matter, and each choice of implementation approach seems to have issues. 
     1There seems to be a serious issue with how we handle keywords (by which we mean, things like the `else` and `=>` in `cond`). R5RS was vague on the matter, and each choice of implementation approach seems to have issues. 
    22 
     3Thing which need considering: 
     4 
     5 * `else` and `=>` in `cond` 
     6 * `else` in `case` 
    37 * Is `syntax-rules` a keyword in this sense?  Some Schemes say yes, others no. 
     8 * And how about `unquote` and `unquote-splicing` within `quote`? 
    49 
    5 The R6RS standard decided to use explicitly exported and defined auxiliary syntax values, where every syntax-rules literals clause matched hygienically using `free-identifier=?`. 
     10The R6RS standard decided to use explicitly exported and defined auxiliary syntax values, where every syntax-rules literals clause matched hygienically using `free-identifier=?`. This is a particular case of the "Keywords as Bindings" option below. 
    611 
    712Let's summarise the issues with different approaches. 
     
    1722== Keywords as Bindings == 
    1823 
    19 Under this scheme, `else` is bound to something (a value? a macro? a pineapple?) along with the definition of `cond`, and we check that the same binding is in place when `else` is used in the wild. 
     24Under this scheme, `else` and `=>` are bound to something (a value? a macro? a pineapple?) along with the definition of `cond`, and we check that the same binding is in place when `else` is used in the wild. 
    2025 
    2126This means that if we do: 
     
    3439 
    3540Please add alternative implementation techniques here, and discuss their problems and characteristics. 
     41 
     42== Conclusions == 
     43 
     44It looks like the problems can be avoided by: 
     45 
     46 * Not allowing the choice of a keyword or an arbitrary expression. `cond` suffers because one might bind a variable called `else` and then attempt to check the truthfulness of its value as a `cond` test. `case`'s `else` appears in a context where that would be impossible. 
     47 * For cases where keywords and arbitrary expressions (or, more precisely, references to variables) can collide, it looks like "Keywords as Bindings", with the keywords bound to special sentinel syntax values and compared as being the same identifier, is the best approach. 
     48 
     49Can anyone refute that?