[m-users.] Free and Ground in the same error line?
Julien Fischer
jfischer at opturion.com
Tue Oct 31 23:13:58 AEDT 2023
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.
More information about the users
mailing list