"Set of" not supported?

Thanks, logged as bugs://79660

Ok, cool that you will consider at least the 2 :slight_smile:

But for the Count - part:

Yes, you are totally right, that I could easily implement this on my own, what I actually had in mind when I wrote about the Count was, that it would fit very nice to the RTL because the set its actually a sequence of and for that, I could say that it totally behaves like that:

  1. It has a Count (number for all elements stored in)
  2. Add/Remove items to/from
  3. Is iteratable (I can, wherever I am in the set, do x,y,z with it)

Thats all I actually wanted, to make it totally behave like a full sequence, regarded, that it doesnt behave internally like one, but regardless to the User(Developer) who makes use of it.

As Im lurking thru other channels, also what is about this thing, I thought Island/Cocoa allow already for set iteration?

Ichecked right now and indeed iteration over sets is not possible and even this here doesnt work (it works in fpc and delphi)

TSet = set of Byte //this should be 255 bits

One way to find out? (they aren’t. 79660 is still open, and low priority).

the thing is tho these are important for code refactoring since sets are a quiet heavily used in delphi, so would be nice to make that complete.

Consider my post above this doesnt work also:"Set of" not supported? - #24 by LazarusRisen and this worked fine in delphi

Thanks, logged as bugs://85377

would you mind also supporting this syntax, when you work on this bug:

var st: TSet := [1..200];  //set from 1 to 200 elements was also able in FPC?

Thanks, logged as bugs://85395

Im wondering has this Type do smth with it internally or was it written to extend the limitation of sets over 255?

This is really a very different type. Oxygene sets are tied to numeric values (and available only in Oxygene), the Set<T> class is a container class — similar to, say, a List<T> — that contains only unique values. Also, it’s available to all languages.

1 Like

Nice to see :slight_smile:

I know I have penetrated you with the sets this week but this is the very last thing which really is important to be added to the language:

TCharSet = set of ['a'..'z', 'A.'..'Z', '0'..'9']; It makes filtering based logic so much more easier than constantly checking manually and creating those constructs from scratch. And yes I could emulate this with records but not so easy and memoryfriendly as it is done by sets from the compiler, like I would have to more magic to create this to be at max 1 byte length.

Just out of curiosity, Marc, how would you transcribe this simple Object Pascal code to Oxygene? I’ve partially translated it to Oxygene, but I think set of is throwing a wrench in the works. I also tried to use CodeBot but it got mangled pretty badly. :crazy_face:

namespace forEach_Oxy;

type
  Program = class

  furniture = public enum(chair, desk, bed, wardrobe);
  arrangement = set of furniture;

  var
    thing: furniture;

  public class method Main();
    begin
      writeLn("All available pieces of furniture: ");
      for thing in arrangement do
      begin
        writeLn(thing);
      end;
    end;

  end;

end.

I’d make this a flags enum, then it’s implicitly usable le as a set. that said, I’m surprised this isn’t supported,'ll check. What platform?

type
  furniture = public enum(chair, desk, bed, wardrobe);
  arrangement = set of furniture;

compiles clean for me in .NET. B ut having the types like that in the middle of the class declaration isnt valid. Also, you cane enumerate a type, only an instance of that type.

this compiles for me:

namespace forEach_Oxy;

type
  Program = class

    //var thing: furniture; // H6 Field "thing" defined in type "Program" is never used
    class var myArrangement: arrangement;

    public class method Main();
    begin
      writeLn("All available pieces of furniture: ");
      for thing in myArrangement do
      begin
        writeLn(thing);
      end;
    end;

  end;

  furniture = public enum(chair, desk, bed, wardrobe);
  arrangement = set of furniture;


  end.
1 Like

Thank you Mark. It does compile for me as well. But the output does not include enumerating through the set, it only outputs the following line:

All available pieces of furniture:

Well, class var myArrangement: arrangement; is empty?

This seems to work (as suggested by CodeBot):
class var myArrangement: arrangement := [furniture.chair, furniture.desk, furniture.bed, furniture.wardrobe];

yes, that looks right

So to recap, this is the original Object Pascal code:

program SetOfTest;

type
  furniture = (chair, desk, bed, wardrobe); 
  arrangement = set of furniture; 

var
  thing: furniture;

begin
  writeLn('all available pieces of furniture:');
  for thing in arrangement do
    writeLn(thing);
end.

And this is the transcribed Oxygene code:

namespace SetOF_Oxy;

type
Program = class

  class var myArrangement: arrangement := [furniture.chair, furniture.desk, furniture.bed, furniture.wardrobe];

    public class method Main();
    begin
      writeLn("All available pieces of furniture: ");
      for thing in myArrangement do
        writeLn(thing);
    end; // Main
  end; // class

  furniture = public enum(chair, desk, bed, wardrobe);
  arrangement = set of furniture;
  
end. // namespace

It’s interesting that furniture = public enum(chair, desk, bed, wardrobe); and
arrangement = set of furniture are located at the end of the file. Is this idiomatic Oxygene?