Chris wrote:
No you're right, there's an issue here. The Binary type itself is a STRUCTURE (so it's being passed by value), but it holds its data internally in a byte array (so a reference type) and when you convert the Binary value into a BYTE array in your first local assignment, then the conversion returns that exact internal array. Maybe the best way is to return a new copy of the array instead, will log an incident on that to be looked at.
Given the fact that the binary type is a value type it indeed makes sense to return a copy of the byte array as well (in other words, to make it a really immutable type).
Agreed, I made the change. Not sure if also the constructor that accepts a byte array needs to use a cloned buffer as well. If this constructor is supposed to be called only from the compiler emitted code for literals and from within the class code, then there's no point I think.
Btw, I think you accidentally increased the assembly version (not only the file version) of the runtime to 2.8.0.0 instead of 2.6.0.0.
Karl Heinz,
Adding such a constructor is no problem at all. In fact I'll map the implicit converter to call the same constructor to keep the logic in one place.
Important to realize is that the mapping between characters and bytes only works for lower ascii characters. Accented characters and characters from other character sets will not map like that. They will be replace with a question mark when translated.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
yes, i´m aware of the problems. If e.g. Chris creates a byte array with some special greece chars included i won´t be able to see on my machine the correct string presentation if i simply use RuntimeState.WinEncoding:GetString( bArr).
i asked about the string constructor because it´s possible to do this:
Going back to Chris's question, here is a list of common VFP functions that I think would signify an advancement if implemented from scratch or recreated to match VFP's behavior closer:
EMPTY() and EVL() (I'm not forgetting this, Matt)
ISNULL()
ALINES()
TRANSFORM() (verify formats) and TTOC()
TEXTMERGE()
STREXTRACT()
XMLTOCURSOR() and CURSORTOXML()
AERROR(), at least to support SQL* functions
GETFILE(), PUTFILE() and LOCFILE()
Because of how this thread evolved, I worked on the BIT* functions. I will propose them in a separate thread.