Re: [fpc-pascal] access violation?
Am 27.07.2018 um 19:41 schrieb Ryan Joseph: On Jul 27, 2018, at 11:24 AM, Mattias Gaertner wrote: You can't if you compile with -CR. The RTL is not compiled with objectchecks, so it works there. According to this test not only can you call methods on nil objects but it calls the method statically (like a class method), i.e the test prints “DoThis”. How is that possible? Self on x86_64 target is just a hidden argument. It won't work with virtual methods. This is all news to me. I had no idea I was possibly compiling programs where I could call nil objects. Normal, non-virtual methods are essentially ordinary functions/procedures. In contrast to static functions/procedures they have a hidden parameter that contains the value of Self. As Self is merely a pointer there is no problem if Self should be Nil as long as it isn't dereferenced (which happens if you access a field or a call a virtual method). Calling a virtual method would fail immediately. How do I disable this? I just ran this test program with -CR and I still calls the method statically. The method is always called statically, -CR doesn't change anything there. Calling a virtual method however would fail with EObjectCheck instead of EAccessViolation. The method you provided below would not fail anyway, because it doesn't dereference Self. If you'd however access for example a field of your class then a check should be inserted inside the method. For some reason it isn't however and *that* is the bug. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Syntax changes suggestions
Well, I am also of the opinion that threadvar is kind of a kludge too. I think part of the aesthetic of Pascal is that it reads fairly close to English. Creating a lot of new compound words is a bit jarring. As I just now figured out how to articulate the above, I have what I think is a more consistent group of proposals. It will prevent needing to create a lot of special keywords: var c: thread TMyClass; d: auto TMyClass; Or, perhaps even better: thread var c: TMyClass; managed var d: TMyClass; Cheers, R0b0t1 On Thu, Jul 26, 2018 at 10:19 PM, Ryan Joseph wrote: > > >> On Jul 25, 2018, at 8:05 AM, R0b0t1 wrote: >> >> This looks ugly. It also introduces modifiers to variable >> declarations. Some features should not be part of the language, they >> should be built on top of it. > > > Yeah, introducing modifiers to variables is not so great. You could avoid > introducing modifiers but using a new section like “scopevar” which is > similar to “threadvar” I guess. > > scopevar > c: TMyClass; > begin > c := TMyClass.Create; > > I accomplish this in my code using an auto release pool which empties at the > end of every event loop. > > var > c: TMyClass; > begin > c := TMyClass.Create; > c.AutoRelease; > > // or > c := TMyClass.Instance; // calls Create + AutoRelease in the constructor > > That’s not so pretty either, involves extra constructors sometimes (if you > want to keep things pretty) and it requires extra infrastructure you need to > setup. Jonas told me once this is actually more efficient though since it > frees multiple objects all at the same time so it decreases heap > fragmentation (I think he meant). This idea is heavily utilized in all of > Apple’s Cocoa frameworks so it’s a sound solution. > > > Meh, no free lunch, just food for thought. :) > > Regards, > Ryan Joseph > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Operator overload bug
On Mon, Jul 23, 2018 at 1:49 PM, Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > Ryan Joseph schrieb am Mo., 23. Juli 2018, > 17:35: > >> >> > On Jul 23, 2018, at 12:00 AM, Sven Barth via fpc-pascal < >> fpc-pascal@lists.freepascal.org> wrote: >> > >> > Yes, it's a bug, so please report it. >> >> Thanks, reported. The severity is “minor” which I guess is correct. >> > > "Minor" is the default severity. We have made the value not editable by > users, cause they'd more often than not consider their bugs as more severe > than really severe bugs. > > Regards, > Sven > Someone posted a working patch for this on the bugtracker report Ryan made, just to let you know. > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal