Re: [fpc-pascal] Primitive Record Wrappers

2016-03-19 Thread Mazola Winstrol
2016-03-11 0:15 GMT-03:00 silvioprog : > On Sun, Mar 6, 2016 at 7:21 PM, Mazola Winstrol > wrote: > [...] > >> Please see the code in attachments and send your suggestions / remarks. >> > > Thanks for share. > > How do I use the the

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-11 Thread Sven Barth
Am 11.03.2016 08:19 schrieb "Michael Van Canneyt" : > > > > On Fri, 11 Mar 2016, Sven Barth wrote: > >> Am 11.03.2016 04:16 schrieb "silvioprog" : >>> >>> >>> On Sun, Mar 6, 2016 at 7:21 PM, Mazola Winstrol >> >> wrote: >>> >>>

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-10 Thread Michael Van Canneyt
On Fri, 11 Mar 2016, Sven Barth wrote: Am 11.03.2016 04:16 schrieb "silvioprog" : On Sun, Mar 6, 2016 at 7:21 PM, Mazola Winstrol wrote: [...] Please see the code in attachments and send your suggestions / remarks. Thanks for share. How

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-10 Thread Sven Barth
Am 11.03.2016 04:16 schrieb "silvioprog" : > > On Sun, Mar 6, 2016 at 7:21 PM, Mazola Winstrol wrote: > [...] >> >> Please see the code in attachments and send your suggestions / remarks. > > > Thanks for share. > > How do I use the the

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-10 Thread silvioprog
On Sun, Mar 6, 2016 at 7:21 PM, Mazola Winstrol wrote: [...] > Please see the code in attachments and send your suggestions / remarks. > Thanks for share. How do I use the the NullableTypes.String unit? Tried: program project1; {$mode objfpc}{$H+} uses

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-03 Thread silvioprog
On Thu, Mar 3, 2016 at 10:16 AM, Mazola Winstrol wrote: > 2016-03-02 23:12 GMT-03:00 silvioprog : > >> On Tue, Mar 1, 2016 at 12:08 AM, Mazola Winstrol >> wrote: >> [...] >>> >>> I apologize, it works. >>> >> >> Do you have plan

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-03 Thread Mazola Winstrol
2016-03-02 23:12 GMT-03:00 silvioprog : > On Tue, Mar 1, 2016 at 12:08 AM, Mazola Winstrol > wrote: > [...] >> >> I apologize, it works. >> > > Do you have plan to share it in some place like Github, Lazarus-CCR or as > Lazarus generics demo? Just a

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-02 Thread silvioprog
On Tue, Mar 1, 2016 at 12:08 AM, Mazola Winstrol wrote: [...] > > I apologize, it works. > Do you have plan to share it in some place like Github, Lazarus-CCR or as Lazarus generics demo? Just a idea, because this implementation sounds good. -- Silvio Clécio

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-01 Thread Constantine Yannakopoulos
On Tue, Mar 1, 2016 at 3:59 PM, Mazola Winstrol wrote: > > Can you send me? > ​Done.​ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-01 Thread Mazola Winstrol
2016-03-01 10:07 GMT-03:00 Constantine Yannakopoulos : > > The only solution I have found is to implement ALL operators for > TNullableType by defining a generic interface INullableOperatiors > that contains methods for all operators, then implement for each type by > means

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-01 Thread Constantine Yannakopoulos
On Mon, Feb 29, 2016 at 5:13 PM, Mazola Winstrol wrote: > I have noticed that, by using generics, we can't overload arithmetic > operators. > > E.g.: > > ... > class operator Negative(A: TNullableType): T; > ... > > class operator TNullableType.Negative(A: TNullableType):

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-01 Thread Mazola Winstrol
2016-03-01 1:48 GMT-03:00 : > On 02/29/2016 10:08 PM, Mazola Winstrol wrote: > >> There is a problem in my design. The code won't compile if i try to >> specialize with a type which doesn'y supports arithmetic operators e.g >> String >> types. >> > > apparently i'm

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-01 Thread Mazola Winstrol
2016-03-01 9:13 GMT-03:00 Sven Barth : > Am 01.03.2016 04:08 schrieb "Mazola Winstrol" : > > Is there any way to overcome this? Is there any way to tell the compiler > to ignore some operators depending on the specialization type? > > No, there

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-01 Thread Sven Barth
Am 01.03.2016 04:08 schrieb "Mazola Winstrol" : > Is there any way to overcome this? Is there any way to tell the compiler to ignore some operators depending on the specialization type? No, there is not. Better not use operators other than the assignment ones or provide

