Re: [m-users.] Free and Ground in the same error line?
Julien Fischer <[email protected]> Tue, 31 Oct 2023 23:13:58 +1100 (AEDT)
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 28 Oct 2023, Sean Charles (emacstheviking) wrote: > I rewrote it like this, could it be any leaner? Asking in case I am not as good as I can be yet :D ! > Â Â 384 get_class_superclass(Class, Super, !X) :- > Â Â 385 Â Â ( if !.X = [ tk(Cp, Cb) | Rest ] then > Â Â 386 Â Â Â Â Class = ps(Cp, Cb), > Â Â 387 Â Â Â Â Super = no, > Â Â 388 Â Â Â Â !:X Â = Rest > Â Â 389 Â Â else if !.X = [ sexp(_, [ tk(Cp, Cb), tk(Sp, Sb) ]) | Rest ] then > Â Â 390 Â Â Â Â Class = ps(Cp, Cb), > Â Â 391 Â Â Â Â Super = yes(ps(Sp, Sb)), > Â Â 392 Â Â Â Â !:X Â = Rest > Â Â 393 Â Â else > Â Â 394 Â Â Â Â fail > Â Â 395 Â Â ). > > I mean, it's fine but in the manual, 2.13 DCG-rules it says "As a > matter of style, we recommend that in future DCG notation be reserved > for writing parsers and sequence generators, and that state variable > syntax be used for passing state threads." I would not read too much into that recommendation. It was written as part of the change that added state variables to the Mercury language. At that point, no one had much experience using, for parsers or sequence generators, or anthing else. My opinion, with the benefit of twenty years of hindsight, is don't use DCGs. (The one exception to that might be if I were in the process of porting an existing Prolog program to Mercury.) Julien. _______________________________________________ users mailing list [email protected] https://lists.mercurylang.org/listinfo/users