Re: [fpc-pascal] Set size limit
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(var v:t;s:genset); procedure genericsetlast(var v:t;s:genset); function genericsetislast(v:t;s:genset):boolean; function isemptygenericset(s:genset):boolean; function genericsetnotempty(s:genset):boolean; procedure addtogenericset(var s:genset;v:t); function genericsetsingleton(singleton:t):genset; function genericsetunion(s1,s2:genset):genset; function genericsetdifference(s1,s2:genset):genset; function genericsetintersection(s1,s2:genset):genset; function genericsetsymetricdifference(s1,s2:genset):genset; function genericseteq(s1,s2:genset):boolean; function genericsetneq(s1,s2:genset):boolean; function isin(s:genset;v:t):boolean; procedure genericsetisin(s:genset;v:t;var b:boolean); procedure emptygenericset(var newset:genset);{ set newset to be empty } function genericsetle(s1,s2:genset):boolean;{ s1<=s2} function genericsetge(s1,s2:genset):boolean; implementation type pset=^setrec; setrec = record value:t; left, right:pset; bal:integer; end; cheat = record case boolean of true:(yes:pset;); false:(no:pointer); end; procedure phex(p:pointer); var r:record case boolean of true:(i:integer); false:(p:pointer); end; begin r.p:=p; write(r.i); end; function pointer2pset(p:pointer):pset; begin pointer2pset:=p; end; function newnode(var key:t; l,r:pset):pset; var temp:pset; begin new(temp); with temp^ do begin value:=key; left:=l; right:=r; end; newnode:=temp; end; procedure genericsetisin(s:genset;v:t;var b:boolean); begin b:=isin(s,v);end; function genericsetlt(s1,s2:genset):boolean; begin genericsetlt:= not isemptygenericset(genericsetdifference(s2,s1)) end; function genericsetgt(s1,s2:genset):boolean; begin genericsetgt:=genericsetlt(s2,s1); end; function genericsetle(s1,s2:genset):boolean; begin genericsetle:= not genericsetgt(s1,s2); end; function genericsetge(s1,s2:genset):boolean; begin genericsetge:=genericsetle(s2,s1) end; function genericsetneq(s1,s2:genset):boolean; begin genericsetneq:= not genericseteq(s1,s2); end; function genericseteq(s1,s2:genset):boolean; begin genericseteq:=isemptygenericset(genericsetsymetricdifference(s1,s2)) end; function genericsetsymetricdifference(s1,s2:genset):genset; begin genericsetsymetricdifference:=genericsetdifference(genericsetunion(s1,s2),genericsetintersection(s1,s2)); end; function genericsetintersection(s1,s2:genset):genset; var temp:genset; procedure rec(p:pset); begin if p<>nil then with p^ do begin if isin(s2,value) then addtogenericset(temp,value); rec(right);rec(left); end end; begin emptygenericset(temp); rec(pointer2pset(s1 )); genericsetintersection:=temp; end; function genericsetunion(s1,s2:genset):genset; var temp:genset; procedure rec(p:pset); begin if p<>nil then with p^ do begin addtogenericset(temp,value); rec(right);rec(left); end end; begin {emptygenericset(temp); rec(pointer2pset(s1 ));} temp:=s1; rec(pointer2pset(s2 )); genericsetunion:=temp; end; function genericsetnotempty(s:genset):boolean;begin genericsetnotempty:=not isemptygenericset(s) end; function isemptygenericset(s:genset):boolean;begin isemptygenericset:=s=nil end; procedure emptygenericset(var newset:genset); begin newset :=nil; end; function newset(v:t;l,r:pset):pset; var temp:pset; begin new(temp); with temp^ do begin value:=v;left:=l;right:=nil;bal:=0; end; newset:=temp end; function
Re: [fpc-pascal] Set size limit
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 element at the other, a set to contain up to (say) 257 elements would require more space and that's not supported. Probably a typo, but 8 bit * 8 bytes = 64 elements. So I suppose you mean `[...] occupies 32 bytes in memory [...]`? Just so nobody gets confused :-) Definitely a typo, or rather the fingers running ahead of the brain. I was thinking of various compilers I'd come across that ordered things differently and how best to not imply that [0] invariably mapped onto $0001. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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.g. vector operations that suggest a realistic maximum size? I am annoyed by some LCL bugs which are there only for Delphi compatibility. This issue is similar. It is not. This kind of artificial limitation could easily be fixed. I think it should apply for {$mode objfpc} only. 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, a simple hashtable-based class would probably be much faster and memory efficient than simply extending the default implementation though. With operator overloading and generics you might even be able to use more or less the same syntax as with built-in sets. For larger sets... OK, how /does/ one declare a set of UTF-8 characters? -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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-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 didn't have any vector instructions at all. Again: this limitation is unrelated to instruction sets, it's about deciding on a point at which you're going to waste a lot of memory by using a plain bitmap. 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, a simple hashtable-based class would probably be much faster and memory efficient than simply extending the default implementation though. With operator overloading and generics you might even be able to use more or less the same syntax as with built-in sets. For larger sets... OK, how /does/ one declare a set of UTF-8 characters? An UTF-8 character is not an ordinal data type and hence support for set of utf-8 character is orthogonal to support for larger sets. If you store them in strings or arrays, then you need a hashtable of strings or arrays (and/or support for sets of strings or arrays, which would probably be implemented using... a hashtable). Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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 didn't have any vector instructions at all. Again: this limitation is unrelated to instruction sets, it's about deciding on a point at which you're going to waste a lot of memory by using a plain bitmap. For larger sets... OK, how /does/ one declare a set of UTF-8 characters? An UTF-8 character is not an ordinal data type and hence support for set of utf-8 character is orthogonal to support for larger sets. If you store them in strings or arrays, then you need a hashtable of strings or arrays (and/or support for sets of strings or arrays, which would probably be implemented using... a hashtable). 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 be far better. A modest expansion to be able to handle something like a bitboard for Go might be attractive though. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
On Mon, Mar 11, 2013 at 7:09 AM, Mark Morgan Lloyd markmll.fpc-pas...@telemetry.co.uk 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 be far better. 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 try to add more than 256 elements to the set ? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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 try to add more than 256 elements to the set ? 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 how many elements are inside it. The above also shows an alternative to sets in that case: you can use a bitpacked array[TMyEnum] of boolean instead. Of course, then you can't use the regular set operators. Jonas___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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 compile the code and raise an exception if I try to add more than 256 elements to the set ? 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 how many elements are inside it. The above also shows an alternative to sets in that case: you can use a bitpacked array[TMyEnum] of boolean instead. Of course, then you can't use the regular set operators. If the array is a named one (e.g. TMyArraySet = bitpacked array[TMyEnum] of Boolean) then operator overloading could be used... Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
On Mon, Mar 11, 2013 at 10:43 AM, Jonas Maebe jonas.ma...@elis.ugent.be 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 how many elements are inside it. The above also shows an alternative to sets in that case: you can use a bitpacked array[TMyEnum] of boolean instead. Of course, then you can't use the regular set operators. Jonas Your explanation made the implementation problem clear to me. And the alternative is interesting. Thank you. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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 single pseudo-set type you want to use (except maybe if you use generics, if generics for simple types already work). Jonas___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
Daniel Gaspary wrote: On Mon, Mar 11, 2013 at 7:09 AM, Mark Morgan Lloyd markmll.fpc-pas...@telemetry.co.uk 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 be far better. 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 try to add more than 256 elements to the set ? 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 at the other, a set to contain up to (say) 257 elements would require more space and that's not supported. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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'd have to reimplement this for every single pseudo-set type you want to use (except maybe if you use generics, if generics for simple types already work). Generics do work for array, but maybe not for indices. 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... Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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 then it will be easier to implement compiler support using bitpacked arrays instead of creating so complex workarounds? Best regards, Paul Ishenin ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
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 - From: Daniel Gaspary dgasp...@gmail.com To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org 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 elements [1] The problem seems to be that TMyEnum has more than 256 elements. Can I specify such Set with some compiler option ? My fpc is pre 2.6, any change on new versions concerning Sets limits? Thanks. [1] A more specific message would help too. :) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ubigset.7z Description: Binary data ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
Sorry, there are some changes neccessary: drop the reference to unit uAsms delete the line FillOnes ( ... it was there for debugging purposes - Original Message - From: Gerhard Scholz g...@g--s.de To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org Cc: dgasp...@gmail.com Sent: Monday, 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 - From: Daniel Gaspary dgasp...@gmail.com To: FPC-Pascal users discussions fpc-pascal@lists.freepascal.org 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 elements [1] The problem seems to be that TMyEnum has more than 256 elements. Can I specify such Set with some compiler option ? My fpc is pre 2.6, any change on new versions concerning Sets limits? Thanks. [1] A more specific message would help too. :) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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 at the other, a set to contain up to (say) 257 elements would require more space and that's not supported. Probably a typo, but 8 bit * 8 bytes = 64 elements. So I suppose you mean `[...] occupies 32 bytes in memory [...]`? Just so nobody gets confused :-) -- Ewald ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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) it can hold in a byte. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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 binary values. 256 is the max number of elements (bit values) it can hold in a byte. Sets are up to 32-byte (256bits), enums can be up to 32-bit. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
On Sun, Mar 10, 2013 at 2:38 PM, Graeme Geldenhuys gra...@geldenhuys.co.uk 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 CPUs supported by FPC that would justify it. I am annoyed by some LCL bugs which are there only for Delphi compatibility. This issue is similar. This kind of artificial limitation could easily be fixed. I think it should apply for {$mode objfpc} only. Juha ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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. It is not. This kind of artificial limitation could easily be fixed. I think it should apply for {$mode objfpc} only. 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, a simple hashtable-based class would probably be much faster and memory efficient than simply extending the default implementation though. With operator overloading and generics you might even be able to use more or less the same syntax as with built-in sets. Jonas___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
On Sun, Mar 10, 2013 at 3:45 PM, Marco van de Voort mar...@stack.nl 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 for other CPUs, too. Regards, Juha ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
On Sun, Mar 10, 2013 at 11:12 AM, Jonas Maebe jonas.ma...@elis.ugent.be 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 length. It was a array of records, the set would be one of the fields. I believe it's not possible to have dynamic array initialized inside records. TMyRecord = record TheSet: TMySet; end; const MyArray: array[TMyEnum] of TMyRecord = ( (TheSet: [me1, me3]), (TheSet: [me2, me1]) ); Now I have changed the code to a function with a case returning the record. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
On Sun, Mar 10, 2013 at 4:19 PM, Florian Klämpfl flor...@freepascal.org 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 day. I must say that I don't like the situation where I cannot backup my claims with facts. Now I cannot. I sill study the compiler later ... Regards, Juha ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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, a simple hashtable-based class would probably be much faster and memory efficient than simply extending the default implementation though. With operator overloading and generics you might even be able to use more or less the same syntax as with built-in sets. There is a generic hashset implementation in the stl package, which has no 256-element limit on set size. See ...\source\packages\fcl-stl\src\ghashset.pp A .tex documentation file is included along with a hashsetexample.pp Howard ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal As I recall (it's been almost 30 years since I looked at this) UCSD Pascal had a set size of 4096 bits. This was a p-code interpreter. I think the 32 bit set size was a result of the original TurboPascal being written for the Z-80. UCSD Pascal is long gone, TurboPascal staggers on. Rolf -- TRUTH in her dress finds facts too tight. In fiction she moves with ease. Stray Birds by Rabindranath Tagore ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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 CPUs supported by FPC that would justify it. I am annoyed by some LCL bugs which are there only for Delphi compatibility. This issue is similar. This kind of artificial limitation could easily be fixed. Without wanting to cause upset, before you make statements like that I think you could /really/ do with checking how many bits fit in a byte :-) -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[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 elements [1] The problem seems to be that TMyEnum has more than 256 elements. Can I specify such Set with some compiler option ? My fpc is pre 2.6, any change on new versions concerning Sets limits? Thanks. [1] A more specific message would help too. :) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Set size limit
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 maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal