Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2012-02

global property, with getter in other unit

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

Defining a property in the interface section (outside a class), that refers to methods in another unit, gives an *unexpected* error. It may well be not allowed and then should give an error, but the right error in the right place.

Btw, only tested with 2.4.4, apologies if that is fixed in 2.6.0

A none existing function, reports an immediate error, on the line where the property is declared:

    property Foo: TObject read NoneExistingFunction;

But

    property Foo: TObject read  FunctionFromOtherUnit;  // OtherUnit is

in uses

The compiler passes that line without error.

But when trying to read the property

   UnitFoo.pas(999,3) Error: Wrong number of parameters specified for

call to "FunctionFromOtherUnit"

Reply by email

Paul Ishenin
to Martin

28.02.2012 3:01, Martin пишет:

Show quoted text 19 lines
Defining a property in the interface section (outside a class), that refers to methods in another unit, gives an *unexpected* error. It may well be not allowed and then should give an error, but the right error in the right place. Btw, only tested with 2.4.4, apologies if that is fixed in 2.6.0 A none existing function, reports an immediate error, on the line where the property is declared: property Foo: TObject read NoneExistingFunction; But property Foo: TObject read FunctionFromOtherUnit; // OtherUnit is in uses The compiler passes that line without error. But when trying to read the property UnitFoo.pas(999,3) Error: Wrong number of parameters specified for call to "FunctionFromOtherUnit"

Can you submit a more complete example?

Best regards,
Paul Ishenin

Reply by email

Martin
to Paul Ishenin
Paul Ishenin wrote 7 lines
28.02.2012 3:01, Martin пишет: > Defining a property in the interface section (outside a class), that > refers to methods in another unit, gives an *unexpected* error. It may > well be not allowed and then should give an error, but the right error > in the right place. > > Btw, only tested with 2.4.4, apologies if that is fixed in 2.6.0

verified with 2.6 too

Show quoted text 11 lines
> > property Foo: TObject read FunctionFromOtherUnit; // OtherUnit is in > uses > > The compiler passes that line without error. > > But when trying to read the property > UnitFoo.pas(999,3) Error: Wrong number of parameters specified for call > to "FunctionFromOtherUnit" Can you submit a more complete example?

Attached.

It needed 3 units,

accessing Foo in the same unit, in which it is declared (unit2) compiles (not tested if it runs...)

Reply by email

Paul Ishenin
to Martin

28.02.2012 9:11, Martin пишет:

Show quoted text 6 lines
Attached. It needed 3 units, accessing Foo in the same unit, in which it is declared (unit2) compiles (not tested if it runs...)

You found some bug in the compiler. Property can only be declared inside a structure but compiler allowed to do this in a unit level.

If this is not some FPC feature unknown to me I will fix it.

Best regards,
Paul Ishenin

Reply by email

Martin
to Paul Ishenin
Paul Ishenin wrote 12 lines
28.02.2012 9:11, Martin пишет: > Attached. > > It needed 3 units, > > accessing Foo in the same unit, in which it is declared (unit2) compiles > (not tested if it runs...) You found some bug in the compiler. Property can only be declared inside a structure but compiler allowed to do this in a unit level. If this is not some FPC feature unknown to me I will fix it.

http://www.freepascal.org/docs-html/ref/refse24.html#x56-630004.6

questiion is about where the getterr/setter must be defined.

btw, they can not be prefixed

this fails
    property FooSinteger read SomeUnit.GetFoo;
this passes, but fails from 3rd unit
    property FooSinteger read GetFooFromSomeUnit;

Reply by email

Martin
to Martin
Martin wrote 26 lines
On 29/02/2012 01:40, Paul Ishenin wrote: > 28.02.2012 9:11, Martin пишет: >> Attached. >> >> It needed 3 units, >> >> accessing Foo in the same unit, in which it is declared (unit2) >> compiles >> (not tested if it runs...) > > You found some bug in the compiler. Property can only be declared > inside a structure but compiler allowed to do this in a unit level. > > If this is not some FPC feature unknown to me I will fix it. http://www.freepascal.org/docs-html/ref/refse24.html#x56-630004.6 questiion is about where the getterr/setter must be defined. btw, they can not be prefixed this fails property FooSinteger read SomeUnit.GetFoo; this passes, but fails from 3rd unit property FooSinteger read GetFooFromSomeUnit; __

actually

Show quoted text 7 lines
The read/write specifiers can be hidden by declaring them in another unit which must be in the uses clause of the unit. This can be used to hide the read/write access specifiers for programmers, just as if they were in a private section of a class (discussed below). For the previous example, this could look as follows:

So it should work, but does not

Reply by email

Paul Ishenin
to Martin: http://www.freepascal.org/docs-html/ref/refse24.html#x56-630004.6 questiion is about…
Martin wrote 12 lines
> If this is not some FPC feature unknown to me I will fix it. http://www.freepascal.org/docs-html/ref/refse24.html#x56-630004.6 questiion is about where the getterr/setter must be defined. btw, they can not be prefixed this fails property FooSinteger read SomeUnit.GetFoo; this passes, but fails from 3rd unit property FooSinteger read GetFooFromSomeUnit;

Looks like this old feature was not maintained in the compiler since the intial svn import from cvs.

The code contains various errors which was not noticed since 2005 year like:

     procedure property_dec;
       begin
...
            message(parser_e_resourcestring_only_sg);

This should give an error about resource strings when you have a deal with a property.

Best regards,
Paul Ishenin

Reply by email