It would be great if you could replace the seek in restore_byte by ungetc. This would make it possible to read directly from STDIN, Sockets, etc (STDIN.seek(-1) #=> RuntimeError). It is also possible to reuse the IO for multiple objects.
For example, with MRI:
ruby -e 'Marshal.dump("foo", STDOUT); Marshal.dump("bar", STDOUT)' | ruby -e 'loop { p Marshal.load(STDIN) }'
"foo"
"bar"
Traceback (most recent call last):
3: from -e:1:in `<main>'
2: from -e:1:in `loop'
1: from -e:1:in `block in <main>'
-e:1:in `load': end of file reached (EOFError)
With this changes below, this would be possible with mruby as well:
It would be great if you could replace the seek in restore_byte by ungetc. This would make it possible to read directly from STDIN, Sockets, etc (
STDIN.seek(-1) #=> RuntimeError
). It is also possible to reuse the IO for multiple objects.For example, with MRI:
With this changes below, this would be possible with mruby as well:
I am not sure why MRI raises an EOFError which is what I expected, but mruby continues parsing marshal data.
My changes (sorry, I dont really know any CPP):