Picotron Playground -- an experimental web-based edition of my WIP Fantasy Workstation -- is OUT NOW! It includes a code editor and terminal program for poking around some demos of the #picotron API and runtime.

https://lexaloffle.com/bbs/?tid=50923

Picotron Playground

@zep Picotron v7 raises an error on nil table iterator. Expected?

for i,v in pairs(nil) do
end
>>bad argument #1...

@fsouchu @zep Dunno what zep thinks but I would expect an error on trying to iterate nil.
@Felice @zep pico took a different approach so far - hence asking if intentional
(and no I very much like it doesn’t raise an error - iterating on a nil table = nop)
@fsouchu @zep
Mm, no. Iterating on a nil table should be an error, not a nop. In most cases passing nil to an iterator suggests that the input variable was not derived correctly or that the code that was supposed to create a table in it failed, and the author needs to debug the code that created it. Doing a nop on nil just makes it harder for people to track down bugs.

@fsouchu @zep
BTW if you do want that behavior, just write something like maybe_pairs(t) that wraps pairs(t) with a test that returns a nop iterator if t is nil.

That'd do what you want and make the expected behavior explicit in your code.

@Felice @zep sure, just that this was supported on pico8, hence the question