Re: [m-users.] More optimization away

Mark Brown <[email protected]> Wed, 20 Dec 2023 20:21:08 +1100
Newsgroups gmane.comp.lang.mercury.general
Message-ID <CAM4AczAa9HB+2QZEtTKADyu1CBiB1puxLQc2dDv4RZG2HUrT1Q@mail.gmail.com>
On Wed, Dec 20, 2023 at 6:02 PM Volker Wysk <[email protected]> wrote:
>
> Hi
>
> I've made my predicate dependent on the IO state, in order to prevent it
> from being optimized away. However, the IO state isn't used inside the
> predicate. So will this be optimized away in a non-default semantics?

Not with strict semantics. A hypothetical lazy implementation might
optimize this away, but then I wouldn't expect this technique to work
well in lazy languages generally.

Cheers,
Mark

>
> :- pred throw_db_error(odbc.result::in, io::di, io::uo) is det.
>
> throw_db_error(Res, !IO) :-
>     (
>         Res = odbc.ok(_)
>     ;
>         Res = odbc.error(Messages),
>         throw(db_error(errors(Messages)))
>     ).
>
> TIA,
> Volker
> _______________________________________________
> users mailing list
> [email protected]
> https://lists.mercurylang.org/listinfo/users
_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users