On 2/20/13, David A. Wheeler <dwhee...@dwheeler.com> wrote: > Beni Cherniavsky-Paskin: >> > This behaves surprisingly: >> > >> > $ >> > ! a b >> > ! c d >> > ==> >> > ((a b (c d))) >> > >> > it seems $ consumes the following newline, resulting in same parsing as >> > if I >> > wrote >> > >> > $ a b >> > c d >> > >> > Is this deliberate? > > Alan Manuel Gloria >> No (at least not by me; check David's answer, but I suspect he didn't >> implement it deliberately that way). > > Alan's right, that's unintentional in the Scheme implementation. > > The BNF does not permit this construct at all, so the ANTLR implementation > will give an error in this case. > > The relevant production is it_expr, which permits only: > | SUBLIST hspace* is_i=it_expr {$v=list($is_i.v);} /* "$" first on line > */ > That is, "$", after any hspaces, MUST be followed with an it_expr, and > CANNOT > be followed currently by ";" or an end-of-line marker. > > >> Every example we have has some >> other datum after the "$", I never said anything about $-at-eol ever >> since I first proposed SUBLIST on the mailinglist, and so on, so you >> might legitimately say that this is "unspecified". >> >> > Since "a b" is on a child line, I'd it to parse in the same manner as "c >> > d", >> > resulting in ((a b) (c d)). >> >> That seems reasonable, given your rules. One might say that: >> >> $ >> ! a b >> ! c d >> ==> >> $ \\ >> ! a b >> ! c d > > I'm okay with that, especially if it makes using the construct "more > natural" > and avoids turning a plausible use into an error. > > It's a trivial 1-line addition to the BNF. If we *don't* add that, then I > clearly > need to add an error-check to the Scheme implementation. >
Hmmm.... $ ! a b ! c d INDENT ; stack: (0 ?) INDENT a b ; stack: (0 ? 2) SAME c d ; stack: (0 ? 2) DEDENT DEDENT \\ !\\ !!a b !!c d ( ( (a b) (c d))) ==> (((a b) (c d))), not ((a b) (c d)) - note the extra () introduced by $ compared to \\ -- However despite that, Beni's let example is correct: let $ x $ compute 'x y $ compute 'y use x let INDENT ; stack: (0 ?) INDENT x INDENT compute 'x ; (0 ? 4 ?) DEDENT ; stack (0 ? 4), indentation 4 y INDENT compute 'y ; (0 ? 4 ?) DEDENT DEDENT ; stack (0 ?), indentation 2 use x ; stack (0 2) DEDENT let !\\ !!x !!!compute 'x !!y !!!compute 'y !use x >> > [I'm asking this because if it's 'fixed, my >> > closing-SUBLIST-by-unmatched-dedent would allow: >> > >> > let $ >> > ! ! x $ compute 'x >> > ! ! y $ compute 'y >> > ! body... >> > ] > > I have a *lot* of concerns with that particular construct. > > But we could certainly allow $-at-end-of-line regardless, > on the grounds of consistency. > > So let's add $-at-EOL, unless someone objects soon. > > --- David A. Wheeler > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > _______________________________________________ > Readable-discuss mailing list > Readable-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/readable-discuss > ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ Readable-discuss mailing list Readable-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/readable-discuss