"strict", another oddity ? [Re: [fpc-pascal] deprecated syntax is inconsistent.]

Martin fpc at mfriebe.de
Thu Apr 29 18:38:00 CEST 2010


While I am not particularly leaning to either side on the "deprecated" 
discussion, I found another "oddity" due to the single lookahead scenario

"strict" is allowed as identifier. the following does compile
var
   strict: Integer;

BUT, because now e can have "strict private"; the following does NOT 
compile:
type
   TForm1 = class(TForm)
   private
     strict: Integer;

Even though I would think it to be correct code? (There probably exists 
a wiki explaining it?)

Martin

On 29/04/2010 13:35, ik wrote:
> On Thu, Apr 29, 2010 at 13:39, Jonas Maebe <jonas.maebe at elis.ugent.be 
> <mailto:jonas.maebe at elis.ugent.be>> wrote:
>
>
>     On 29 Apr 2010, at 12:00, Graeme Geldenhuys wrote:
>
>         Michael Van Canneyt het geskryf:
>
>             Consider the following - what  you propose - statements:
>
>
>             Var
>              A : Integer;
>              deprecated : Boolean;
>
>             The compiler cannot decide whether the 'deprecated' is a
>             modifier or the
>
>
>         Yes it can, because in your example 'deprecated' is followed
>         by a colon and
>         a type.
>
>         Var
>           A : Integer; deprecated;
>
>         This is *not* ambiguous at all,
>
>
>     It is ambiguous to the compiler, as is explained in one of the
>     links I posted previously:
>     http://wiki.freepascal.org/User_Changes_2.4.0#Order_of_field_and_method.2Fproperty_declarations
>
>     "The above code was ambiguous to the compiler, because when it
>     finished parsing the property, it could not decide based on seeing
>     the default token whether this meant that the property was a
>     default property, or whether a field coming after the property was
>     called "default". It did find this out after it had parsed the
>     default token (because the next token was a ":" rather than a
>     ";"), but by then it was too late."
>
>     The compiler uses only a single lookahead token, while
>     disambiguating your example would require two.
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20100429/0df0dcec/attachment.html>


More information about the fpc-pascal mailing list