Re: [fpc-pascal] method-definition
Michael Van Canneyt via fpc-pascal schrieb am Sa., 16. Dez. 2023, 09:43: > The requirement for parameters in record constructors I guess comes from > C++ builder by Embarcadero. > There are some limitations imposed by C++. > > Whether they could be dropped in FPC is something Sven Barth should answer. > We only "inherited" that for Delphi compatibility. Technically the compiler could handle it without problems... 路♀️ Regards, Sven > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] method-definition
On Sat, 16 Dec 2023, Hairy Pixels via fpc-pascal wrote: On Dec 15, 2023, at 8:56 PM, Adriaan van Os via fpc-pascal wrote: What complicates things, is that many conflicting rules have the same name in the Language Reference. For example, conceptually we have object-methods, record-methods, class-methods, interface-methods and objcclass-methods. But only the record method rules are prefixed as such. You mean like why records require you to add "static" to class methods? Makes no sense to me either. Well, I guess the explanation is something like the following: Because class methods normally get a TClass pointer (a class reference) as Self unless you specify self (in which case they become normal records). Since records do not have a TClass concept, this 'Self' cannot be passed. To be consistent with classes and to make this explicit, the 'static' is required. In my opinion this is superfluous, but embarcadero decided otherwise. The requirement for parameters in record constructors I guess comes from C++ builder by Embarcadero. There are some limitations imposed by C++. Whether they could be dropped in FPC is something Sven Barth should answer. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] method-definition
> On Dec 15, 2023, at 8:56 PM, Adriaan van Os via fpc-pascal > wrote: > > What complicates things, is that many conflicting rules have the same name in > the Language Reference. For example, conceptually we have object-methods, > record-methods, class-methods, interface-methods and objcclass-methods. But > only the record method rules are prefixed as such. You mean like why records require you to add "static" to class methods? Makes no sense to me either. I don't understand why record constructors must have parameters while static functions do not. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] method-definition
On 15.12.23 16:00, Martin Frb via fpc-pascal wrote: [...] However, a method can be reintroduced, and be virtual/abstract. type TFoo = class procedure Bar; virtual; abstract; end; TFoo2 = class(TFoo) procedure Bar; reintroduce; virtual; abstract; end; Can that make sense? Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] method-definition
On 15/12/2023 14:56, Adriaan van Os via fpc-pascal wrote: I am puzzled by the syntax rule in Chapter 6. Classes of the FreePascal Language Reference (version 3.2.0) Section 6.1 Class definitions has method-definition = [ "CLASS" ] ( function-header | procedure-header | constructor-header | destructor-header ) ";" [ ( ( ( "virtual" | "dynamic" ) [ ";" "abstract" ] ) | "override" | "message" ( integer-constant | string-constant ) ) ";" ] [ call-modifiers ";" ] . Section 6.6.1 Declaration has: method-definition = ( function-header | procedure-header | constructor-header | destructor-header ) ";" method-directives . method-directives = ( ( "virtual" | "dynamic" ) [ ";" "abstract" ] | "reintroduce" ";" | "override" ";" | "message" constant-expression ) [ call-modifiers ";" ] . 2. "reintroduce" is in just one of the two definitions. Another note: "reintroduce" is given as an alternative to "virtual; [abstract;]". However, a method can be reintroduced, and be virtual/abstract. program Project1;{$Mode objfpc} type TFoo = class procedure Bar; virtual; abstract; end; TFoo2 = class(TFoo) procedure Bar; reintroduce; virtual; abstract; end; begin end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] method-definition
I am puzzled by the syntax rule in Chapter 6. Classes of the FreePascal Language Reference (version 3.2.0) Section 6.1 Class definitions has method-definition = [ "CLASS" ] ( function-header | procedure-header | constructor-header | destructor-header ) ";" [ ( ( ( "virtual" | "dynamic" ) [ ";" "abstract" ] ) | "override" | "message" ( integer-constant | string-constant ) ) ";" ] [ call-modifiers ";" ] . Section 6.6.1 Declaration has: method-definition = ( function-header | procedure-header | constructor-header | destructor-header ) ";" method-directives . method-directives = ( ( "virtual" | "dynamic" ) [ ";" "abstract" ] | "reintroduce" ";" | "override" ";" | "message" constant-expression ) [ call-modifiers ";" ] . Is this supposed to be the same rule for ? Some notes: 1. I don't see a rule anywhere in the Language Reference 2. "reintroduce" is in just one of the two definitions. 3. the optional "CLASS" is in just one of the two definitions. What complicates things, is that many conflicting rules have the same name in the Language Reference. For example, conceptually we have object-methods, record-methods, class-methods, interface-methods and objcclass-methods. But only the record method rules are prefixed as such. Regards, Adriaan van Os ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal