Good observations. > -----Original Message----- > From: MikkelFJ [mailto:mikkelj-anti-spam / post1.dknet.dk] > Sent: Tuesday, July 31, 2001 12:36 PM > To: ruby-talk / ruby-lang.org > Subject: [ruby-talk:18906] Re: Digits in method names > > > > "brucedickey" <brucedickey / micron.com> wrote in message > news:6_B97.12866$WD1.533464 / e420r-atl2.usenetserver.com... > > > Yes, in pure theory -- the theory of certain types of > parsers, that is. > > However, in practice identifiers are usually limited to a > fixed number of > > significant characters and therefore it is possible to distinguish a > number > > from an identifier within that number of characters. Most mainstream > parsers > > Not even so: Most compilers separate the lexer from the > parser. The lexer > will break up the tokens, and the parser will usually have a > fixed number of > token lookahead (LALR(1) = 1 token). > This means that even a 7K long identifier will still only be > one token. > And the lexer will classify the token as either a number of a > potential > identifier (might be a keyword, depending on architecture). > > The real requirement here, is that the lexer should be able > to make the > distinction. Hence we do not want 0 to be a valid identifier > - although in > principle it was not a problem if it had to be declared first. > > The only problem is if spaces are not required to follow some > operator or > keyword: > > 0 plus 2 > 0plus2 > array.each do|i| i = 2 + 0end > > The issue about infinite lookahead is btw: not as bad as it > sounds - the > trend seems to be more userfriendly rather than more > parserfriendly. This > can require significant lookahead but parsers are fast enough > these days. > > Mikkel > > >