rakitzis / rc

rc shell -- independent re-implementation for Unix of the Plan 9 shell (from circa 1992)
Other
250 stars 23 forks source link

Great tests, but missing 'if not' #90

Closed frobnitzem closed 9 months ago

frobnitzem commented 12 months ago

I've started an effort to standardize the various versions of the rc shell,

https://github.com/frobnitzem/rc-org

and really appreciate the tests present in this version's tripping.rc.

However, a history and status of the branches of rc shows that the main barrier to adopting this version is the lack of 'if not'. All other implementations of the rc shell retain the original 'if not' syntax.

Some discussion threads, #19, #74, #82, note that this syntax was never fully operational in in this version, and recently removed. I'd propose to add 'if not' as an equivalent to 'else'. Even a substitution in the lexer would accomplish this.

rakitzis commented 9 months ago

I don't see how "if not" is equivalent to "else": The "else" keyword must land on the same line as the close brace or it will fail to parse. "if not" on the other hand must stand alone after a newline.

In any case, this has been debated ad nauseam over the years. I made a choice (in 1991!) to diverge from the "if not" syntax, in particular because it was called out as a bug in the original rc man page, and because I thought the "} else" workaround was actually a superior solution.

(I'd like to say my judgement was affirmed by the Go developers, who picked more or less exactly the same solution for resolving the if/else shift/reduce conflict in their design of Go's syntax)

So I'd rather leave this alone and not introduce "if not" into this flavor of rc. Thank you.