Re: [fpc-pascal] Primitive Record Wrappers

2016-03-01 Thread Rainer Stratmann
On Wednesday 17 February 2016 18:40:52 you wrote: > Hello list, > > In some situations, would be very interesting to determine whether the > value of a primitive variable is initialized or not. For example, fields in > database records can contain null values. By implementing an ORM, it would >

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-29 Thread Mazola Winstrol
2016-02-29 13:16 GMT-03:00 Sven Barth : > Am 29.02.2016 16:13 schrieb "Mazola Winstrol" : > > > > I have noticed that, by using generics, we can't overload arithmetic > operators. > > > > E.g.: > > > > ... > > class operator Negative(A:

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-29 Thread Sven Barth
Am 29.02.2016 16:13 schrieb "Mazola Winstrol" : > > I have noticed that, by using generics, we can't overload arithmetic operators. > > E.g.: > > ... > class operator Negative(A: TNullableType): T; > ... > > class operator TNullableType.Negative(A: TNullableType): T; > begin

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-29 Thread Mazola Winstrol
I have noticed that, by using generics, we can't overload arithmetic operators. E.g.: ... class operator Negative(A: TNullableType): T; ... class operator TNullableType.Negative(A: TNullableType): T; begin Result := -1 * A; end; wouldn't compile with the error "Operator not applicable

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-29 Thread Mazola Winstrol
2016-02-27 14:58 GMT-03:00 silvioprog : > > $MODE DELPHI implies {$H ON} > , so so you > should remove the {$H+}. > > Thanks for the tip! i will remove for the next version.

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-28 Thread Maciej Izak
2016-02-27 9:44 GMT+01:00 Sven Barth : > Sidenote for this (don't know whether you have already ensured that): > these operators must not be useable as global operators as after all they > must he known in the RTTI and that can't work if they're declared in > another

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-27 Thread silvioprog
On Sat, Feb 27, 2016 at 2:49 PM, Mazola Winstrol wrote: > I've implemented a new version. For this version i created a mock class to > use with FHasValue (the previous implementation uses a hack to the > interface internal layout). > Thanks for share that. It seems a very

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-27 Thread Mazola Winstrol
2016-02-27 0:49 GMT-03:00 Dmitry Boyarintsev : > On Fri, Feb 26, 2016 at 10:38 PM, Mazola Winstrol > wrote: > >> In the code bellow, the generic type TNullableTyple is implemented (and >> incomplete for now). >> > How to reset TNullableType to

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-27 Thread Mazola Winstrol
I've implemented a new version. For this version i created a mock class to use with FHasValue (the previous implementation uses a hack to the interface internal layout). unit NullableTypes; {$mode delphi}{$H+} interface type { TMockInterfacedObject } TMockInterfacedObject =

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-27 Thread Sven Barth
Am 27.02.2016 09:36 schrieb "Maciej Izak" : > > 2016-02-27 4:38 GMT+01:00 Mazola Winstrol : >> >> In the code bellow, the generic type TNullableTyple is implemented (and incomplete for now). >> > > It can be done more optimal with incoming operators

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-27 Thread Maciej Izak
2016-02-27 4:38 GMT+01:00 Mazola Winstrol : > In the code bellow, the generic type TNullableTyple is implemented (and > incomplete for now). > > It can be done more optimal with incoming operators Initialize and Finalize. I have working implementation but I need to adjust

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-26 Thread Dmitry Boyarintsev
On Fri, Feb 26, 2016 at 10:38 PM, Mazola Winstrol wrote: > In the code bellow, the generic type TNullableTyple is implemented (and > incomplete for now). > How to reset TNullableType to Null value? HasValue seems to be read-only. > Is there any possibility of "nullable

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-26 Thread Mazola Winstrol
Hello, In the code bellow, the generic type TNullableTyple is implemented (and incomplete for now). Is there any possibility of "nullable types" be added to RTL or anyother fpc provided package? unit NullableTypes; {$mode delphi}{$H+} interface type { TNullable } TNullable = record

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-23 Thread Maciej Izak
2016-02-20 9:23 GMT+01:00 Sven Barth : > Am 20.02.2016 06:25 schrieb "Michalis Kamburelis" < > michalis.ka...@gmail.com>: > > I remember a thread on fpc-devel "Pascal Smart Pointers Idea + ARC > > implementation" where the original author (Maciej Izak) was already > >

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-21 Thread Sven Barth
Am 21.02.2016 03:02 schrieb "Mazola Winstrol" : > > 2016-02-20 3:24 GMT-02:00 Michalis Kamburelis : >> >> The major problem there is that it's difficult to force it to be >> always initialized with zeroes. Currently, a non-global variable of >>

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-20 Thread Mazola Winstrol
2016-02-20 3:24 GMT-02:00 Michalis Kamburelis : > The major problem there is that it's difficult to force it to be > always initialized with zeroes. Currently, a non-global variable of > unmanaged type can always be filled with memory garbage, as explained > in other

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-20 Thread Sven Barth
Am 20.02.2016 06:25 schrieb "Michalis Kamburelis" : > I remember a thread on fpc-devel "Pascal Smart Pointers Idea + ARC > implementation" where the original author (Maciej Izak) was already > working to overcome this: >

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-19 Thread Michalis Kamburelis
2016-02-18 15:43 GMT+01:00 Mazola Winstrol : > Em 18/02/2016 10:12, "Marco van de Voort" escreveu: >> >> In our previous episode, Mazola Winstrol said: >> >end; >> > >> > >> > Suppose that this class represent data of the Person table in a sql >> >

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-18 Thread Mazola Winstrol
Em 18/02/2016 10:12, "Marco van de Voort" escreveu: > > In our previous episode, Mazola Winstrol said: > >end; > > > > > > Suppose that this class represent data of the Person table in a sql > > database. Suppose that there is records where the column "BirthDate" is > > null.

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-18 Thread Marco van de Voort
In our previous episode, Mazola Winstrol said: >end; > > > Suppose that this class represent data of the Person table in a sql > database. Suppose that there is records where the column "BirthDate" is > null. How do i represent a null "BirthDate" in my object? Keep using variants instead of

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-18 Thread Mazola Winstrol
2016-02-18 8:00 GMT-02:00 leledumbo : > > What do you think about it? Is there any other solution? > > There's a reason why > http://www.freepascal.org/docs-html/3.0.0/fcl/db/tfield.isnull.html is > invented > > You didnt understand my point. Design classes coupled

Re: [fpc-pascal] Primitive Record Wrappers

2016-02-18 Thread leledumbo
> What do you think about it? Is there any other solution? There's a reason why http://www.freepascal.org/docs-html/3.0.0/fcl/db/tfield.isnull.html is invented -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Primitive-Record-Wrappers-tp5724175p5724180.html

[fpc-pascal] Primitive Record Wrappers

2016-02-17 Thread Mazola Winstrol
Hello list, In some situations, would be very interesting to determine whether the value of a primitive variable is initialized or not. For example, fields in database records can contain null values. By implementing an ORM, it would be interesting to represent these null values in the properties