[m-users.] inline / anonymous predicates ... style...

Sean Charles (emacstheviking) objitsu at gmail.com
Sun Mar 6 00:10:02 AEDT 2022


Hi,

Having recently seen the `errors.m` contribution to the Mercury extras folder, and more reading if compiler and mmc-doc source code, I often see this style:

P = (pred (...) .......
      ),
      list.take_while(P, ....
or   list.foldl(P, ...

and I wondered is it a style matter or is the compiler able to do more if I define the predicate first ? I ask as my code for my transpiler rarely does this, mainly because of my past experience with other languages where you just throw the code inline:

    list.take(
	(pred(...)
        ),
	..args..
    )

is there a preferred style and if so, what was the basis for that decision ? I ask because once a week I go on a 'code cleaning' exercise in my transpiler to help me spot repetition and such like.

Thanks,
Sean.


More information about the users mailing list