View Issue Details

IDProjectCategoryView StatusLast Update
0037333FPCCompilerpublic2020-07-12 21:21
ReporterBBaz Assigned To 
PrioritylowSeverityfeatureReproducibilityalways
Status newResolutionopen 
Product Version3.2.0 
Summary0037333: Procedural types cannot have helpers
Description(This a an enhancement request)

For example I'd like to generalize using `isAssigned` or `isNotAssigned` as a properties of everything than is allowed by the `assigned()` intrinsic.

This works for pointers, classes, and now interface (thanks BTW) but for now not procedural types, e.g

---
  TNotifyEventHelper = type helper for TNotifyEvent
    function isNotAssigned: boolean;
    function isAssigned: boolean;
  end;
---

is refused with

---
Error: Type "<procedure variable type of procedure(TObject) of object;Register>" cannot be extended by a type helper
---

Ultimately I'm thinking to generic helpers... also I know there might be limitations. In a perfect world we could declare

---
 generic TAssignedHelper<T> = type helper for T
    function isNotAssigned: boolean;
    function isAssigned: boolean;
  end;
---
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Sven Barth

2020-07-12 13:25

manager   ~0123922

Last edited: 2020-07-12 13:26

View 2 revisions

Helpers for procedure and method variables are not supported on purpose, because functions can be used for them as well and if they return a structured type (or a type that has a helper active) things can get very messy.

jamie philbrook

2020-07-12 16:20

reporter   ~0123932

I am trying to visualize what use a helper for that would be?

 I mean we already have "Assigned" to check for if it's been set or not.

 Even if you were able to shorten the entry call of a procedure by using a helper it still is something that already exists, Overloads..

 Oh well, maybe my mental visible is bad these days

BBaz

2020-07-12 17:30

reporter   ~0123936

Yeah optional parens are a problem sometimes...

Maybe close, I don't really care.

Sven Barth

2020-07-12 21:21

manager   ~0123941

@jamie: BBaz is talking about function/procedure and method variables. There is no issue with overloads there nor is there an issue with default parameters.

@BBaz: I'm not saying that the idea isn't good, in fact I had the same thought when I originally implemented type helpers, but the possible implications and how to deal with them are quite problematic...

Issue History

Date Modified Username Field Change
2020-07-11 22:11 BBaz New Issue
2020-07-12 13:25 Sven Barth Note Added: 0123922
2020-07-12 13:26 Sven Barth Priority normal => low
2020-07-12 13:26 Sven Barth Severity minor => feature
2020-07-12 13:26 Sven Barth FPCTarget => -
2020-07-12 13:26 Sven Barth Note Edited: 0123922 View Revisions
2020-07-12 16:20 jamie philbrook Note Added: 0123932
2020-07-12 17:30 BBaz Note Added: 0123936
2020-07-12 21:21 Sven Barth Note Added: 0123941