lgi-devs / lgi

Dynamic Lua binding to GObject libraries using GObject-Introspection
MIT License
440 stars 70 forks source link

Add compress.lua example #229

Closed v1993 closed 5 years ago

v1993 commented 5 years ago

I've been struggling for a while with how to use converters, so I think that this example may help others later.

If you have any questions/ideas about it, I will be glad to help with improving.

TingPing commented 5 years ago

Maybe error handling would be a good idea.

v1993 commented 5 years ago

@TingPing Well, I've already added checks which were required to produce meaningful errors during testing. Do you suggest to add assert on every single call which may fail in theory?

TingPing commented 5 years ago

Well, at a glance the splice() call is among the more important ones. For examples I'd also say assert()s are bad compared to printing the error messages (for things expected to fail, like bad input).

v1993 commented 5 years ago

@TingPing Ok about more checks, will do that. What do you have against assert, by the way? They still print error message to console (and exit to prevent further problems).

psychon commented 5 years ago

@TingPing Are you fine with this now?

ildar commented 5 years ago

Guys, this is an example, not a production application. Excessive error checks may only obscure it IMHO

TingPing commented 5 years ago

I mean I'm not going to block it or anything. I just think examples should represent real usage and that means handling expected errors not asserting.

No big deal.

psychon commented 5 years ago

I'll count that as "reviewed by @TingPing" :-)