Discussion:
[Scheme-reports] editorial awkwardness for syntax-rules pattern-matching
Per Bothner
2014-09-03 20:43:55 UTC
Permalink
If there is a revision or successor to r7rs, I suggest changing the really
awkward specification of syntax-rules pattern-matching with ellipsis in 4.3.2:

For example:

P is of the form (P_1 . . . P_k P_e ellipsis P_m+1 ... P_n)
where E is a proper list of n elements, the first
k of which match P_1 through P_k , respectively, whose
next m−k elements each match P_e, whose remaining
n−m elements match P_m+1 through P_n

The phrase 'of the form (P_1 ... P_k P_e ellipsis P_m+1 ... P_n)'
doesn't really make sense since m and n come out of nowhere.

Much clearer to write:

P is of the form (P_1 . . . P_k P_e ellipsis P_k+1 ... P_k+l)
where E is a proper list of n elements, the first
k of which match P_1 through P_k , respectively, whose
next n−k-l elements each match P_e, whose remaining
l elements match P_k+1 through P_k+l

Similarly for other items.
--
--Per Bothner
***@bothner.com http://per.bothner.com/
John Cowan
2014-09-03 23:40:56 UTC
Permalink
Post by Per Bothner
P is of the form (P_1 . . . P_k P_e ellipsis P_k+1 ... P_k+l)
where E is a proper list of n elements, the first
k of which match P_1 through P_k , respectively, whose
next n−k-l elements each match P_e, whose remaining
l elements match P_k+1 through P_k+l
I don't see where the aditional clarity comes in; also, having both 1 and l
in a formula is asking for trouble.
--
John Cowan http://www.ccil.org/~cowan ***@ccil.org
One time I called in to the central system and started working on a big
thick 'sed' and 'awk' heavy duty data bashing script. One of the geologists
came by, looked over my shoulder and said 'Oh, that happens to me too.
Try hanging up and phoning in again.' --Beverly Erlebacher
Per Bothner
2014-09-04 00:47:34 UTC
Permalink
Post by John Cowan
Post by Per Bothner
P is of the form (P_1 . . . P_k P_e ellipsis P_k+1 ... P_k+l)
where E is a proper list of n elements, the first
k of which match P_1 through P_k , respectively, whose
next n−k-l elements each match P_e, whose remaining
l elements match P_k+1 through P_k+l
I don't see where the aditional clarity comes in;
Well, in my opinion 'P is of the form (P_1 . . . P_k P_e ellipsis P_m+1 ... P_n)'
is somewhat nonsensical. Where do m and n come from? n is the length of E, but m
is complicated to describe as it depends on both n and the number of patterns
in P following the ellipsis. This seems a rather unusual way to enumerate items in
a list.

Using l (or m) for the number of sub-patterns following the ellipsis is much
easier to understand: l is just the number of sub-patterns following the ellipsis,
and this is obvious from the form P_k+1 ... P_k+l.
Post by John Cowan
also, having both 1 and l in a formula is asking for trouble.
That occurred to me. Using m in place of l is one option.

Even better if we're willing to use other letters beside P for sub-patterns:

P is of the form (P_1 . . . P_k Q ellipsis R_1 ... R_m)
where E is a proper list of n elements, the first
k of which match P_1 through P_k , respectively, whose
next n−k-m elements each match Q, whose remaining
m elements match R_1 through R_m
--
--Per Bothner
***@bothner.com http://per.bothner.com/
John Cowan
2014-09-03 23:40:56 UTC
Permalink
Post by Per Bothner
P is of the form (P_1 . . . P_k P_e ellipsis P_k+1 ... P_k+l)
where E is a proper list of n elements, the first
k of which match P_1 through P_k , respectively, whose
next n−k-l elements each match P_e, whose remaining
l elements match P_k+1 through P_k+l
I don't see where the aditional clarity comes in; also, having both 1 and l
in a formula is asking for trouble.
--
John Cowan http://www.ccil.org/~cowan ***@ccil.org
One time I called in to the central system and started working on a big
thick 'sed' and 'awk' heavy duty data bashing script. One of the geologists
came by, looked over my shoulder and said 'Oh, that happens to me too.
Try hanging up and phoning in again.' --Beverly Erlebacher
Vassil Nikolov | Васил Николов
2014-09-04 03:30:23 UTC
Permalink
Post by Per Bothner
...
P is of the form (P_1 . . . P_k P_e ellipsis P_m+1 ... P_n)
where E is a proper list of n elements, the first
k of which match P_1 through P_k , respectively, whose
next m−k elements each match P_e, whose remaining
n−m elements match P_m+1 through P_n
The phrase 'of the form (P_1 ... P_k P_e ellipsis P_m+1 ... P_n)'
doesn't really make sense since m and n come out of nowhere.
In fact, m and n are defined by that
phrase (with an implicit "where m and n
are such that"); pretty usual practice in
my view.

---Vassil.
--
Vassil Nikolov | Васил Николов | <***@pobox.com>

"Be careful how you fix what you don't understand." (Brooks 2010, 185)
Loading...