Re: [fpc-pascal] Set size limit

2019-08-07 Thread larry03052
Try this: unit genericset (t); interface type genset=pointer; (*! The functions getnext, getlast and getfirst must never be called on an empty set. The function getnext should never be called on the last element of a set. *) procedure genericsetnext(var v:t;s:genset); procedure genericsetfirst(

Re: [fpc-pascal] Set size limit

2013-03-12 Thread Flávio Etrusco
On Mon, Mar 11, 2013 at 10:54 AM, Daniel Gaspary wrote: > On Mon, Mar 11, 2013 at 10:43 AM, Jonas Maebe > wrote: >> A set is basically a bitpacked array of boolean. Element X is set to true if >> you add X to the set, and to false if you remove it again. That means that >> if you have a set with

Re: [fpc-pascal] Set size limit

2013-03-12 Thread Mark Morgan Lloyd
Ewald wrote: Once upon a time, Mark Morgan Lloyd said: No, because the elements in a set are dictated by their position. A set that can contain anything between 0 and 256 elements occupies 8 bytes in memory with the (bit representing the) 0 element at one end and the (bit representing the) 256 e

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Ewald
Once upon a time, Mark Morgan Lloyd said: > No, because the elements in a set are dictated by their position. A > set that can contain anything between 0 and 256 elements occupies 8 > bytes in memory with the (bit representing the) 0 element at one end > and the (bit representing the) 256 element a

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Gerhard Scholz
nday, March 11, 2013 7:42 PM Subject: Re: [fpc-pascal] Set size limit Here is a unit that could be useful. Works with pentium and Win32; not tested with other CPUs or operating system. I hope you have 7zip, or I will create a zip file. Greetings Gerhard - Original Message - F

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Gerhard Scholz
uot; Sent: Saturday, March 09, 2013 9:52 PM Subject: [fpc-pascal] Set size limit Hi, I am trying to create a Set Type... TMyEnum = (me1, me2, me3); // more than 500 elements TMySet = set of TMyEnum; ...but I get the following error: "Error: illegal type declaration of set element

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Paul Ishenin
11.03.13, 22:10, Sven Barth wrote: Generics do work for array, but maybe not for indices. Only for type of element as I remember. Also you'd need to declare the operators anyway. Best solution in this case might be to encapsulate the array in a record and define the operators there... Maybe

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Sven Barth
Am 11.03.2013 14:59, schrieb Jonas Maebe: On 11 Mar 2013, at 14:52, Sven Barth wrote: If the array is a named one (e.g. "TMyArraySet = bitpacked array[TMyEnum] of Boolean") then operator overloading could be used... Yes, but since neither open nor dynamic bitpacked arrays are supported, you

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Mark Morgan Lloyd
Daniel Gaspary wrote: On Mon, Mar 11, 2013 at 7:09 AM, Mark Morgan Lloyd wrote: That was pretty much my gist. Since these days Unicode is larger than 65536 codepoints I don't think there's any advantage to expanding sets from 256 to 65536 elements, efficient operations on sparse arrays of 256-e

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Jonas Maebe
On 11 Mar 2013, at 14:52, Sven Barth wrote: If the array is a named one (e.g. "TMyArraySet = bitpacked array[TMyEnum] of Boolean") then operator overloading could be used... Yes, but since neither open nor dynamic bitpacked arrays are supported, you'd have to reimplement this for every sin

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Daniel Gaspary
On Mon, Mar 11, 2013 at 10:43 AM, Jonas Maebe wrote: > A set is basically a bitpacked array of boolean. Element X is set to true if > you add X to the set, and to false if you remove it again. That means that > if you have a set with 600 possible values, you need at least 600 bits, > regardless of

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Sven Barth
Am 11.03.2013 14:43, schrieb Jonas Maebe: On 11 Mar 2013, at 14:32, Daniel Gaspary wrote: In my case the enum has near 600 elements. TMyEnum = (me1, me2...); The set though would never be used to contain more than 256. TMySet = set of TMyEnum; Is it not viable to modify the compiler to com

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Jonas Maebe
On 11 Mar 2013, at 14:32, Daniel Gaspary wrote: In my case the enum has near 600 elements. TMyEnum = (me1, me2...); The set though would never be used to contain more than 256. TMySet = set of TMyEnum; Is it not viable to modify the compiler to compile the code and raise an exception if I t

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Daniel Gaspary
On Mon, Mar 11, 2013 at 7:09 AM, Mark Morgan Lloyd wrote: > That was pretty much my gist. Since these days Unicode is larger than 65536 > codepoints I don't think there's any advantage to expanding sets from 256 to > 65536 elements, efficient operations on sparse arrays of 256-element sets > would

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Mark Morgan Lloyd
Jonas Maebe wrote: Provided that one calls a Z80 16-bit :-) More to the point: do any current CPUs have e.g. vector operations that suggest a realistic maximum size? The current x86's bit test/set instructions support addressing the complete 32/64 bit address space. But the original 8086 did

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Jonas Maebe
On 11 Mar 2013, at 10:39, Mark Morgan Lloyd wrote: Jonas Maebe wrote: On 10 Mar 2013, at 15:00, Juha Manninen wrote: There are no 8-bit CPUs supported by FPC that would justify it. It is unrelated to 8 bit cpus. Even Turbo Pascal 1.0 ran on a 16 bit cpu. Provided that one calls a Z80 16-b

Re: [fpc-pascal] Set size limit

