That would be extremely helpful IMO, as the implicit casting is not self-evident for those (relatively) new to the FB compiler. It definitely got me confused a bit. I bet there are Pascal programmers out there who use the PChar data type without realizing much what's happening under the hood. This is because FPC is more strict if it comes to implicit type casting, which is why it is relatively easy there to do pointer arithmatics. I'm happy to see that FBC allows us to do the same, but it isn't as obvious. In this respect it would be helpful to have something like this in FB:
Code: Select all
dim buffer as string
dim p as PChar ' zstring ptr type
buffer = "something"
p = CPChar(buffer) ' convert to PChar
' instead of:
p = cast(PChar, @buffer)
The cast construction is powerful, but it requires more thinking and it looks a bit verbose, especially when passing as parameters.
Anyway, I saved your example for future reference. (BTW 'traited' should be 'treated'.)