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.


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


=> “\350”

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.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs