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

Re: new draft

This page is part of the web mail archives of SRFI 62 from before July 7th, 2015. The new archives for SRFI 62 contain all messages, not just those from before July 7th, 2015.



> Taylor Campbell wrote:
> ...
>   - I've included the formal specification, based on what Al* Petrofsky
>     suggested.  (I'd like to note at this point my distaste for using
>     such cumbersome tools as BNF-style grammars for describing Lisp
>     syntax...  I attribute the complexity of the change to that, not to
>     the complexity of this SRFI; the change to the recursive-descent
>     parser shows how simple it really is.)

- the complexity is due to inconsistency of the lexical scoping specified
  resulting in the necessary surgery to scheme's otherwise simple grammar;
  which would not be necessary if the lexical scope of an <s-exp> comment
  were arguably chosen to be consistent with the languages exiting grammar.

> Regarding Aubrey Jaffer's use of #; for a different purpose: since the
> use of #; for S-expression comments is already well-established, and
> since it has already been decided upon for R6RS, I think it is better
> for this SRFI to stick with #; and for some other character sequence to
> be selected to substitute for SCM's somewhat obscure use of #;.
> 
> On the matter of nested comments: I am pretty firmly set on the current
> way S-expression comments work.  Since it's an extremely specialized
> case, since it has a very simple logical explanation, and since the
> current way things work is a very simple addition to a traditional Lisp
> recursive-descent S-expression parser, I'm inclined to stay with the
> status quo unless the suggested alternative can be shown to be as
> simple, in terms of logical explanation & recursive-descent parser, as
> the status quo.

- unfortunately not true, it's not consistent with scheme's grammar, nor
  a consistent addition to a recursive decent parser, as it's doesn't have
  a recursive lexical scoping semantics.

- more ideally would be to recognize that it may be easily be simply treated
  just as quote, etc. is parsed, where (comment ... (quote ...)) is
  equivalent to (quote ... (comment ...)), as such commenting any <s-exp> is
  yields an <empty-s-exp>, just as quoting a commented (i.e. <empty-s-exp>)
  also equivalently yields an <empty-s-exp>.

- for those so inclined, the following is a simple tweak of mzscheme's
  reader, which does just this, and please note how it's both simpler, and
  may actually prefer it's more consistent semantics:

(which basically adds two lines, and removes 20, which may imply something)

 or if preferred could forward the whole file to anyone interested.

mods to read.c :

...

  case '#':
    ch = scheme_getc_special_ok(port);
    switch ( ch )
  {
  case EOF:
  case SCHEME_SPECIAL:
    scheme_read_err(port, stxsrc, line, col, pos, 1, ch, indentation,
                    "read: bad syntax `#'");
    break;
  case ';':

#if 1 /* replaced with literally a call to an extended read_quote  */
    return read_quote("", an_uninterned_symbol, 1, port, stxsrc, line, col,
                      pos, ht, indentation, params);
#elif /* eliminating the otherwise below odd semantics */
  {
    Scheme_Object *skipped;
    skipped = read_inner(port, stxsrc, ht, indentation, params, 0);
    if (SCHEME_EOFP(skipped))
      scheme_read_err(port, stxsrc, line, col, pos, SPAN(port, pos),
                      EOF, indentation,
    "read: expected a commented-out element for `#;' (found end-of-file)");
    /* For resolving graphs introduced in #; : */
    if (*ht) {
      Scheme_Object *v;
      v = scheme_hash_get(*ht, an_uninterned_symbol);
      if (!v)
    v = scheme_null;
      v = scheme_make_pair(skipped, v);
      scheme_hash_set(*ht, an_uninterned_symbol, v);
    }

    if (comment_mode & RETURN_FOR_HASH_COMMENT)
      return NULL;

    goto start_over;
  }
#endif

...

 static Scheme_Object *
read_quote(char *who, Scheme_Object *quote_symbol, int len,
       Scheme_Object *port,
       Scheme_Object *stxsrc, long line, long col, long pos,
       Scheme_Hash_Table **ht,
       Scheme_Object *indentation, ReadParams *params)
{
  Scheme_Object *obj, *ret;

  obj = read_inner(port, stxsrc, ht, indentation, params, 0);
  if (SCHEME_EOFP(obj))
    scheme_read_err(port, stxsrc, line, col, pos, len, EOF, indentation,
            "read: expected an element for %s (found end-of-file)",
            who);
#if 1 /* Adding one line to effectively remove <empty-s-exp>'s */
  if ((obj == NULL) || (quote_symbol == an_uninterned_symbol)) return NULL;
#endif
  ret = (stxsrc
     ? scheme_make_stx_w_offset(quote_symbol, line, col, pos, len, stxsrc,
                                STX_SRCTAG) : quote_symbol);
  ret = scheme_make_pair(ret, scheme_make_pair(obj, scheme_null));
  if (stxsrc)
    ret = scheme_make_stx_w_offset(ret, line, col, pos, SPAN(port, pos),
                                   stxsrc, STX_SRCTAG);
  return ret;
}

...