Sign in Join

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

Mailing lists / fpc-pascal / 2013-02

Can property setters be procedures only?

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Frank Church

When I try to set a property using a function I get the error:

form001.pas(28,64) Error: Illegal symbol for property access
form001.pas(34,1) Fatal: There were 1 errors compiling module, stopping

Is there something about properties that prevent them from being set by a function?

I can call a function to set that property, but I wonder why a setter can't be a function?

Frank Church ======================= http://devblog.brahmancreations.com

Reply by email

Michael Van Canneyt
to Frank Church
Frank Church wrote 7 lines
When I try to set a property using a function I get the error: form001.pas(28,64) Error: Illegal symbol for property access form001.pas(34,1) Fatal: There were 1 errors compiling module, stopping Is there something about properties that prevent them from being set by a function?

Yes, the absence of a result.
Results sometimes require special handling (strings etc).

I can call a function to set that property, but I wonder why a setter can't be a function?

Because there is no result.

Where is the result in

  MyControl.Top:=3;

?

Michael.

Reply by email

Frank Church
to Michael Van Canneyt
Michael Van Canneyt wrote 27 lines
On Wed, 6 Feb 2013, Frank Church wrote: > When I try to set a property using a function I get the error: > > form001.pas(28,64) Error: Illegal symbol for property access > form001.pas(34,1) Fatal: There were 1 errors compiling module, stopping > > Is there something about properties that prevent them from being set > by a function? Yes, the absence of a result. Results sometimes require special handling (strings etc). > I can call a function to set that property, but I wonder why a setter > can't be a function? Because there is no result. Where is the result in MyControl.Top:=3; ?

What I'm thinking of is when there is an error and the sender has to be notified?
I am thinking of a case where it would be undesirable to raise an exception that would stop the flow of the program
Would it be better to have some kind of exception handler or calling some kind of function that would return an error code would be better?

Show quoted text 5 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Frank Church ======================= http://devblog.brahmancreations.com

Reply by email

Michael Van Canneyt
to Frank Church
Frank Church wrote 31 lines
On 6 February 2013 09:07, Michael Van Canneyt wrote: > > > On Wed, 6 Feb 2013, Frank Church wrote: > >> When I try to set a property using a function I get the error: >> >> form001.pas(28,64) Error: Illegal symbol for property access >> form001.pas(34,1) Fatal: There were 1 errors compiling module, stopping >> >> Is there something about properties that prevent them from being set >> by a function? > > > Yes, the absence of a result. > Results sometimes require special handling (strings etc). > > >> I can call a function to set that property, but I wonder why a setter >> can't be a function? > > > Because there is no result. > > Where is the result in > MyControl.Top:=3; > ? > What I'm thinking of is when there is an error and the sender has to be notified?

In the case of properties this can only be done with exceptions.

I am thinking of a case where it would be undesirable to raise an exception that would stop the flow of the program Would it be better to have some kind of exception handler or calling some kind of function that would return an error code would be better?

You should use exceptions.

Michael.

Reply by email