Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-21 Thread Sven Barth via fpc-pascal
Mattias Gaertner schrieb am Do., 21. Juni 2018, 09:24: > On Wed, 20 Jun 2018 21:56:56 +0200 > Sven Barth via fpc-pascal wrote: > > >[...] > > The modeswitch is enabled by default in Delphi modes as this feature was > > added for Delphi compatibility. > > I would like to use that for objfpc. > Is

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-21 Thread Sven Barth via fpc-pascal
Mark Morgan Lloyd schrieb am Do., 21. Juni 2018, 09:11: > On 20/06/18 20:00, Sven Barth via fpc-pascal wrote: > > > Addendum: the support for the "+" operator is now coupled to a new > > modeswitch "ArrayOperators". > > If the modeswitch is enabled, then the operator can not be overloaded > > and

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-21 Thread Ryan Joseph
I mean the += [] part. :) > On Jun 21, 2018, at 3:37 PM, Mattias Gaertner > wrote: > > Note: This was supported for a long time. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-21 Thread Mattias Gaertner
On Thu, 21 Jun 2018 15:17:39 +0700 Ryan Joseph wrote: >[...] > Finally got to try this. It’s really satisfying being able to do: >[...] > for i in arr do Note: This was supported for a long time. Mattias ___ fpc-pascal maillist - fpc-pascal@

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-21 Thread Ryan Joseph
> On Jun 21, 2018, at 2:56 AM, Sven Barth via fpc-pascal > wrote: > > Addendum: the support for the "+" operator is now coupled to a new modeswitch > "ArrayOperators". Finally got to try this. It’s really satisfying being able to do: var arr: array of integer = (1, 2, 3); i:

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-21 Thread Mattias Gaertner
On Wed, 20 Jun 2018 21:56:56 +0200 Sven Barth via fpc-pascal wrote: >[...] > The modeswitch is enabled by default in Delphi modes as this feature was > added for Delphi compatibility. I would like to use that for objfpc. Is there a command line flag to enable a modeswitch? Mattias

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-21 Thread Mark Morgan Lloyd
On 20/06/18 20:00, Sven Barth via fpc-pascal wrote: Addendum: the support for the "+" operator is now coupled to a new modeswitch "ArrayOperators". If the modeswitch is enabled, then the operator can not be overloaded and it also won't be used even if an overload from a unit without the modesw

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-20 Thread Sven Barth via fpc-pascal
Am 20.05.2018 um 14:23 schrieb Sven Barth: Hello together! I'm pleased to announce that after nearly a year various extensions for dynamic arrays have been finished. This includes the following features: - support for array constructors using "[...]" syntax - support for Insert(), Delete() a

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-18 Thread Sven Barth via fpc-pascal
Am 19.06.2018 um 00:57 schrieb Joao Schuler: If I can, I would like to vote for "&" instead of "+". As I use Free Pascal with math (neural networks), I would vote for "&" with concatenation and "||" with "union" (in the case it's ever required). There won't be any voting as the "+" operator was

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-18 Thread Joao Schuler
If I can, I would like to vote for "&" instead of "+". As I use Free Pascal with math (neural networks), I would vote for "&" with concatenation and "||" with "union" (in the case it's ever required). On Mon, Jun 18, 2018 at 5:24 AM, Roger Rivero Jr. (SAMPA WebMaster) < sa...@caonao.cu> wrote: >

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-18 Thread Roger Rivero Jr. (SAMPA WebMaster)
Dear Sir: I don´t like your way of answering. Period. Mathematical operators on matrices (+, -, *, ~, etc.) have being defined centuries ago, and all the scientific community uses the same conventions on them. It´s not proper that somebody now would like to redefine the conventions on his own

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-07 Thread Florian Klämpfl
Am 07.06.2018 um 12:42 schrieb Martok: What actually happens is that the memory is released back to the heap (but *not* to the OS, at least on Linux), with the result that concatenating elements will introduce a substantial hit particularly if space for a new element allocated from the heap isn't

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-07 Thread Sven Barth via fpc-pascal
Mark Morgan Lloyd schrieb am Do., 7. Juni 2018, 11:46: > On 04/06/18 12:00, Nitorami wrote: > >>> It would be reasonable to assume that the predefined + might be>> > substantially more efficient than a programmer-defined one could be. > >> Yes, that's one of the reasons I vote for keeping the new

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-07 Thread Mark Morgan Lloyd
On 07/06/18 10:45, Martok wrote: What actually happens is that the memory is released back to the heap > (but *not* to the OS, at least on Linux), with the result that > concatenating elements will introduce a substantial hit particularly if > space for a new element allocated from the heap is

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-07 Thread Martok
> What actually happens is that the memory is released back to the heap > (but *not* to the OS, at least on Linux), with the result that > concatenating elements will introduce a substantial hit particularly if > space for a new element allocated from the heap isn't contiguous. Writing a preallo

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-07 Thread Mark Morgan Lloyd
On 04/06/18 12:00, Nitorami wrote: It would be reasonable to assume that the predefined + might be>> substantially more efficient than a programmer-defined one could be. Yes, that's one of the reasons I vote for keeping the new feature>and allow to overload the operator. I don't think that ar

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-04 Thread Nitorami
>> It would be reasonable to assume that the predefined + might be >> substantially more efficient than a programmer-defined one could be. >Yes, that's one of the reasons I vote for keeping the new feature >and allow to overload the operator. I don't think that argument holds water. Concatenatio

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Bernd Oppolzer
Am 03.06.2018 um 18:12 schrieb Sven Barth via fpc-pascal: Bernd Oppolzer > schrieb am So., 3. Juni 2018, 11:56: Am 02.06.2018 um 15:14 schrieb Sven Barth via fpc-pascal: Mark Morgan Lloyd mailto:markmll.fpc-pas...@telemetry.co.uk>> schrieb am Sa., 2

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread denisgolovan
> Horses for courses. I think the impressive thing about APL is that the > necessary operations were worked out (and used for Blackboard > demonstrations) /before/ it was converted into a computer language, and > by and large weren't added to. However the functional nature of the > language was v

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Mark Morgan Lloyd
On 03/06/18 16:30, denisgolovan wrote: Having worked with APL for almost 6 years and continuing with Q/KDB, I would say APL syntax is much more readable than Perl 6. Horses for courses. I think the impressive thing about APL is that the necessary operations were worked out (and used for Black

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Marco van de Voort
In our previous episode, Sven Barth via fpc-pascal said: > > not exist, if FreePascal had gone another direction like PL/1, for > > example, > > where the string concatenation operator is || > > (and DB2, and - probably - other SQL dialects). > > > > FPC inherited the +-operator for concatenation

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread denisgolovan
Having worked with APL for almost 6 years and continuing with Q/KDB, I would say APL syntax is much more readable than Perl 6. Though being able to modify language like that is really impressive. BR, Denis ___ fpc-pascal maillist - fpc-pascal@lists

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Mark Morgan Lloyd
On 03/06/18 14:30, Ryan Joseph wrote: On Jun 3, 2018, at 9:07 PM, Marco van de Voort wrote:> > But nobody + an item to their item list. The operator is "+" not "add". What other operators could be used then? There’s only so many characters on the keyboard after all. My only interest is becaus

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Sven Barth via fpc-pascal
Ryan Joseph schrieb am So., 3. Juni 2018, 10:22: > > > > On Jun 3, 2018, at 3:15 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > Because operator overloads are static methods not normal methods. > > I don’t understand. Why aren’t both those variants possible? The

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Sven Barth via fpc-pascal
Bernd Oppolzer schrieb am So., 3. Juni 2018, 11:56: > > > Am 02.06.2018 um 15:14 schrieb Sven Barth via fpc-pascal: > > Mark Morgan Lloyd schrieb am Sa., 2. > Juni 2018, 10:53: > >> However as Dennis points out + is also essential for vector operations. >> Perhaps either leaving it to the progra

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Ryan Joseph
> On Jun 3, 2018, at 10:36 PM, Michael Van Canneyt > wrote: > > That is a horrible idea. > > Think of it: You will read someone else's code, and have absolutely no clue > what it does. For sure. Apple even showed how you can use emojis as operators. :) The best I can say is some interestin

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Michael Van Canneyt
On Sun, 3 Jun 2018, Ryan Joseph wrote: On Jun 3, 2018, at 9:07 PM, Marco van de Voort wrote: But nobody + an item to their item list. The operator is "+" not "add". What other operators could be used then? There’s only so many characters on the keyboard after all. My only interest is

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Ryan Joseph
> On Jun 3, 2018, at 9:07 PM, Marco van de Voort wrote: > > But nobody + an item to their item list. The operator is "+" not "add". What other operators could be used then? There’s only so many characters on the keyboard after all. My only interest is because it’s fast to type and looks nice

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Marco van de Voort
In our previous episode, Ryan Joseph said: > > but IMO it is strange to use + for string concatenation; > > I always have bad feelings about this. > > It?s actually pretty common to use the phrase ?adding two things together? > in English. For example: ?I?m going to add some more strawberries to

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Florian Klämpfl
Am 03.06.2018 um 15:15 schrieb Mattias Gaertner: On Sun, 3 Jun 2018 14:59:46 +0200 Florian Klämpfl wrote: [...] Yes, that's one of the reasons I vote for keeping the new feature and allow to overload the operator. There is still concat which provides exactly the same functionality. True.

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Mattias Gaertner
On Sun, 3 Jun 2018 14:59:46 +0200 Florian Klämpfl wrote: >[...] > > Yes, that's one of the reasons I vote for keeping the new feature > > and allow to overload the operator. > > There is still concat which provides exactly the same functionality. True. Same as in Delphi. Is there a problem h

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Florian Klämpfl
Am 03.06.2018 um 14:27 schrieb Mattias Gaertner: On Sun, 3 Jun 2018 11:34:33 + Mark Morgan Lloyd wrote: On 02/06/18 13:00, Mattias Gaertner wrote: Sven Barth via fpc-pascal hat am 2. Juni 2018 um 09:42 geschrieben: > > denisgolovan < denisgolo...@yandex.ru> schrieb am Sa., 2. Juni 2018,

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Mattias Gaertner
On Sun, 3 Jun 2018 11:34:33 + Mark Morgan Lloyd wrote: > On 02/06/18 13:00, Mattias Gaertner wrote: > >> Sven Barth via fpc-pascal hat am 2. Juni > >> 2018 um 09:42 geschrieben: > > denisgolovan < denisgolo...@yandex.ru> > >> schrieb am Sa., 2. Juni 2018, 09:18: > > @Sven > > Please recon

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Mark Morgan Lloyd
On 02/06/18 13:00, Mattias Gaertner wrote: Sven Barth via fpc-pascal hat am 2. Juni 2018 um 09:42 geschrieben: > > denisgolovan < denisgolo...@yandex.ru> schrieb am Sa., 2. Juni 2018, 09:18: > > @Sven > > Please reconsider "+" operator for arrays if your changes really forbid to overload oper

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Ryan Joseph
> On Jun 3, 2018, at 4:56 PM, Bernd Oppolzer wrote: > > but IMO it is strange to use + for string concatenation; > I always have bad feelings about this. It’s actually pretty common to use the phrase “adding two things together” in English. For example: “I’m going to add some more strawberri

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Bernd Oppolzer
Am 02.06.2018 um 15:14 schrieb Sven Barth via fpc-pascal: Mark Morgan Lloyd > schrieb am Sa., 2. Juni 2018, 10:53: However as Dennis points out + is also essential for vector operations. Perhaps either leaving it to the programmer to defi

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Ryan Joseph
> On Jun 3, 2018, at 3:15 PM, Sven Barth via fpc-pascal > wrote: > > Because operator overloads are static methods not normal methods. I don’t understand. Why aren’t both those variants possible? They’re both static I believe. The first is mutating the left side value and the second is a c

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread denisgolovan
Yes, if you want destructive updates you need a special syntax for that. I believe existing syntax is not suitable for destructive update, hence the error I mentioned. BR, Denis ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.f

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-03 Thread Sven Barth via fpc-pascal
Ryan Joseph schrieb am So., 3. Juni 2018, 05:35: > > > > On Jun 2, 2018, at 3:19 PM, denisgolovan wrote: > > > > BTW, you first overload is not implemented properly. You need to clone > "left" first and return it as a result. > > That’s probably the functionality you want but as an aside why can

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-02 Thread Ryan Joseph
> On Jun 2, 2018, at 3:19 PM, denisgolovan wrote: > > BTW, you first overload is not implemented properly. You need to clone "left" > first and return it as a result. That’s probably the functionality you want but as an aside why can’t + overload mutate the caller (left side) and not return

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-02 Thread Sven Barth via fpc-pascal
Mark Morgan Lloyd schrieb am Sa., 2. Juni 2018, 10:53: > However as Dennis points out + is also essential for vector operations. > Perhaps either leaving it to the programmer to define what's needed > would be the best approach, or alternatively splitting dynamic arrays > into mathematical vector

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-02 Thread Sven Barth via fpc-pascal
denisgolovan schrieb am Sa., 2. Juni 2018, 10:28: > Yes, I strongly support removing that functionality in favor of user > operator overloads or vector-compatible way. > To clear something up: this new operator will definitely not be removed. Period. What might be done however (and what I had p

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-02 Thread Mattias Gaertner
> Sven Barth via fpc-pascal hat am 2. Juni > 2018 um 09:42 geschrieben: > > denisgolovan < denisgolo...@yandex.ru> schrieb am Sa., 2. Juni 2018, 09:18: > > @Sven > > Please reconsider "+" operator for arrays if your changes really forbid to > > overload operators for arrays now. > >   > I

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-02 Thread Mark Morgan Lloyd
On 02/06/18 08:00, Ryan Joseph wrote: On Jun 2, 2018, at 2:42 PM, Sven Barth via fpc-pascal wrote:> > It wasn't me who implemented that part. I personally had planned to do it with a warning for existing overloads, but Florian beat me to it and implemented it this way. Though when asked by me

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-02 Thread denisgolovan
Yes, I strongly support removing that functionality in favor of user operator overloads or vector-compatible way. Moreover, SSE/AVX vector extensions also should work per-element. I mean those vectors as in https://bugs.freepascal.org/view.php?id=27870 BR, Denis _

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-02 Thread denisgolovan
It's technically possible. But for vector operations to be valid/consistent both of them should work the same way. That is perform arithmetic per-element addition. BTW, you first overload is not implemented properly. You need to clone "left" first and return it as a result. BR, Denis ___

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-02 Thread Ryan Joseph
> On Jun 2, 2018, at 2:42 PM, Sven Barth via fpc-pascal > wrote: > > It wasn't me who implemented that part. I personally had planned to do it > with a warning for existing overloads, but Florian beat me to it and > implemented it this way. Though when asked by me he did say that we'll wait

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-02 Thread Sven Barth via fpc-pascal
denisgolovan schrieb am Sa., 2. Juni 2018, 09:18: > @Sven > Please reconsider "+" operator for arrays if your changes really forbid to > overload operators for arrays now. > It wasn't me who implemented that part. I personally had planned to do it with a warning for existing overloads, but Flori

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-02 Thread Ryan Joseph
> On Jun 2, 2018, at 2:17 PM, denisgolovan wrote: > > Same here. > > The semantics for vector operations on arrays was thoroughly explored in > vector languages (APL, A+, J, K, etc). > Doing per-element dyadic function application is the basis for it. Having > proper operators overloads is c

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-02 Thread denisgolovan
> By all means, please reconsider this, and leave me the choice to define the > operators. If I want "+" for concatting, it is trivial to define it myself. > I don't need the language to force that and eseentially destroy operator > overloading for mathematical operations on dynamic arrays. Same h

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-01 Thread Ryan Joseph
> On Jun 2, 2018, at 1:35 PM, Nitorami wrote: > > I strongly disagree with the opionon that "+" is natural to be the append > operation. Not even in the context of a list? I’m still not sure what exactly the operations you are doing but it sounds like you have a vector of numbers and you wan

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-01 Thread Nitorami
>Why are you using dynamic arrays for vectors/matricies? If what you have is an actual array you wish to grow then + would likely be an append operation. Dynamic arrays are incredibly convenient for purposes like signal processng, whe you need to handle large blocks of numeric data in variable si

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-01 Thread Ryan Joseph
> On Jun 2, 2018, at 5:19 AM, Nitorami wrote: > > Are you serious ? I have been using dynamic arrays a lot for processing of > vectors and matrices containing floating point values, and implemented the + > operator to do the obvious, add the elements of two vectors, NOT to concat > them. This i

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-06-01 Thread Nitorami
> ## "+" operator > The compiler now implements a "+" operator for arrays which is the same > as if Concat() would be called on the arrays. > Note regarding backwards compatibility: existing "+" operator overloads > for dynamic arrays no longer compile. Are you serious ? I have been using dynamic

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-25 Thread Sven Barth via fpc-pascal
Am 25.05.2018 um 08:42 schrieb Ryan Joseph: On May 25, 2018, at 1:02 PM, Sven Barth via fpc-pascal wrote: Yes, that is what it does. Though a possible optimization would be that the compiler detects "dynarr := dynarr + [elem]" and converts it to "Insert(elem, dynarr, High(dynarr))”. 100%

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-25 Thread Sven Barth via fpc-pascal
Ryan Joseph schrieb am Fr., 25. Mai 2018, 12:45: > > > > On May 25, 2018, at 3:57 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > If I had to guess you were probably doing something with the arrays they > weren't designed for. :/ > > > > It’s a little foggy now b

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-25 Thread Ryan Joseph
> On May 25, 2018, at 3:57 PM, Sven Barth via fpc-pascal > wrote: > > If I had to guess you were probably doing something with the arrays they > weren't designed for. :/ > It’s a little foggy now but I think I had a dynamic array in a class which was being passed around some functions or t

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-25 Thread Sven Barth via fpc-pascal
Ryan Joseph schrieb am Fr., 25. Mai 2018, 10:24: > > > > On May 25, 2018, at 3:18 PM, Michael Van Canneyt > wrote: > > > > I'm guessing you are not using strings either then, for performance > reasons ? Because exactly the same happens there. > > really? I had a collection class with a dynamic a

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-25 Thread Sven Barth via fpc-pascal
Michael Van Canneyt schrieb am Fr., 25. Mai 2018, 10:15: > > > On Fri, 25 May 2018, Sven Barth via fpc-pascal wrote: > > > Yes, that is what it does. Though a possible optimization would be that > the > > compiler detects "dynarr := dynarr + [elem]" and converts it to > > "Insert(elem, dynarr, Hi

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-25 Thread Ryan Joseph
> On May 25, 2018, at 3:18 PM, Michael Van Canneyt > wrote: > > I'm guessing you are not using strings either then, for performance reasons ? > Because exactly the same happens there. really? I had a collection class with a dynamic array for the storage and that’s when I got the high CPU us

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-25 Thread Bart
On Fri, May 25, 2018 at 8:42 AM, Ryan Joseph wrote: > Oh Insert on the last element works like Push. There really should be a > Push/append etc.. function in there. I know it’s redundant but doing > > Insert(arr, High(arr), value) is more work than Push(arr, value) and it’s not > clear if we can

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-25 Thread Michael Van Canneyt
On Fri, 25 May 2018, Ryan Joseph wrote: On May 25, 2018, at 1:06 PM, Michael Van Canneyt wrote: Dynamic arrays are reference counted. The interlocked increment is there to make the operations thread safe. I do not know whether the classes you speak of are thread safe. If there is no FPC_I

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-25 Thread Michael Van Canneyt
On Fri, 25 May 2018, Sven Barth via fpc-pascal wrote: Yes, that is what it does. Though a possible optimization would be that the compiler detects "dynarr := dynarr + [elem]" and converts it to "Insert(elem, dynarr, High(dynarr))". Since dynamic array helpers work could you expose a functio

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-25 Thread Ryan Joseph
> On May 25, 2018, at 1:02 PM, Sven Barth via fpc-pascal > wrote: > > Yes, that is what it does. Though a possible optimization would be that the > compiler detects "dynarr := dynarr + [elem]" and converts it to "Insert(elem, > dynarr, High(dynarr))”. 100% > > > Since dynamic array help

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-25 Thread Ryan Joseph
> On May 25, 2018, at 1:06 PM, Michael Van Canneyt > wrote: > > Dynamic arrays are reference counted. The interlocked increment is there to > make the operations thread safe. I do not know whether the classes you speak > of are thread safe. If there is no FPC_INTERLOCKEDINCREMENT64, most likel

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-24 Thread Sven Barth via fpc-pascal
Ryan Joseph schrieb am Fr., 25. Mai 2018, 07:55: > The procedural syntax of Insert(arr, 0, value) is less enticing than > arr.Insert(0, value) also but again we can fix that with type helpers. > You are overestimating what type helpers are capable of doing for dynamic arrays - see my remark abou

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-24 Thread Michael Van Canneyt
On Fri, 25 May 2018, Ryan Joseph wrote: On May 25, 2018, at 12:43 PM, Michael Van Canneyt wrote: I think the above is "right", and completely equivalent to sets, which are in some ways like an array: a "collection" of same typed values. To add an element to a set you also do MySet:=My

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-24 Thread Sven Barth via fpc-pascal
Ryan Joseph schrieb am Fr., 25. Mai 2018, 04:35: > > > > On May 25, 2018, at 1:37 AM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > This is currently not supported. And to avoid backwards compatibility > problems with existing operator overloads you'd probably need

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-24 Thread Ryan Joseph
> On May 25, 2018, at 12:43 PM, Michael Van Canneyt > wrote: > > I think the above is "right", and completely equivalent to sets, which are in > some ways > like an array: a "collection" of same typed values. > > To add an element to a set you also do > MySet:=MySet+[aValue]; > > That said

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-24 Thread Michael Van Canneyt
On Fri, 25 May 2018, Ryan Joseph wrote: On May 25, 2018, at 1:37 AM, Sven Barth via fpc-pascal wrote: This is currently not supported. And to avoid backwards compatibility problems with existing operator overloads you'd probably need to convert it to a dynamic array first: === code be

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-24 Thread Ryan Joseph
> On May 25, 2018, at 1:37 AM, Sven Barth via fpc-pascal > wrote: > > This is currently not supported. And to avoid backwards compatibility > problems with existing operator overloads you'd probably need to convert it > to a dynamic array first: > > === code begin === > > a += ['foo']; >

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-24 Thread Anthony Walter
I just wanted to drop this trick to work around problems with record helpers .. If you wanted to create a record helper for a type that is not normally allowed, or perhaps you want to have multiple record helpers for the same type, consider defining your own separate type and make it contain said

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-24 Thread Sven Barth via fpc-pascal
Am 24.05.2018 um 17:27 schrieb Ryan Joseph: On May 20, 2018, at 7:23 PM, Sven Barth via fpc-pascal wrote: The compiler now implements a "+" operator for arrays which is the same as if Concat() would be called on the arrays. I haven’t built it yet but I’m curious, does += now push an eleme

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-24 Thread Ryan Joseph
> On May 20, 2018, at 7:23 PM, Sven Barth via fpc-pascal > wrote: > > The compiler now implements a "+" operator for arrays which is the same as if > Concat() would be called on the arrays. > I haven’t built it yet but I’m curious, does += now push an element to the array or does this just

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-21 Thread Maciej Izak
2018-05-21 10:12 GMT+02:00 Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org>: > > That is at least what I would *expect* for Delphi as well. And no, I'm > definitely not underestimating their ability to come up with strange > syntaxes... Do I do prefer not to think about it too much to a

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-21 Thread Maciej Izak
2018-05-21 10:49 GMT+02:00 Jonas Maebe : > Breaking backwards compatibility is one of the the worst things you can do > in a programming language/compiler, and the primary concern when making > changes to a language should always be to avoid this (except when you're > developing a new language tha

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-21 Thread Jonas Maebe
On 21/05/18 01:36, Maciej Izak wrote: IMO potentially breaking compatibility is better than lock/prohibition for missing features in Delphi (or waiting for Delphi implementation). Breaking backwards compatibility is one of the the worst things you can do in a programming language/compiler, and

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-21 Thread Mark Morgan Lloyd
On 20/05/18 12:30, Sven Barth via fpc-pascal wrote: ## "+" operator The compiler now implements a "+" operator for arrays which is the same as if Concat() would be called on the arrays. Note regarding backwards compatibility: existing "+" operator overloads for dynamic arrays no longer compile

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-21 Thread Sven Barth via fpc-pascal
Am 21.05.2018 um 01:36 schrieb Maciej Izak: 2018-05-21 0:52 GMT+02:00 Sven Barth via fpc-pascal >: The thing is that I can easily imagine the Delphi devs to be so stoned to use the "[...]" for static arrays inside dynamic arrays as well which

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Maciej Izak
2018-05-21 0:52 GMT+02:00 Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org>: > The thing is that I can easily imagine the Delphi devs to be so stoned to > use the "[...]" for static arrays inside dynamic arrays as well which could > lead to constructs like the following because they for

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Sven Barth via fpc-pascal
Maciej Izak schrieb am So., 20. Mai 2018, 23:32: > 2018-05-20 22:50 GMT+02:00 Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org>: > >> I prohibited it because Delphi does not support it correctly and I don't >> know whether they'd use the usual "(...)"-syntax for the static arrays or

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Maciej Izak
2018-05-20 22:50 GMT+02:00 Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org>: > I prohibited it because Delphi does not support it correctly and I don't > know whether they'd use the usual "(...)"-syntax for the static arrays or > switch to the dynamic array one. To avoid potential back

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Sven Barth via fpc-pascal
Maciej Izak schrieb am So., 20. Mai 2018, 21:49: > Why you decide to prohibit static array constants inside dynamic array > constants for Delphi modes in r39045? I do not understand this decision. It > is some punishment for using Delphi mode? -,- IMO bad decision. > I prohibited it because Delp

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Maciej Izak
2018-05-20 20:44 GMT+02:00 Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org>: > Anthony Walter schrieb am So., 20. Mai 2018, 19:09: > >> By the way, what's the reason for differences in () / [] syntax between >> objpas and delphi mode? >> > > For the non-Delphi modes I decided to keep

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Jesus Reyes A.
En Sun, 20 May 2018 07:23:25 -0500, Sven Barth via fpc-pascal escribió: Hello together! I'm pleased to announce that after nearly a year various extensions for dynamic arrays have been finished. This includes the following features: - support for array constructors using "[...]" syntax -

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Sven Barth via fpc-pascal
Mattias Gaertner schrieb am So., 20. Mai 2018, 17:58: > >[...] > > === code end === > > > > For constants the dynamic array constants adhere to the writable > > constants switch $J. E.g. the following will result in an exception: > > > > === code begin === > > > > {$J-} > > const > >Test1: ar

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Sven Barth via fpc-pascal
Anthony Walter schrieb am So., 20. Mai 2018, 19:09: > By the way, what's the reason for differences in () / [] syntax between > objpas and delphi mode? > For the non-Delphi modes I decided to keep consistency with static array constants (which use the same syntax in Delphi btw!). For the Delphi

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Anthony Walter
Never mind, I found the problem. program hello; {$mode delphi} procedure Test; var Data: array of Integer = [0, 15, 24]; I: Integer; begin WriteLn('Testing new array features'); for I in Data do WriteLn(I); // fixed end; begin Test; end. Outputs: Testing new array features 0 15

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Anthony Walter
I just got fpc from svn trunk (http://svn.freepascal.org/svn/fpc/trunk/) and tested. Before I submit to Mantis, can you tell me if I made a mistake here? program hello; {$mode delphi} procedure Test; var Data: array of Integer = [0, 15, 24]; I: Integer; begin WriteLn('Testing new array fea

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Anthony Walter
Holy crap Sven. This is so awesome! I was going to write a request last week to allow for a simplified array constant declaration, and you've already got it done. Thanks for your work. I'll test it momentarily and report any actual problems to Mantis. By the way, what's the reason for differences

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Michael Van Canneyt
On Sun, 20 May 2018, Mattias Gaertner wrote: On Sun, 20 May 2018 14:23:25 +0200 Sven Barth via fpc-pascal wrote: Hello together! I'm pleased to announce that after nearly a year various extensions for dynamic arrays have been finished. This includes the following features: - support for

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Mattias Gaertner
On Sun, 20 May 2018 14:23:25 +0200 Sven Barth via fpc-pascal wrote: > Hello together! > > I'm pleased to announce that after nearly a year various extensions for > dynamic arrays have been finished. This includes the following features: > > - support for array constructors using "[...]" syntax

Re: [fpc-pascal] Feature announcement: Dynamic array extensions

2018-05-20 Thread Michael Van Canneyt
On Sun, 20 May 2018, Sven Barth via fpc-pascal wrote: Hello together! I'm pleased to announce that after nearly a year various extensions for dynamic arrays have been finished. This includes the following features: - support for array constructors using "[...]" syntax - support for Insert(