AndrewHoward 0 Posted July 24, 2023 (edited) Hi, Could someone explain this code: type TDataContainer = class public type TIterateAction = reference to procedure (value: integer); strict private FData: TArray<integer>; FIndex: integer; public constructor Create(const data: TArray<integer>); procedure Iterate(action: TIterateAction); function GetFirst(var value: integer): boolean; function GetNext(var value: integer): boolean; end; I don't understand the role of "type" after public and before the anonymous method type declaration? public type Doesn't it require a matching "end" ? Thanks Edited July 24, 2023 by AndrewHoward Share this post Link to post
Attila Kovacs 629 Posted July 24, 2023 it's a type declaration in the class it's type TDataContainer = class public type TIterateAction = reference to procedure (value: integer); strict private FData: TArray<integer>; FIndex: integer; public constructor Create(const data: TArray<integer>); procedure Iterate(action: TIterateAction); function GetFirst(var value: integer): boolean; function GetNext(var value: integer): boolean; end; TDataContainer.TIterateAction type It's just ebarcadero who does not give a fuck to implement its own syntax to the formatter. 1 Share this post Link to post
David Schwartz 426 Posted July 26, 2023 Delphi supports nested types. This binds the type name TIterateAction to TDataContainer in case anybody wants to refer to it outside of TDataContainer class. Usually I see nested types declared as Private, which basically means they're intended for the exclusive use of that class, as nobody outside of the class can even see them. 1 Share this post Link to post
Remy Lebeau 1392 Posted July 26, 2023 (edited) On 7/24/2023 at 11:59 AM, AndrewHoward said: Could someone explain this code: This is documented in Embarcadero's DocWiki: Nested Type Declarations Edited July 26, 2023 by Remy Lebeau 1 Share this post Link to post
AndrewHoward 0 Posted July 27, 2023 On 7/26/2023 at 5:11 PM, Remy Lebeau said: This is documented in Embarcadero's DocWiki: Nested Type Declarations Thank you very much. Share this post Link to post
Fr0sT.Brutal 900 Posted August 7, 2023 OT: this always requires a knowing people (or knowing AI) to realize how to name "the weird thing you see in code" properly. The following RTFM-ing with exact naming is trivial but that initial step could be really hard. Share this post Link to post
David Schwartz 426 Posted August 12, 2023 On 8/7/2023 at 4:56 AM, Fr0sT.Brutal said: OT: this always requires a knowing people (or knowing AI) to realize how to name "the weird thing you see in code" properly. The following RTFM-ing with exact naming is trivial but that initial step could be really hard. If I understand what you're saying, I think it's a big problem that renders Google practically useless if you don't know the proper term to use, or if there even is one. You can give a code sample to google and ask, "what is this?" and you'll probably get a bunch of gibberish that does not include what you're looking for. ChatGPT might do a better job. But if you don't know what something is called, it's hard to ask anybody anything about it. Telling someone to RTFM isn't helpful b/c they don't even know what to look for. Case in point: where can you find the entire set of % parameters that can be used in a Format statement? if you go to the Help topic for Format, it doesn't say. You have to find a link buried in commentary to bring up that info. I still don't know what they're actually called. Share this post Link to post
Fr0sT.Brutal 900 Posted August 21, 2023 On 8/12/2023 at 12:22 PM, David Schwartz said: I think it's a big problem that renders Google practically useless if you don't know the proper term to use, or if there even is one Yes and the fact that some coding features are only show themselves as some non-alpha symbols complicates things. Trying to google "what ^#$& means in <language name>" does not always return relevant results. On 8/12/2023 at 12:22 PM, David Schwartz said: Case in point: where can you find the entire set of % parameters that can be used in a Format statement? Hm, I was always going Format > Formatting strings for this in D7 help and XE2 already has these parameters in the function's page. Share this post Link to post