Recent

Author Topic: Why is it impossible to call not static object class method by object type  (Read 7066 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 10993
Re: Why is it impossible to call not static object class method by object type
« Reply #15 on: October 19, 2021, 10:10:04 am »
Mark,
object is deprecated for almost 20 years. I already suggested to the Delphi people to withdraw that "deprecated" many moons ago since it has definite and applicable functionality other than class. I also suggested on this forum in a different context that for the same reason the "deprecated" mark should be removed.
The average programmer productivity is 4-5 hours per day. Peak performance 72 hours for short bursts. MTBF is 1 second or less.

Thaddy

  • Hero Member
  • *****
  • Posts: 10993
Re: Why is it impossible to call not static object class method by object type
« Reply #16 on: October 19, 2021, 12:12:07 pm »
I almost know:
- Devs will drop either object  or deprecated on object.
The deprecated has been misinformation for many years.
The average programmer productivity is 4-5 hours per day. Peak performance 72 hours for short bursts. MTBF is 1 second or less.

MarkMLl

  • Hero Member
  • *****
  • Posts: 3537
Re: Why is it impossible to call not static object class method by object type
« Reply #17 on: October 19, 2021, 12:22:34 pm »
I almost know:
- Devs will drop either object  or deprecated on object.
The deprecated has been misinformation for many years.

We are repeatedly told that he core developers don't like object. We are also repeatedly told that TP and Delphi compatibility are extremely important.

My own no-doubt-uninformed opinion is that so much effort has been involved in keeping up with Delphi's advances that that compatibility will not be discarded, even if- and I'm not trying to criticise here- the result would be a cleaner language.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

korba812

  • Full Member
  • ***
  • Posts: 224
Re: Why is it impossible to call not static object class method by object type
« Reply #18 on: October 19, 2021, 12:31:31 pm »
I can use class function for objects like this:
Code: Pascal  [Select][+][-]
  1. program Project1;
  2. type
  3.   TMyType=object
  4.     class procedure MyMethod;
  5.   end;
  6. class procedure TMyType.MyMethod;
  7. begin
  8.   writeln('class procedure TMyType.MyMethod');
  9. end;
  10. var
  11.   O: TMyType;
  12. begin
  13.   O.MyMethod;
  14.   readln;
  15. end.

kupferstecher

  • Sr. Member
  • ****
  • Posts: 460
Re: Why is it impossible to call not static object class method by object type
« Reply #19 on: October 19, 2021, 12:34:19 pm »
The core developers repeat on a regular basis that _object_ is only there for legacy compatibility, and all new work is going into _class_.

Yes, but thats really a pity. On target embedded I use OOP without a dynamic memory.

In my opinion class and object should be rectified to go hand in hand with each other. On syntax level nothing would change only the internals like the VMT could change. That would mean full backward compatibility on code level. Internally object and class could be managed in the same way, for the class type this would mean that there should be a more lightweight base class other than TObject and VMT being optional. If there is a very lightweight object and class type, having no overhead, i.e. internally behaving like a record, then even the record type could be seen as deprecated.

I guess what stands against it, are concerns, that Delphi does future changes that may be incompatible to such a fpc-specific implementation.

MarkMLl

  • Hero Member
  • *****
  • Posts: 3537
Re: Why is it impossible to call not static object class method by object type
« Reply #20 on: October 19, 2021, 12:40:19 pm »
Yes, but thats really a pity.

Yes, it /is/ a pity... but the solution is to fork the project. And quite frankly I think there are far more fundamental problems in Pascal which need to be fixed if that is done, based on "best practice" which has become obvious in the 50 years since Wirth hacked it.

None of which detracts from FPC/Lazarus's position as one of if not /the/ best development environment of this type.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Thaddy

  • Hero Member
  • *****
  • Posts: 10993
Re: Why is it impossible to call not static object class method by object type
« Reply #21 on: October 19, 2021, 01:05:04 pm »
I can use class function for objects like this:
You are declaring a var in your code or something. That defeats the point of this discussion. As per MY example.
Class syntax is simply different from object syntax.....(sigh)

Really: object is not class, class procedures on objects are unreasonable in the first place.
Just need static to have the same result....
« Last Edit: October 19, 2021, 01:13:55 pm by Thaddy »
The average programmer productivity is 4-5 hours per day. Peak performance 72 hours for short bursts. MTBF is 1 second or less.

PascalDragon

  • Hero Member
  • *****
  • Posts: 3521
  • Compiler Developer
Re: Why is it impossible to call not static object class method by object type
« Reply #22 on: October 19, 2021, 01:37:29 pm »
Then you need to declare the object as deprecated. How it is done in delphi. The apparent appearance of new features (which as it turns out are a bug) misleads people

No, deprecated means that no further work is done and that even bugs aren't fixed. However we do fix bugs (as seldom as they are for object) and here and then a feature implemented for classes falls off for objects as well simply because they share a lot of code in the compiler.

We are repeatedly told that he core developers don't like object. We are also repeatedly told that TP and Delphi compatibility are extremely important.

Please don't put words in our mouths. We don't say that we “don't like object”. It's simply that we see no real use to invest in extending it. object has its uses (it's even used inside the compiler in some locations, though nowadays they could be replaced with advanced records) like the one mentioned by kuperstecher on embedded platforms, but that's it. It's simply that the type is not going to grow beyond its original aspirations.

In my opinion class and object should be rectified to go hand in hand with each other. On syntax level nothing would change only the internals like the VMT could change. That would mean full backward compatibility on code level. Internally object and class could be managed in the same way, for the class type this would mean that there should be a more lightweight base class other than TObject and VMT being optional. If there is a very lightweight object and class type, having no overhead, i.e. internally behaving like a record, then even the record type could be seen as deprecated.

They are too different and there is code out there that depends on these differences (yes, even the VMT, because the class vmt is available as System.TVMT and the object one is also documented). So not going to happen.

zamtmn

  • Sr. Member
  • ****
  • Posts: 418
Re: Why is it impossible to call not static object class method by object type
« Reply #23 on: October 19, 2021, 02:20:34 pm »
I don't remember class methods and static methods in TP, maybe in latest BP?
In my opinion, it should be banned class methods or enable referenced by type

I understand that a lot of effort is being spent, and other things are in priority... But everything should work logically

>>Just need static to have the same result....
not quite - static not compatible with "of object"
« Last Edit: October 19, 2021, 02:52:02 pm by zamtmn »

Thaddy

  • Hero Member
  • *****
  • Posts: 10993
Re: Why is it impossible to call not static object class method by object type
« Reply #24 on: October 19, 2021, 03:44:24 pm »
class vars were as a syntazx never in TP. Only later Delphi.
The average programmer productivity is 4-5 hours per day. Peak performance 72 hours for short bursts. MTBF is 1 second or less.

zamtmn

  • Sr. Member
  • ****
  • Posts: 418
Re: Why is it impossible to call not static object class method by object type
« Reply #25 on: October 19, 2021, 04:15:31 pm »
class vars were as a syntazx never in TP. Only later Delphi.
what abount static methods?

korba812

  • Full Member
  • ***
  • Posts: 224
Re: Why is it impossible to call not static object class method by object type
« Reply #26 on: October 19, 2021, 04:47:03 pm »
You are declaring a var in your code or something. That defeats the point of this discussion. As per MY example.
Class syntax is simply different from object syntax.....(sigh)

Really: object is not class, class procedures on objects are unreasonable in the first place.
Just need static to have the same result....
Right, but the question is why compiler allows incorrect object definition.

PascalDragon

  • Hero Member
  • *****
  • Posts: 3521
  • Compiler Developer
Re: Why is it impossible to call not static object class method by object type
« Reply #27 on: October 20, 2021, 09:13:52 am »
Right, but the question is why compiler allows incorrect object definition.

Due to objects and classes sharing quite a lot of code inside the compiler it needs to be actively forbidden for one and if that is forgotten, well, that leads to situations like this.

zamtmn

  • Sr. Member
  • ****
  • Posts: 418
Re: Why is it impossible to call not static object class method by object type
« Reply #28 on: October 20, 2021, 05:22:40 pm »
Still, it's probably better to fix class methods for objects. this is a very useful thing

edit:
I also want to clarify: Is normal work of class constructors and class destructor for objects an bug?
« Last Edit: October 20, 2021, 06:25:56 pm by zamtmn »

PascalDragon

  • Hero Member
  • *****
  • Posts: 3521
  • Compiler Developer
Re: Why is it impossible to call not static object class method by object type
« Reply #29 on: October 21, 2021, 09:08:23 am »
Still, it's probably better to fix class methods for objects. this is a very useful thing

There is nothing that can be fixed, because non-static class methods simply can not work for objects. Objects have no TClass-like meta type which is required for that. The only fix there'll be is to disallow non-static class methods for objects, cause they simply don't make sense.

I also want to clarify: Is normal work of class constructors and class destructor for objects an bug?

Class constructors and destructors are not supposed to work on objects either.

 

TinyPortal © 2005-2018