Page 1 of 1

UTF8.GetBytes type inference in mono

PostPosted: Wed Feb 20, 2008 9:20 pm
by khjklujn
I've bumped into a bit of weirdness in mono with System.Text.Encoding.UTF8.

The following example behaves as expected under Microsoft's framework.
class Program
def main is shared
buf = System.Text.Encoding.uTF8.getBytes('yo')
for i in buf
print i

To get the same behavior under mono, I had to code it as:
class Program
def main is shared
buf = System.Text.Encoding.utF8.getBytes('yo') to Byte[]?
for i in buf
print i

The first bit of oddness is that under .NET, Cobra wants to use "uTF8", which is what it should be. However, under mono, Cobra wants "utF8".

The second thing is that Cobra is inferring a return type of Int32 for getBytes, which causes a C# compilation error unless it is explicitly cast to what it really is.

Re: UTF8.GetBytes type inference in mono

PostPosted: Wed Feb 20, 2008 9:46 pm
by Charles
What does "cobra -version" give you on each platform?

Re: UTF8.GetBytes type inference in mono

PostPosted: Thu Feb 21, 2008 1:59 am
by Charles
This is a bug in Cobra's treatment of method overloads. You'll have to stick with the typecast for now.

The different name treatment indicates to me different versions of Cobra. You may have forgotten to point your cobra.bat to the new version on Windows. On Unix-like systems, the "install" script takes care of that for you.

Re: UTF8.GetBytes type inference in mono

PostPosted: Thu Feb 21, 2008 10:12 am
by khjklujn
Ah yes, versioning.

Never mind the report about the "uTF8" versus "utF8" under the different frameworks. I was still running 0.7.2 on the windows box. Using 0.7.3, both frameworks want UTF8 to be spelled utF8.

Re: UTF8.GetBytes type inference in mono

PostPosted: Thu Feb 21, 2008 12:34 pm
by Charles
The name treatment change is due was for names like "osVersion" and such. I hadn't considered the numeric case, so I'll fix for next version. At least now in 0.7.3, you get the suggestions for unknown member names so you know what works.

Re: UTF8.GetBytes type inference in mono

PostPosted: Thu Feb 21, 2008 4:53 pm
by khjklujn
The name suggestions worked great. I never would have figured it out without them.