[fpc-pascal] a proposal about "with" syntax

Martin lazarus at mfriebe.de
Sun Mar 17 14:51:59 CET 2013


On 17/03/2013 12:54, Marco van de Voort wrote:
> In our previous episode, Sven Barth said:
>>> Now THAT is really unpascalish... either ":=" or the already suggested
>>> "as"...
> Since it is a pseudo variable declaration, I would assume VAR syntax and
> just use ":" ?
>

Or maybe it should require a "variable" declaration (or otherwise 
declared identifier with fixed type).

Otherwise it goes into an undesirable direction:

Function Foo;
begin
   with a: SomeInteger do Work(a);
   with a: SomeBoolean do Work(a);
end;

a is first integer, then boolean within the same scope. *Very* confusing.

And very close to the next step (which of course can be rejected by the 
compiler)

Function Foo;
begin
   with a: SomeInteger do begin
      Work(a);
      with a: SomeBoolean do Work(a); // masking a
   end;
end;

But if the inner a was Integer too, then maybe it should work? Unless it 
gets a similar special status like a loop variable?

-------------------
IIRC in other threads on this topic, some people explicitly stated they 
wanted this feature so the would not need to declare "a" first (I may 
remember this wrong).
IMHO starting with the first loop hole of allowing an undeclared 
identifier to be used, is just opening the door to more and more 
weakening of the language requirement.
Besides, it does not hurt, if "a" needs to be declared.






More information about the fpc-pascal mailing list