Forums

UTF8.GetBytes type inference in mono

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

UTF8.GetBytes type inference in mono

Postby khjklujn » Wed Feb 20, 2008 9:20 pm

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.
khjklujn
 
Posts: 29

Re: UTF8.GetBytes type inference in mono

Postby Charles » Wed Feb 20, 2008 9:46 pm

What does "cobra -version" give you on each platform?
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: UTF8.GetBytes type inference in mono

Postby Charles » Thu Feb 21, 2008 1:59 am

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.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: UTF8.GetBytes type inference in mono

Postby khjklujn » Thu Feb 21, 2008 10:12 am

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.
khjklujn
 
Posts: 29

Re: UTF8.GetBytes type inference in mono

Postby Charles » Thu Feb 21, 2008 12:34 pm

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.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: UTF8.GetBytes type inference in mono

Postby khjklujn » Thu Feb 21, 2008 4:53 pm

The name suggestions worked great. I never would have figured it out without them.
khjklujn
 
Posts: 29


Return to Discussion

Who is online

Users browsing this forum: No registered users and 35 guests