[fpc-devel]feature requests: circular unit ref, usage before define, Delphi constructs, block local identifiers

Michael Van Canneyt michael.vancanneyt at wisa.be
Mon Mar 25 14:10:53 CET 2002

On Mon, 25 Mar 2002, [iso-8859-1] R Hof wrote:

> I've got some things I like to see implemented in free
> pascal.
> The first thing is the possibility to let units
> include eachother.

You can do that already. But only if one of the two references is in the
implementation section. If the uses would be in the interface section,
the compiler can never decide which unit to compile first in such
case, so it simply cannot be done.

> ------------------------
> The second feature request is the usage of identifiers
> while they're defined later on in the code. For
> example, sometimes is looks more natural if some
> procedure is defined before another one. Defining
> procedures forward is a solution, but it would be
> easier if this wouldn't be necessary.

Pascal is a single pass language. This is necessary for the strong type
checking - hence the forward declaration. So this also is not possible.

> ------------------------
> Third:
> - dynamic arrays (var a: array of integer;)

This is already possible; both in 1.0 and 1.1

> - Variants

Supported in version 1.1

> - out arguments (ie procedure p(out a: integer); )
> like in Delphi

Supported in version 1.1

> Fourth:
> block local identifiers:
> - if (...) then begin
>     var i: integer;
>     .
>   end;

I don't think we will do this as this will lead to many nested try/finally blocks
and according stack frame buildups, leading to very inefficient code.

> - 1) "with x := a[i].position.x do ..."
>   or better: defining identifier x at the same time
>   like
>   2) "with var x := a[i].position.x do ..."
>   or
>   3) "with const x: integer = a[i].position.x do ..."
>   I'd prefer construct 2) (so without mentioning x's
>   type explicitly). Construct 1) where x
>   is defined as a local variable elsewhere can also be
>   useful.

If you want this, I suggets you use C,Perl or PHP or so.
Pascal is a very structured and readable language, and I think that it
should remain so. Introducing this kind of things will badly affect the
readability and 'cleannes' of the language.


More information about the fpc-devel mailing list