err = Write(int32(len(g.Name)))
err |= Write([]byte(g.Name))
err |= Write(g.Age)
err |= Write(g.FurColor)
return err;
If err is of type int with 0 == noError, this will require some new syntax if you want to return the correct error code (which you should want to do). I would suggest introducing x ||= y <===> x = x || y
In English: if x (still) equals its default, evaluate y and assign the result to x"One could even shortcut this to
err = Write(int32(len(g.Name)))
|| Write([]byte(g.Name))
|| Write(g.Age)
|| Write(g.FurColor)
return err;
Advantage: that's how the shell works, too. Disadvantage is that 'logical or' is not what one associates with "run items until first failure", but that can be learned.An alternative could be to have a language construct that takes a sequence of lambda's, executes them in sequence until the first one that fails (if any) and returns the index and the result code of the failing lambda. That would get you something like:
index,err = SEQ([
Write(int32(len(g.Name)))
, Write([]byte(g.Name))
, Write(g.Age)
, Write(g.FurColor)
]);
I like the first idiom better, though.