2013-03-11 Thread Mark Morgan Lloyd
Jonas Maebe wrote: On 10 Mar 2013, at 15:00, Juha Manninen wrote: There are no 8-bit CPUs supported by FPC that would justify it. It is unrelated to 8 bit cpus. Even Turbo Pascal 1.0 ran on a 16 bit cpu. Provided that one calls a Z80 16-bit :-) More to the point: do any current CPUs have e

Re: [fpc-pascal] Set size limit

2013-03-10 Thread Mark Morgan Lloyd
Juha Manninen wrote: No. As far as I understand, sets are stored in 1 byte internally - as binary values. 256 is the max number of elements (bit values) it can hold in a byte. This is one area where FPC could actually improve things. The 1 byte limit is purely historical. There are no 8-bit C

Re: [fpc-pascal] Set size limit

2013-03-10 Thread Rolf Grunsky
On 13-03-09 03:56 PM, Jonas Maebe wrote: On 09 Mar 2013, at 21:52, Daniel Gaspary wrote: The problem seems to be that TMyEnum has more than 256 elements. Can I specify such Set with some compiler option ? No. My fpc is pre 2.6, any change on new versions concerning Sets limits? No. Jo

Re: [fpc-pascal] Set size limit

2013-03-10 Thread Howard Page-Clark
On 10/03/13 2:12, Jonas Maebe wrote: There is a already a test for larger set support: http://svn.freepascal.org/svn/fpc/trunk/tests/test/tset6.pp Nobody has worked yet on implementing it, but if anyone thinks it's easy to do, please go ahead. For larger sets, especially if they are sparse,

Re: [fpc-pascal] Set size limit

2013-03-10 Thread Juha Manninen
On Sun, Mar 10, 2013 at 4:19 PM, Florian Klämpfl wrote: >> This issue is similar. This kind of artificial limitation > I always wonder how people know more than me about the compiler :) > >> could easily be fixed. > Go ahead. :) Ok, I sent my reply too quickly. I must study the compiler at some d

Re: [fpc-pascal] Set size limit

2013-03-10 Thread Daniel Gaspary
On Sun, Mar 10, 2013 at 11:12 AM, Jonas Maebe wrote: > For larger sets, especially if they are sparse, a simple hashtable-based class > would probably be much faster and memory efficient Just some background.. I was using a Set because I needed a initialized constant "container" with a variable

Re: [fpc-pascal] Set size limit

2013-03-10 Thread Florian Klämpfl
Am 10.03.2013 15:00, schrieb Juha Manninen: > This issue is similar. This kind of artificial limitation I always wonder how people know more than me about the compiler :) > could easily be fixed. Go ahead. ___ fpc-pascal maillist - fpc-pascal@lists

Re: [fpc-pascal] Set size limit

2013-03-10 Thread Juha Manninen
On Sun, Mar 10, 2013 at 3:45 PM, Marco van de Voort wrote: > Sets are up to 32-byte (256bits), enums can be up to 32-bit. Ok, sorry. The limitation for sets is not one byte. Still, FPC could add support for still more bytes. 64-bit CPUs are now popular and the feature could easily be implemented

Re: [fpc-pascal] Set size limit

2013-03-10 Thread Jonas Maebe
On 10 Mar 2013, at 15:00, Juha Manninen wrote: > There are no 8-bit CPUs > supported by FPC that would justify it. It is unrelated to 8 bit cpus. Even Turbo Pascal 1.0 ran on a 16 bit cpu. > I am annoyed by some LCL bugs which are there only for Delphi compatibility. > This issue is similar. I

Re: [fpc-pascal] Set size limit

2013-03-10 Thread Juha Manninen
On Sun, Mar 10, 2013 at 2:38 PM, Graeme Geldenhuys wrote: > No. As far as I understand, sets are stored in 1 byte internally - as > binary values. 256 is the max number of elements (bit values) it can > hold in a byte. This is one area where FPC could actually improve things. The 1 byte limit is

Re: [fpc-pascal] Set size limit

2013-03-10 Thread Marco van de Voort
In our previous episode, Graeme Geldenhuys said: > On 2013-03-09 20:52, Daniel Gaspary wrote: > > > > The problem seems to be that TMyEnum has more than 256 elements. > > Can I specify such Set with some compiler option ? > > No. As far as I understand, sets are stored in 1 byte internally - as

Re: [fpc-pascal] Set size limit

2013-03-10 Thread Graeme Geldenhuys
On 2013-03-09 20:52, Daniel Gaspary wrote: > > The problem seems to be that TMyEnum has more than 256 elements. > Can I specify such Set with some compiler option ? No. As far as I understand, sets are stored in 1 byte internally - as binary values. 256 is the max number of elements (bit values)

Re: [fpc-pascal] Set size limit

2013-03-09 Thread Jonas Maebe
On 09 Mar 2013, at 21:52, Daniel Gaspary wrote: > The problem seems to be that TMyEnum has more than 256 elements. > > Can I specify such Set with some compiler option ? No. > My fpc is pre 2.6, any change on new versions concerning Sets limits? No. Jonas

[fpc-pascal] Set size limit

2013-03-09 Thread Daniel Gaspary
Hi, I am trying to create a Set Type... TMyEnum = (me1, me2, me3); // more than 500 elements TMySet = set of TMyEnum; ...but I get the following error: "Error: illegal type declaration of set elements" [1] The problem seems to be that TMyEnum has more than 256 elements. Can I specif