Hello,
this is more a suggestion remark but I noticed that operator []( Index as integer=0 ) is not possible. The optionnal value 0 is reject here.
My remark is that the operator [] could be used for other purposes than like a deferencing pointer, so the notation udt[] without any value wouldn't really have to hurt the eyes. I don't know if the parser can really support it ourdays, but if it is possible and just volontarily not done, I wonder if there is any real problem in allowing this in the future. For () I would understand the risk of confusion with a procedure call, but here I dont see anything similar.
What's your opinion? Thanks.
Index should be possibly optionnal for operator []
-
- Posts: 2958
- Joined: Jun 02, 2015 16:24
Re: Index should be possibly optionnal for operator []
I would say that using that syntax for anything other than it's compiler specific purpose would make your code VERY hard to read and understand by anyone other than yourself, and maybe me for you as well after a few years. It seems like a neat idea at first, but the heartache of later trying to maintain that code may not be worth it.Tourist Trap wrote:...
My remark is that the operator [] could be used for other purposes ...
Just my $0.02
-
- Posts: 2958
- Joined: Jun 02, 2015 16:24
Re: Index should be possibly optionnal for operator []
You are right but the idea was for me to make a kind of priviledged (syntactically) property, like the default property in VB.net. The default property of VB is written simply class_instance(). In FB this could be done by udt_instance[] because we can not overload the () and also because there is more ambiguity with () than [] for this purpose.Imortis wrote: I would say that using that syntax for anything other than it's compiler specific purpose would make your code VERY hard to read and understand by anyone other than yourself, and maybe me for you as well after a few years.