Closed dustin closed 11 years ago
Thanks - pushed a quick err assignment fix, but still just as wide and indented until I get some more quality time.
If you want to understand the general union logic more, here's the original (non-persistent / memory-only) code that this was based on...
https://github.com/steveyen/gtreap/blob/master/treap.go#L78
And it was pretty much mechanically adding the reading & error propagation stuff.
that doesn't look bad. Why don't you make the other one look like that? :)
In general, just return the error when you get it. I think that'd clean it up a lot.
Steve Yen wrote:
Thanks - pushed a quick err assignment fix, but still just as wide and indented until I get some more quality time.
If you want to understand the general union logic more, here's the original (non-persistent / memory-only) code that this was based on...
https://github.com/steveyen/gtreap/blob/master/treap.go#L78 And it was pretty much mechanically adding the reading & error propagation stuff.
— Reply to this email directly or view it on GitHub https://github.com/steveyen/gkvlite/issues/1#issuecomment-12207159.
Hmmm.
Looks like I completely misunderstood the := operator.
It's a little extra confusing inside the if. I don't use the if/;/test idiom all that much. When you do, the bindings don't escape the if/else.
Steve Yen wrote:
Hmmm.
Looks like I completely misunderstood the := operator.
— Reply to this email directly or view it on GitHub https://github.com/steveyen/gkvlite/issues/1#issuecomment-12207222.
yeah, i just realized that, so time to scrub a lot more code. thanks for catching this.
Made union() and several other functions look taller and more correct. Plus, now I think I understand :=
I haven't confirmed, but I can't see how this thing could possibly return an error.
In general, I think anything more than two or three levels should be a sign that something is not right. In this case, there's something like nine levels of conditionals nested, each declaring a distinct
err
var and throwing it away.It seems like it should be possible to make a correct implementation that's correct and less... wide.