On Sunday, June 17, 2012 04:30:00 Timon Gehr wrote: > On 06/17/2012 04:04 AM, Bernard Helyer wrote: > > Sigh. If you're going to reply like that, it would be nice to know you > > had the slightest fucking clue what you're talking about. > > > > On Saturday, 16 June 2012 at 11:26:21 UTC, Timon Gehr wrote: > >> On 06/16/2012 07:19 AM, Bernard Helyer wrote: > >>> On Friday, 15 June 2012 at 12:56:49 UTC, Timon Gehr wrote: > >>>> On 06/15/2012 02:19 PM, bearophile wrote: > >>>>> Timon Gehr: > >>>>>> Why not allow equality operators to operate on types? > >>>>> > >>>>> That's nice, of course. But is it possible? > >>>> > >>>> Yes, certainly. > >>> > >>> Not without losing the context insensitivity of the D grammar (because > >>> now we can't say for certain what "T == J" is > >> > >> It is a comparison. That suffices for the parser. The grammar stays > >> completely context-independent. > > > > But we can't say whether T is a type or a value. _That_ matters. > > FROM A PARSER LEVEL, NO!
It depends on the grammar. As it stands, with is(T == W), T and T must be types, and with T == W, they _cannot_ be types. If a different grammar rule were used inside of is, then you'd get a different result for what types of tokens the parser considers T and W to be. If you got rid of is(T == W) in favor of T == W, then the parser could no longer determine their types. That can certainly work - but only if the semantic analyzer is okay with the parser not knowing what T and W are. As it stands, IsExpression is its own rule in the grammar, and it expects T == W to be Type == TypeSpecialization, so the grammar rules are _defnitely_ different when == is used in an is expression is used than when == is used outside of an is expression. So, what you're suggesting would definitely mean changing the grammar, and it would mean giving the semantic analyzer less information from the parser (since it couldn't tell the semantic analyzer whether T and W were types or not). I expect that it's feasible, but it would be a large change. And one major downside would be that it would be impossible for a program which used the parser but not the semantic analyzer (e.g. for syntax highlighting) would then need the semantic analyzer as well to actually do what it does. - Jonathan M Davis
