Re: [m-users.] More optimization away
Mark Brown <[email protected]> Thu, 21 Dec 2023 12:55:12 +1100
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <CAM4AczAjM0Ov5gAcNiO1yigMg7i53OQ=+qKAgrdc5_hRrPM_Bg@mail.gmail.com> |
On Wed, Dec 20, 2023 at 10:38 PM Volker Wysk <[email protected]> wrote: > > Am Mittwoch, dem 20.12.2023 um 20:21 +1100 schrieb Mark Brown: > > 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. > > Okay... After all, it doesn't seem to be a good idea to try to write > programs that work in all semantics. Rather, it doesn't seem to be a good idea to try to write programs *that use exceptions to indicate real results*, at least not if you need that level of portability. Having said that, we could always add to the standard library a det version of throw that takes the I/O state. All implementations need to respect the semantics documented in the standard library, so (unlike your example code) there would be no way to infer that the final I/O state is the same as the initial one, thus no way that the optimization could be logically justified. Personally, though, I prefer sticking with my first paragraph. Cheers, Mark > > Cheers, > Volker > _______________________________________________ > users mailing list > [email protected] > https://lists.mercurylang.org/listinfo/users _______________________________________________ users mailing list [email protected] https://lists.mercurylang.org/listinfo/users