Herb Sutter briefly discusses D during interview

Timon Gehr timon.gehr at gmx.ch
Wed Jun 8 12:19:40 PDT 2011


Jonathan M Davis wrote:
> On 2011-06-08 12:03, Timon Gehr wrote:
> > Kagamin wrote:
> > > Timon Gehr Wrote:
> > > > It is more convenient for the compiler to read the declaration left to
> > > > right to construct the type. (just like for people)
> > >
> > > a real example in the go language :)
> > >
> > > hello := []byte("hello, world\n")
> >
> > In your example the compiler has to parse the type "[]byte" from right to
> > left, not left to right, to make sense out of it.
>
> Does it really? It's an array of bytes, not a byte of arrays. I fully expect
> that it looks at it from left-to-right. But I don't know how they implemented
> it.
>
> - Jonathan M Davis

True, I think the input is consumed left-to-right. But as they are using a
standard recursive descent parser, it will go like this:

Find []                                               ("look" at [])
 -> Recursively parse another type                    ("look" at byte)
Create [] Expression and link it to the parsed type.  ("look" at [])

So actually the parser looks at them in _both_ orders =).

Timon





More information about the Digitalmars-d mailing list