Some possible new Features?

(SH) #1

Hey Guys,

Would you also consider some of these features?

instead of: (pointer + index)^.MyProperty := 10; -------> pointer->MyProperty


TSomeRecord = packed record
Prop1, Prop2, Prop3: string;


var x: string[30];  //like FPC/Delphi allows it to minimize the string storage

(Carlo Kok) #2

(pointer + index)^.MyProperty := 10;
I want to allow:
(pointer + index).MyProperty := 10; in this case
(issue 77290, logged for the version after the upcoming version)

what are you trying to solve with packed record, we have packed support (iirc via [Packed]), but it won’t do anything in this case, since they’re all the same size?

var x: string[30];

Not a big fan of that to be honest, it has some implications, like [0] being the length that are incompatible with Oxygene.

(SH) #3


the way how C/C++ handles pointer access is more symantic-sugar, because:

 pointer->MyProperty // tells: pointer is "pointing" to MyProperty, thats very semantic^^

And the case with packed was just an example^^, ok but you are allowing it, cool :slight_smile:

By the way,
is string a class or does it internally behave like it was behaving in FPC/Delphi??

(Carlo Kok) #4

String is a class, it’s immutable too, so it’s more like .net’s string. If you need to change a string a lot of times, it’s better to use StringBuilder (like appending, editing), otherwise string has functions for concat/substring/delete/etc.

(SH) #5

[Packed] doesnt work unfortunately^^

And would you consider, at least as a compiler directive, to introduce the “ptr->Property” semantic?

(RemObjects) #6

Thanks, logged as bugs://77291

(Carlo Kok) #7

no because I’ll probably match delphi /freepascal and allow “ptr.Property” instead.

I’ve logged an issue for Packed.

(RemObjects) #8

bugs://77291 got closed with status fixed.

(SH) #9

Honestly the reason why I like it more is because I want a difference between calling and reference. Property and for that the arrow operator is actually more convenient but you are the compiler chief :grinning::grinning:

(Carlo Kok) #10

well the arrow operator is used for lambdas, so wouldn’t work here.

(SH) #11

Ah ok, well than there is no other possibility here ^^

(SH) #12

I noticed something else as a missing feature, which was for me actually really really helpful and pretty useful!


var myFIle: file of MyRecord
var myTextFile: Text;    //same as : file of text;

Why did you remove this?

(Carlo Kok) #13

We never added it. Nor do we have plans to support file of or Text types.

(SH) #14

Ok, but why dont you introduce those features^^

What are your struggles with it?

(Carlo Kok) #15

In my opinion they don’t fit in a modern language. “TextFile” can be done a lot better with StreamReader or equivalent, a proper class instead of “magic”. File of would have trouble with alignment, strings (which are pointers) and cpu byte ordering. Something like this can be solved a lot better with a class that clearly states tells what it’s doing. And lastly, record files restrict a file to 1 type, can’t easily be expanded because the record format is “set” and probably should be discouraged in the first place.

That all said, there’s nothing to stop anyone from writing two classes that do this that mostly match the semantics.

(SH) #16

Ah ok, a much more direct answer :smiley:

I understand your struggles now even better!

And btw, it may happen that sometimes i’m asking some unnessecary questions or stupid ones, because im not in a developer level like you guys^^ and im still learning a lot, pls put that in mind when reading some issues i’ve posted :stuck_out_tongue:

(Carlo Kok) #17

btw we have an open source project:

which would be an ideal place to put TextFile/File<T>. If you want to consider contributing to the effort.

(SH) #18

I found another feature, are you able to create the same tuples as in C# 7.0
where they are named tuples, like: (Name: string, ID: int32, haveLoan: boolean)

and in Oxygene:

  var myyTuple: tuple of (Name: string, ID: int32,  haveLoan: boolean);´
  myTuple.ID, myTuple.Name, myTuple.haveLoand //and so on...

would be really nice, because you wouldnt have to create really often records, which are actually not more than what i explained before :smiley:

Why are your tuples classes and not records, they actually behave more like a struct/record?

(SH) #19


Your MemoryStream implementation, does it behave äquivalent to “file of”?


                var stream: MemoryStream := new MemoryStream(20);
		var data: ^TData;
		data := new TData[1];
		data^.A := 1000;
		data^.B := 2000;
		data^.C := 3000;
		data^.D := 4000;
		data^.B := 127;
		data^.Count := 100000;

		Stream.Write(^Void(data), 10);  //write data, 10 times in memory

It SEEMS that it can take any-object and write it to another memory-location count-times, am i right, it pretty look like “file of” ^^

(Carlo Kok) #20

It takes a size. Not a count. Multiply it by sizeof(tdata)