From: Tony Arcieri Date: 2009-05-21T07:28:34+09:00 Subject: Re: Pythonic indentation (or: beating a dead horse) --000e0cd13a2a0d4cd8046a5f8c85 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Wed, May 20, 2009 at 4:18 PM, Tony Arcieri wrote: > I'd be particularly interested in solutions which can be parsed with a > LALR, > LL*, or PEG parser. The approach you're describing does not sound like it > could be expressed as a CFG, not that there isn't a CFG solution for this, > just that the one you're proposing is not. > And I guess I just can't shut up about this: your solution would require a scanner with some degree of grammatical awareness for every expression which contains an indent block. When you start talking about a solution like that, I really think you're going down a rabbit hole. I'll refer to Guido van Rossum on this one: > The unspoken, right brain constraint here is that the complexity introduced by a solution to a design > problem must be somehow proportional to the problem's importance. In my > mind, the inability of lambda to contain a print statement or a while-loop > etc. is only a minor flaw; after all instead of a lambda you can just use a > named function nested in the current scope. > > But the complexity of any proposed solution for this puzzle is immense, to > me: it requires the parser (or more precisely, the lexer) to be able to > switch back and forth between indent-sensitive and indent-insensitive modes, > keeping a stack of previous modes and indentation level. Technically that > can all be solved (there's already a stack of indentation levels that could > be generalized). But none of that takes away my gut feeling that it is all > an elaborate Rube Goldberg contraption > . > You are proposing a Rube Goldberg contraption whereby the scanner would require some degree of grammatical awareness. This is a complex solution. The minor flaw is that you don't like "end" statements. Is the minor flaw of having repeated end statements really worth the level of complexity the solution would require? -- Tony Arcieri medioh.com --000e0cd13a2a0d4cd8046a5f8c85--