Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2015-10

Sets > 256

11 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Schnell

(Not hitchhiking the other thread...)

Mohsen wrote
Pascal sets can only contain values/enumerations whose ordinal value is <= 255.

As currently new language features are discussed I would vote to drop (or relax to some K ) this limitation. This would not break any existing code.

-Michael

Reply by email

DaWorm
to Michael Schnell
Michael Schnell wrote 12 lines
(Not hitchhiking the other thread...) On 13/10/15 19:59, Mohsen wrote: > > Pascal sets can only contain values/enumerations whose ordinal value is > <= 255. > As currently new language features are discussed I would vote to drop (or relax to some K ) this limitation. This would not break any existing code.

What if someone is storing a set in a file, or a stream? Old version saves it, new version reads it, and all of the sudden the data isn't in the same format.

Jeff.

Reply by email

Maciej Izak
to DaWorm

2015-10-15 14:58 GMT+02:00 DaWorm :

Show quoted text 7 lines
What if someone is storing a set in a file, or a stream? Old version saves it, new version reads it, and all of the sudden the data isn't in the same format. Jeff.
Currently size of sets can be different for different compiler options -
{$Z1}, {$Z2}, {$Z4}
Best regards, Maciej Izak

Reply by email

Frederic Da Vitoria
to DaWorm: What if someone is storing a set in a file, or a stream? Old version saves it, new…

2015-10-15 14:58 GMT+02:00 DaWorm :

Show quoted text 19 lines
On Wed, Oct 14, 2015 at 5:36 AM, Michael Schnell wrote: > (Not hitchhiking the other thread...) > > On 13/10/15 19:59, Mohsen wrote: > >> >> Pascal sets can only contain values/enumerations whose ordinal value is >> <= 255. >> > As currently new language features are discussed I would vote to drop (or > relax to some K ) this limitation. This would not break any existing code. > > What if someone is storing a set in a file, or a stream? Old version saves it, new version reads it, and all of the sudden the data isn't in the same format.

Yes, this would be a problem. But wouldn't this be an acceptable price for the improvement? After all, similar things happen with integers, which don't always mean the same thing, reals which changed format at least once in TP/Delphi's history, strings... Sure, we could stick with 256 elements sets, 16 bits integers, 255 characters strings, but we'd lose a lot of possibilities, wouldn't we?

Frederic Da Vitoria (davitof) Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org

Reply by email

Michael Van Canneyt
to Frederic Da Vitoria
Frederic Da Vitoria wrote 24 lines
2015-10-15 14:58 GMT+02:00 DaWorm : > On Wed, Oct 14, 2015 at 5:36 AM, Michael Schnell > wrote: > >> (Not hitchhiking the other thread...) >> >> On 13/10/15 19:59, Mohsen wrote: >> >>> >>> Pascal sets can only contain values/enumerations whose ordinal value is >>> <= 255. >>> >> As currently new language features are discussed I would vote to drop (or >> relax to some K ) this limitation. This would not break any existing code. >> >> > What if someone is storing a set in a file, or a stream? Old version > saves it, new version reads it, and all of the sudden the data isn't in the > same format. > Yes, this would be a problem. But wouldn't this be an acceptable price for the improvement?

No, it is not that simple. Lazarus would stop working completely.

Michael.

Reply by email

Jonas Maebe
to DaWorm: What if someone is storing a set in a file, or a stream? Old version saves it, new…

DaWorm wrote on Thu, 15 Oct 2015:

What if someone is storing a set in a file, or a stream? Old version saves it, new version reads it, and all of the sudden the data isn't in the same format.

Support for larger sets would not change the format of smaller sets. The amount of space a set takes up depends on the element type of the set and the {$packset x} setting. Neither of these would automatically change for existing sets.

That said, sets for 256 elements already take up 32 bytes. Larger sets will usually be quite sparse, which means that just increasing the size will end up wasting a lot of memory. It would probably be better to use a dedicated bitmap class (generic or not) instead that is more clever than just using a bit array (although you could still do that in the class, using a bitpacked array of boolean).

Jonas

Reply by email

Mattias Gaertner
to Michael Van Canneyt: No, it is not that simple. Lazarus would stop working completely. Michael.
Show quoted text 8 lines
[...] >>>> Pascal sets can only contain values/enumerations whose ordinal value is >>>> <= 255. >>>> >>> As currently new language features are discussed I would vote to drop (or >>> relax to some K ) this limitation. This would not break any existing code. No, it is not that simple. Lazarus would stop working completely.

Can you elaborate please?

Mattias

Reply by email

Marco van de Voort
to Michael Van Canneyt: No, it is not that simple. Lazarus would stop working completely. Michael.

In our previous episode, Michael Van Canneyt said:

Show quoted text 7 lines
>> same format. >> > > Yes, this would be a problem. But wouldn't this be an acceptable price for > the improvement? No, it is not that simple. Lazarus would stop working completely.

Sets have a size that is a function of the number of elements. (delphi mode per byte, fpc mode per 32-bit). I don't see how raising the max number of elements would affect Lazarus. F(nr of elements) would still give the same allocation size.

(it does matter that sets are allocated always from element 0 though)

There already is a lot of variation just run the below program for mode delphi and objfpc

{$mode objfpc}
type txxx = set of 50..60;
var x : txxx;
begin
  writeln(sizeof(x));
end.

mode delphi prints "2", objfpc prints "32"

I always considered the 256 extremely annoying since it makes sets and enums not very scalable. Raising the limit would also make bitindexing with larger numbers easier.

Reply by email

Frederic Da Vitoria
to Michael Van Canneyt: No, it is not that simple. Lazarus would stop working completely. Michael.

2015-10-15 16:14 GMT+02:00 Michael Van Canneyt :

Show quoted text 34 lines
On Thu, 15 Oct 2015, Frederic Da Vitoria wrote: 2015-10-15 14:58 GMT+02:00 DaWorm : > > On Wed, Oct 14, 2015 at 5:36 AM, Michael Schnell >> wrote: >> >> (Not hitchhiking the other thread...) >>> >>> On 13/10/15 19:59, Mohsen wrote: >>> >>> >>>> Pascal sets can only contain values/enumerations whose ordinal value is >>>> <= 255. >>>> >>>> As currently new language features are discussed I would vote to drop >>> (or >>> relax to some K ) this limitation. This would not break any existing >>> code. >>> >>> >>> What if someone is storing a set in a file, or a stream? Old version >> saves it, new version reads it, and all of the sudden the data isn't in >> the >> same format. >> >> > Yes, this would be a problem. But wouldn't this be an acceptable price for > the improvement? > No, it is not that simple. Lazarus would stop working completely.

Would you care to explain?

Frederic Da Vitoria (davitof) Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org

Reply by email

Michael Van Canneyt
to Marco van de Voort: In our previous episode, Michael Van Canneyt said: Sets have a size that is a function of…
Marco van de Voort wrote 13 lines
In our previous episode, Michael Van Canneyt said: >>> same format. >>> >> >> Yes, this would be a problem. But wouldn't this be an acceptable price for >> the improvement? > > No, it is not that simple. Lazarus would stop working completely. Sets have a size that is a function of the number of elements. (delphi mode per byte, fpc mode per 32-bit). I don't see how raising the max number of elements would affect Lazarus. F(nr of elements) would still give the same allocation size.

Well. Streaming allows max 32 elements in a set.
Since the current max size (256) is above that raising it, will not matter.

I wrote too quickly, it will not affect lazarus...

Michael.

Reply by email