Re: [fpc-pascal] Managed properties idea

2017-10-04 Thread Sven Barth via fpc-pascal
Am 05.10.2017 05:04 schrieb "Ryan Joseph" : > I’ve been wanting to learn how to contribute to the compiler for years now but maybe this is an easy enough project to start with. I don’t know if this is a problem people have though but I assume it may be since

[fpc-pascal] Managed properties idea

2017-10-04 Thread Ryan Joseph
Yesterday when I was thinking about that enumerators I had an idea for a language feature and something which I saw introduced in Objective-C some years ago. Retaining of a member variable through a property is a common pattern I do everyday nearly. In my root class I manage a simply retain

[fpc-pascal] Finding long file names

2017-10-04 Thread James Richters
I'm trying to use findfirst()/findnext to obtain a list of files. Here's my code: Searchfile:=Tap_Drive+Tap_Path+'\'+Tap_SubDirectory+'\*.TAP'; If FindFirst(Searchfile, FAAnyfile-FAHidden, FileDirInfo)=0 then .. It finds most files, even ones with really long file names, however it can't find

Re: [fpc-pascal] For ..in GetEnumerator Allocation

2017-10-04 Thread Ryan Joseph
> On Oct 4, 2017, at 10:03 PM, Michael Van Canneyt > wrote: > > Newinstance allocates the memory for a new instance of the class. > By default this is GetMem(instanceSize). So you override the class method Newinstance in the enumerator class and return the same block

Re: [fpc-pascal] For ..in GetEnumerator Allocation

2017-10-04 Thread Ryan Joseph
> On Oct 4, 2017, at 5:19 PM, Marco van de Voort wrote: > > Yup, or a record. See e.g. http://www.stack.nl/~marcov/lightcontainers.zip This seems like the simplest more efficient method. Does FPC just know it’s a record internally and not try to dealloc it? GetEnumerator

Re: [fpc-pascal] For ..in GetEnumerator Allocation

2017-10-04 Thread Mattias Gaertner
On Wed, 4 Oct 2017 15:41:27 +0700 Ryan Joseph wrote: > As I understand the for..in loop GetEnumerator method is expected to create a > new object each time it’s called and FPC destroys it later when the loos is > finished. Can I retain the enumerator and just reset

Re: [fpc-pascal] Yet another thread on Unicode Strings

2017-10-04 Thread Marco van de Voort
In our previous episode, Tony Whyman said: > Unicode Character String handling is a question that keeps coming up on > the Free Pascal Mailing lists and, empirically, it is hard to avoid the > conclusion that there is something wrong with the way these character > string types are handled.

Re: [fpc-pascal] For ..in GetEnumerator Allocation

2017-10-04 Thread Michael Van Canneyt
On Wed, 4 Oct 2017, Ryan Joseph wrote: On Oct 4, 2017, at 4:26 PM, Michael Van Canneyt wrote: You can do so by overriding the newinstance and it's sister method of your enumerator class. Can you explain how this works or give an example? Not sure how these gets

Re: [fpc-pascal] For ..in GetEnumerator Allocation

2017-10-04 Thread Ryan Joseph
> On Oct 4, 2017, at 4:26 PM, Michael Van Canneyt > wrote: > > You can do so by overriding the newinstance and it's sister method of > your enumerator class. Can you explain how this works or give an example? Not sure how these gets around the problem of alloc/dealloc

Re: [fpc-pascal] Yet another thread on Unicode Strings

2017-10-04 Thread Mattias Gaertner
On Wed, 4 Oct 2017 13:10:02 +0100 Tony Whyman wrote: > Unicode Character String handling is a question that keeps coming up on > the Free Pascal Mailing lists and, empirically, it is hard to avoid the > conclusion that there is something wrong with the way these

[fpc-pascal] Yet another thread on Unicode Strings

2017-10-04 Thread Tony Whyman
Unicode Character String handling is a question that keeps coming up on the Free Pascal Mailing lists and, empirically, it is hard to avoid the conclusion that there is something wrong with the way these character string types are handled. Otherwise, why does this issue keep arising?

Re: [fpc-pascal] For ..in GetEnumerator Allocation

2017-10-04 Thread Graeme Geldenhuys
On 2017-10-04 09:41, Ryan Joseph wrote: I’d like to remove all these alloc/deallocs so I can use for..in more efficiently in tight loops. I've had the same requirement, and also needed that functionality before the for..in syntax existed in FPC. Take a look at my Iterator interface and

Re: [fpc-pascal] For ..in GetEnumerator Allocation

2017-10-04 Thread Marco van de Voort
In our previous episode, Michael Van Canneyt said: > As an alternative you can create an object enumeator. > It's simply allocated on the stack, and you can reset it in the enumerator > operator. Yup, or a record. See e.g. http://www.stack.nl/~marcov/lightcontainers.zip

Re: [fpc-pascal] For ..in GetEnumerator Allocation

2017-10-04 Thread Michael Van Canneyt
On Wed, 4 Oct 2017, Ryan Joseph wrote: As I understand the for..in loop GetEnumerator method is expected to create a new object each time it’s called and FPC destroys it later when the loos is finished. Can I retain the enumerator and just reset it in-between calls? I’d like to remove all

[fpc-pascal] For ..in GetEnumerator Allocation

2017-10-04 Thread Ryan Joseph
As I understand the for..in loop GetEnumerator method is expected to create a new object each time it’s called and FPC destroys it later when the loos is finished. Can I retain the enumerator and just reset it in-between calls? I’d like to remove all these alloc/deallocs so I can use for..in