#include "share/atspre_define.hats"#include "share/atspre_staload.hats"
staload "libats/libc/SATS/stdio.sats"
fun open_close(): void =let val fptr = fopen("hello.dats", file_mode_r) val p = ptrcast(fptr)in if p = 0 then let prval () = FILEptr_free_null(fptr) in end else let val (pf|rc) = fclose(fptr) val () = assertloc(rc = 0) // fclose is expected to succeed prval None_v() = pf in endend
--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/8246dd5f-fb2f-497e-add4-5c808768ed50%40googlegroups.com.
FWIW, I personally would use
FILEptr_is_null to check if fptr is null, rather than ptrcast and
then a comparison to 0
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLrozrnEK_FiFB5ZyFU%2BEYU%3DZ0nYjZOvbcB5%2BsKcseeSsg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLrozrnEK_FiFB5ZyFU%2BEYU%3DZ0nYjZOvbcB5%2BsKcseeSsg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/9a5a4f56-4fdb-ffc1-ff43-10f1d87fa3e6%40iohk.io.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLrozrnEK_FiFB5ZyFU%2BEYU%3DZ0nYjZOvbcB5%2BsKcseeSsg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAA6Z%2B7BbLK9Fvg0gNN%2B6oCEJMY_E6D610AG8Pf8vG5QZSaekwA%40mail.gmail.com.