project1.lpr(11,19) Error: Only static methods and static variables can be referenced through an object type
project1.lpr(11,19) Error: Only static methods and static variables can be referenced through an object typeSelect bold. Use class.
Code: [Select]project1.lpr(11,19) Error: Only static methods and static variables can be referenced through an object type
There are objective reasons for this?
@PascalDragon
We either have a more productive Object. Or we prohibit everything up to the TP level (including static and class methods). The first option is much better))
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
I almost know:
- Devs will drop either object or deprecated on object.
The deprecated has been misinformation for many years.
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.
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.
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
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.
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.
class vars were as a syntazx never in TP. Only later Delphi.what abount static methods?
You are declaring a var in your code or something. That defeats the point of this discussion. As per MY example.Right, but the question is why compiler allows incorrect object definition.
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.
Still, it's probably better to fix class methods for objects. this is a very useful thing
I also want to clarify: Is normal work of class constructors and class destructor for objects an bug?
[...] there is no object instance in existence that the non-static MyMethod's hidden Self parameter can refer to.
Declaring the class procedure MyMethod as static removes that hidden Self parameter from the object's class method so you can call it as if it were a classic non-method procedure, i.e. a procedure not associated with any individual object.
Why is the static keyword necessary anyway? Ideally the class keyword in front of procedure or function should already remove the hidden parameter.