IsValidIdent() and identifiers escaped with &

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

IsValidIdent() and identifiers escaped with &

Howard Page-Clark
Consider this program, which returns False:

program Project1;

uses sysutils;

var
   &begin: boolean;

begin
   &begin:=IsValidIdent('&begin');
   WriteLn('IsValidIdent(''&begin'') evaluates to ', &begin);
end.

Should sysutils.IsValidIdent() be updated to return True in this case?

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: IsValidIdent() and identifiers escaped with &

Jürgen Hestermann


Am 2017-02-05 um 15:24 schrieb Howard Page-Clark:
var
  &begin: boolean;

Is that a valid identifier?
Here
http://wiki.lazarus.freepascal.org/Identifiers
it says:

Rules for identifiers:

  • Must begin with a letter from the English alphabet or an underscore (_).
  • Can be followed by alphanumeric characters (alphabetic characters and numerals), or the underscore (_).
  • May not contain special characters, such as:
 ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: IsValidIdent() and identifiers escaped with &

Mattias Gaertner
In reply to this post by Howard Page-Clark
On Sun, 5 Feb 2017 14:24:46 +0000
Howard Page-Clark <[hidden email]> wrote:

> Consider this program, which returns False:
>
> program Project1;
>
> uses sysutils;
>
> var
>    &begin: boolean;
>
> begin
>    &begin:=IsValidIdent('&begin');
>    WriteLn('IsValidIdent(''&begin'') evaluates to ', &begin);
> end.
>
> Should sysutils.IsValidIdent() be updated to return True in this case?

The identifier is "begin". The & is an operator.
For example:

type
  TMyEnum = (&begin);
var
  e: TMyEnum = &begin;
begin
  writeln(e);
end.

gives "begin".


Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: IsValidIdent() and identifiers escaped with &

Sven Barth-2
In reply to this post by Jürgen Hestermann

Am 05.02.2017 15:53 schrieb "Jürgen Hestermann" <[hidden email]>:
>
>
>
> Am 2017-02-05 um 15:24 schrieb Howard Page-Clark:
>>
>> var
>>   &begin: boolean;
>
>
> Is that a valid identifier?
> Here
> http://wiki.lazarus.freepascal.org/Identifiers
> it says:
>
> Rules for identifiers:
>
> Must begin with a letter from the English alphabet or an underscore (_).
> Can be followed by alphanumeric characters (alphabetic characters and numerals), or the underscore (_).
> May not contain special characters, such as:
>
>  ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \

http://freepascal.org/docs-html/current/ref/refse4.html#x16-150001.4

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: IsValidIdent() and identifiers escaped with &

Jürgen Hestermann
Am 2017-02-05 um 20:26 schrieb Sven Barth:

>
> > Is that a valid identifier?
> > Here
> > http://wiki.lazarus.freepascal.org/Identifiers
> > it says:
> > Rules for identifiers:
> > Must begin with a letter from the English alphabet or an underscore (_).
> > Can be followed by alphanumeric characters (alphabetic characters and numerals), or the underscore (_).
> > May not contain special characters, such as:
> >
> >  ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \
>
> http://freepascal.org/docs-html/current/ref/refse4.html#x16-150001.4
>

Strange!
Why was it added to use reserved words as an identifier?
What is the use of that?
It seems http://wiki.lazarus.freepascal.org/Identifiers needs an update too.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: IsValidIdent() and identifiers escaped with &

Michael Van Canneyt


On Sun, 5 Feb 2017, Jürgen Hestermann wrote:

> Am 2017-02-05 um 20:26 schrieb Sven Barth:
>>
>> > Is that a valid identifier?
>> > Here
>> > http://wiki.lazarus.freepascal.org/Identifiers
>> > it says:
>> > Rules for identifiers:
>> > Must begin with a letter from the English alphabet or an underscore (_).
>> > Can be followed by alphanumeric characters (alphabetic characters and
>> numerals), or the underscore (_).
>> > May not contain special characters, such as:
>> >
>> >  ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \
>>
>> http://freepascal.org/docs-html/current/ref/refse4.html#x16-150001.4
>>
>
> Strange!
> Why was it added to use reserved words as an identifier?
> What is the use of that?
For example:

If you import a SOAP webservice or REST API, often reserved words are used
in the names of arguments or properties.
This trick allows to use them as-is in the pascal proxy classes.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal