Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread ListMember
On 2014-10-29 14:58, Sven Barth wrote: Delphi introduced weak variable to break up cycling, I implemented them similary in my branch (not using the attribute syntax though) and in Florian's suggestions all object instance variables in legacy code would be "weak" for backwards compatibility. G

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Jonas Maebe
On 29/10/14 17:50, Sven Barth wrote: > On 29.10.2014 16:45, Jonas Maebe wrote: >> >> That's indeed only useful if you then also require that all code not >> written in non-ARC mode performs manual reference counting (like Apple >> does). Having it as "a possibility" does not solve the problem of >>

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Sven Barth
On 29.10.2014 16:45, Jonas Maebe wrote: On 29 Oct 2014, at 16:30, Sven Barth wrote: On 29.10.2014 14:23, Jonas Maebe wrote: Apple also supports mixing ARC and non-ARC code in Objective-C, but the only way this works is by requiring the programmer to manually perform the reference counting in

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Sven Barth
On 29.10.2014 16:59, Michael Schnell wrote: On 10/29/2014 04:17 PM, hinsta...@yandex.ru wrote: I suggest leaving TList from FPC RTL as is. It works with pointers, so leave it be. OK. Repeating the argument for TObjectList. TObjectList could (and IMHO should) be extended with support for manu

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Michael Schnell
On 10/29/2014 04:17 PM, hinsta...@yandex.ru wrote: I suggest leaving TList from FPC RTL as is. It works with pointers, so leave it be. OK. Repeating the argument for TObjectList. -Michael ___ fpc-devel maillist - fpc-devel@lists.freepascal.o

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Jonas Maebe
On 29 Oct 2014, at 16:30, Sven Barth wrote: On 29.10.2014 14:23, Jonas Maebe wrote: Apple also supports mixing ARC and non-ARC code in Objective-C, but the only way this works is by requiring the programmer to manually perform the reference counting in non-ARC code. I don't think there's

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Sven Barth
On 29.10.2014 15:56, hinsta...@yandex.ru wrote: however mandatory explicit casting is also a viable option: thing := TObject(refThing); // okay, compiler, I know what I'm doing, now do your thing, cast this for me Mandatory explicit typecasts would indeed be an option. This way one would (h

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Sven Barth
On 29.10.2014 16:17, hinsta...@yandex.ru wrote: I suggest leaving TList from FPC RTL as is. It works with pointers, so leave it be. For refcounted objects we would use generic list like TFPGList from fgl unit. However, currently existing TFPGList implementation would be unable to deal with re

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Sven Barth
On 29.10.2014 15:33, hinsta...@yandex.ru wrote: I believe that whoever came up with new strings overcomplicated it Consider Java and C# : they do not store encoding in string variables Because in C# and Java they are UTF-16. Keep in mind that Delphi also changed to UTF-16 based strings (Unicod

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Sven Barth
On 29.10.2014 14:23, Jonas Maebe wrote: On 27 Oct 2014, at 19:59, Sven Barth wrote: Florian has written me an idea two weeks ago regarding the "backwards compatibility" aspect (I won't argue the performance impact one ;) ): - TObject and all descendants are reference counted (please no size an

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread hinstance
I suggest leaving TList from FPC RTL as is. It works with pointers, so leave it be. For refcounted objects we would use generic list like TFPGList from fgl unit. However, currently existing TFPGList implementation would be unable to deal with refcounted objects correctly because TFPGLists uses

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Michael Schnell
On 10/29/2014 03:56 PM, hinsta...@yandex.ru wrote: Whatever; I disagree refcounted descendants of non-refcounted objects should be assignable to any variable of parent type; just like any variable is assignable to a variable of parent type And what about TLIst ? If TList is done for not ref-co

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Michael Schnell
On 10/29/2014 03:33 PM, hinsta...@yandex.ru wrote: I believe that whoever came up with new strings overcomplicated it Consider Java and C# : they do not store encoding in string variables Yep. dynamically encoded Strings are a nice feature if done appropriately. But I don't think they are str

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread hinstance
Whatever; I disagree refcounted descendants of non-refcounted objects should be assignable to any variable of parent type; just like any variable is assignable to a variable of parent type type TRefc = class refcounted(TObject) end; var thing: TObject; refThing: TRefc; begin ... th

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Jonas Maebe
On 29 Oct 2014, at 15:09, hinsta...@yandex.ru wrote: With lists it's worse. If you store pointers to interface variables, they become invalid the moment you don't have any "managed" variables left in scope. Same is true for refcounted objects: if you store them in good old TObjectList, i

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Dmitry Boyarintsev
On Wed, Oct 29, 2014 at 10:38 AM, Dmitry Boyarintsev < skalogryz.li...@gmail.com> wrote: > ... about Delphi compatibility. > > That's the number two (and some times number one) reason, why FPC has to deal with the new features as ref-counting, anonymous functions, strings ...etc. _

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Dmitry Boyarintsev
On Wed, Oct 29, 2014 at 10:33 AM, wrote: > I believe that whoever came up with new strings overcomplicated it > Consider Java and C# : they do not store encoding in string variables > And NSFoundation (the foundation for Cocoa and iOS) strings do. But adding encoding was not about "what other l

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread hinstance
I believe that whoever came up with new strings overcomplicated it Consider Java and C# : they do not store encoding in string variables 29.10.2014, 17:30, "Michael Schnell" : > On 10/29/2014 03:09 PM, hinsta...@yandex.ru wrote: >>  I believe you overcomplicate it > > No. We are going to run into

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Michael Schnell
On 10/29/2014 03:09 PM, hinsta...@yandex.ru wrote: I believe you overcomplicate it No. We are going to run into the same mess with incompatible brands of the same types as with "New Strings" :-( -Michael ___ fpc-devel maillist - fpc-devel@lists.f

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Michael Schnell
On 10/29/2014 01:58 PM, Sven Barth wrote: - no change in reference count when assigning a refcounted object variable to it - no change in reference count when assigning it to a refcounted object variable - no change in reference conut when assigning between "weak" variables Thanks for the ex

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread hinsta...@yandex.ru
I believe you overcomplicate itVariable type should define if variable is reference-counted or not.class refcounted => refcountedclass descendant from class refcounted => refcountednormal class => not refcountedpass refcounted instance as TObject => not refcounted at all...Consider existing COM int

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Martin Frb
On 29/10/2014 13:03, Sven Barth wrote: On 28.10.2014 09:57, Hans-Peter Diettrich wrote: Sven Barth schrieb: Take unit Typinfo for example where quite some methods take a TObject instance. The TypInfo methods can determine the exact type of their arguments, and act inside accordingly. If you

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Jonas Maebe
On 27 Oct 2014, at 19:59, Sven Barth wrote: Florian has written me an idea two weeks ago regarding the "backwards compatibility" aspect (I won't argue the performance impact one ;) ): - TObject and all descendants are reference counted (please no size and performance discussion here) - in

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Sven Barth
On 28.10.2014 11:20, hinsta...@yandex.ru wrote: I attached a very small sample project which can not be compiled with FreePascal ARC edition. Thanks, I can reproduce it with that example. + one more thing I noticed: Lazarus 1.3 (trunk) compiled with FreePascal ARC edition refuses to start. Pe

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Sven Barth
On 28.10.2014 10:15, Michael Schnell wrote: On 10/27/2014 05:17 PM, Hans-Peter Diettrich wrote: Something like ShortString and AnsiString? Only that ShortStrings can easily be avoided (AFAIK, no great performance advantage to use them) and hence are seldom used right now. ShortStrings don't

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Sven Barth
On 28.10.2014 09:57, Hans-Peter Diettrich wrote: Sven Barth schrieb: Am 27.10.2014 21:00, schrieb Hans-Peter Diettrich: Sven Barth schrieb: Am 27.10.2014 17:20 schrieb "Hans-Peter Diettrich" mailto:drdiettri...@aol.com>>: > Something like ShortString and AnsiString? With the difference th

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Sven Barth
On 28.10.2014 10:19, Michael Schnell wrote: On 10/27/2014 07:59 PM, Sven Barth wrote: - in code that does not use ARC ("modeswitch arc off" - the default; or maybe better a local directive) all instance variables are considered "weak" While I do have a vision what "weak" means here, can you g

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Michael Schnell
On 10/29/2014 01:27 PM, Michael Schnell wrote: I forgot: ...(b1) you can't assign a ref counted object to a variable of the not ref counted type brand: this will result in a runtime error (as the ref counted TObject type can hold not ref-counted objects by ref-count = -1) ...(b2) you can assign

Re: [fpc-devel] Proof of Concept ARC implementation

2014-10-29 Thread Michael Schnell
Considering the multiple discussions recently here done on the "New Strings", that also introduce multiple compiler-relevant brands of a single type, IMHO there are some restrictions to be payed attention to, if the user is enable to use both ref-counted and not ref-counted Objects. Otherwise w