Code Review: RubyArrayPack

tfpt review /shelveset:RubyArrayPack;REDMOND\curth

Significant subset of Array.pack and String.unpack

What is MRI behavior if I return a number that doesn’t fit in sbyte?

writer.Write((sbyte)Protocols.CastToFixnum(context, self[i + j]));

Does it silently overflow? If so, we should use unchecked() region.

Other than that looks good.

Tomas

Is the “unchecked” just a formality under C#? It’s not currently
throwing an exception.

IronRuby:

[1000].pack(‘c’)
=> “\350”

Matz:
irb(main):012:0> [1000].pack(‘c’)
=> “\350”

More or less. But you can also compile with /checked option and then it
wouldn’t work.
It’s better to mark places where you expect the overflow, because you
usually don’t expect it.

Tomas