Hi! The reason Brian used to_unsafe is because that method is implicitly called when you pass something to C and the type doesn't match: crystal-lang.org/reference/1.3/syn...
So in your case if you define a to_unsafe for Z3::IntExpr that returns @expr, you could replace this:
To be honest if users call something called to_unsafe they only have themselves to blame. I just didn't want it to be called expr as that might encourage segfault-prone code.
Hi! The reason Brian used
to_unsafeis because that method is implicitly called when you pass something to C and the type doesn't match: crystal-lang.org/reference/1.3/syn...So in your case if you define a
to_unsafeforZ3::IntExprthat returns@expr, you could replace this:with this:
which might be nicer to read/write, depending on personal taste.
Is it true even if I mark
to_unsafeasprotected?To be honest if users call something called
to_unsafethey only have themselves to blame. I just didn't want it to be calledexpras that might encourage segfault-prone code.Hm, good point. Apparently it doesn't work if
to_unsafeisprotectedorprivate, but I think it should. I'll ask to change that.