"Set of" not supported?

Hi,

When I try to use “set of bla” it prints: “Language element not supported on this target platform”?
What would be a workaround for this so far ?

–Shpend

what’s your exact goal? you could use enum flags, for example…

Ok, Do they work totally the same?

I actually wanted them to store a set of some graphic_data which I need for drawing stuff and based on whats in the set it should draw differently and create a new set of what has been drawned so far…

Depends. can you give me a code example of what you’d like to do with sets? (also, which platform is it that it fails?)

I wanted to store some pixel-combinations for a lvl-editior i write and the combinations should switch for each former combination to create new kind of pixely lvls.

something like:

var pixel := set of Pixel := GetAllPixel(...)

var oneCombi := CreatePixelCombi(...)

var rndPixelCombi := pixel - [oneCombi] //Delphi syntax

this in a loop, its something I wanted to try out for random pixel worlds…

ah and the platform, as I tagged, is Island :slight_smile:

set of enum should be fine. It’s when you exceed 64 bits, it should give this error.

Ok, “set of Enum” works but why actually doesnt work this, this worked also well in Delphi/Pascal:

set of Byte ; set of char; set of 200..300;        //and so on

They doesnt exceed the 64 bit range

They do? a set of Char would be 65536 bits, and 200 … 300 is 300 bits.

Hmm, maybe i am little confused here, but when I do “set of enum” and enum is an int64, it actually would be set of int64? because one enum type is representative for it, isnt it?

AFAIK, Delphi says too that the set can only contain 255 elements or such, and how does this work then in Delphi? Like here: http://www.delphibasics.co.uk/RTL.asp?Name=set

Delphi’s char type is 8 bits, ie 0…255, that’s 256 items and set’s limit in delphi is 256.

If you have an enum with low value 0, high value 20, then a set of that enum takes 21 bits. For every possible value in the input type, a set takes 1 bit. Our sets are limited to 64bits in Island.

Ok, So when I understand you correctly, (didnt used sets that much) on Island, you probably just support 64 items in a set, because of 64 bit?

When this is true, then actually this should work also then or not:

  set of 0..30; //30bit set?

Could you support a larger bit-amount of sets?

That should work yes.

What do you need larger sets for? There’s a lot of work involved in larger sets and I’m not planning on supporting it unless there’s a worthwhile usecase for it.

Hmm, nope, when I do “set of 0…30” it throws “type missmatch: cannot assign 0…30 to enum” and language element not supported on this platform:

Ok, for my purpose the set of enum is enough to be honest, but ok, just generally i wanted to know!

My last question is: you said that Delphi’s char is 8 bit, but I read that Delphi can take 255 items, so that would be actually 255*sizeof(ordinaltype) This is in ex. 255 * 8 = roundabout 2200 bits, isnt it?

Delphi sets can take 256 items, not 255. It would be 256 bits to store it, which is 32 bytes.

Ah ok, yes got it^^

But could you have a look into the error I described above? I cant make : set of 0…30 because it throws an error, and you said that actually should work?

Thanks, logged as bugs://79606

bugs://79606 got closed with status fixed.

I wanted to add something here, when possible:

  1. When I use: setVariable.ToString that I get something like this:
    [item1, item2, item4…item100] because thats actually what you want when using a set, I dont care much about internal representation, but just what is really in there, because currently I get the internal-bit-value

  2. Also, it would be nice, to have the possibility to iterate over a set, like for all kind of sequences
    (Because, it actually behave pretty much like a sequence, you can “add” “remove” and “find items” even if it is totally differently represented internally)

  3. To have a “Count” property, to detect how much elements are in the set, without the need to iterate over it, but 2) is still needed, because I dont just iterate over a set for its count

Count has very limited uses; if you need that feature you can easily write it yourself.

The other two things would indeed be nice but aren’t on the schedule currently. I’ll log them for future reference.