Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting statement #19

Closed
alpinistbg opened this issue Jan 15, 2023 · 1 comment
Closed

Conflicting statement #19

alpinistbg opened this issue Jan 15, 2023 · 1 comment

Comments

@alpinistbg
Copy link
Contributor

Here, at the end of line 943:

... This dirty trick works only in non-virtual methods (that don't call any virtual methods and don't access any fields).

But actually TObject.Free calls TObject.Destroy which is in turn virtual.

@michaliskambi
Copy link
Owner

Thank you!

Indeed the clause "(that don't call any virtual methods and don't access any fields)" was confusing. It was meant to mean "you cannot call any virtual methods / access fields if Self is (possibly) nil".

I improved the text, also added an example showing it in https://github.com/michaliskambi/modern-pascal-introduction/blob/master/code-samples/method_with_self_nil.lpr . As expected, it works with non-virtual method, but crashes with virtual.

screenshot 2023-01-18 12-47-41 select

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants