Some possible new Features?

Hey Guys,

Would you also consider some of these features?

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

Or

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

Or

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

(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.

Honestly,

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??

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.

[Packed] doesnt work unfortunately^^

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

Thanks, logged as bugs://77291

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

I’ve logged an issue for Packed.

bugs://77291 got closed with status fixed.

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

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

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

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

Typefile/Textfile:

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

Why did you remove this?

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

Ok, but why dont you introduce those features^^

What are your struggles with it?

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.

1 Like

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:

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.

1 Like

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:

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

Question:

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

because:

                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” ^^

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