Various documentation questions

Ellery Newcomer ellery-newcomer at utulsa.edu
Sat Jun 5 21:03:34 PDT 2010


On 06/05/2010 08:16 PM, Bernard Helyer wrote:
> On 06/06/10 03:26, Ellery Newcomer wrote:
>> On 06/05/2010 08:22 AM, Bernard Helyer wrote:
>>> I may be trying to write a D2 compiler in D2 (you can't prove
>>> anything!),
>>
>> ditto, except mine is in java
>
> Awesome! :)

No. Java isn't. :)

Although the jvm talk bearophile linked to suggested that the jvm would 
be relatively easy to generate machine code for.

>
>>
>>> ---
>>>
>>> http://www.digitalmars.com/d/2.0/expression.html#UnaryExpression
>>>
>>> "( Type ) . Identifier"
>>>
>>> why is that significant?
>>>
>>> ---
>>
>> I suppose it's a bid to reduce the amount of incorrect parsing that
>> would result from
>>
>> Type . Identifier
>>
>> And to its credit, I don't think I have come across any trouble with it.
>
> Maybe I'm having a slow morning, but I can't really grok that. Could you
> elaborate? Speak slowly. :)
>

expressions and types are ambiguous, so any place where both can appear 
will be trouble. Consider the token string

Identifier [ Identifier ] . Identifier

does the part before the dot represent a type, or an expression? It's 
impossible to say at parse time (in the general case), and the 
programmer will have cause to use both fairly often.

And yes,

( Identifier [ Identifier ] ) . Identifier

is just as ambiguous, but I think

( Expression ) . Identifier

is much less common than

Expression . Identifier

Ugh. I suppose I'm going to have to write a Type -> Expression routine 
sometime soon.


More information about the Digitalmars-d mailing list