[m-users.] A question of style...

Sean Charles (emacstheviking) objitsu at gmail.com
Thu Mar 3 19:47:20 AEDT 2022


Hi Zoltan,

Yes, I have spent many hours since I began learning Mercury reading the source code, it gives valuable insights into what can be done with it, I've picked up many things not obvious to me from the PDF documentation.

What was needed in my case was a good rethink, I am now on version -two- of my project and it is much cleaner, I have made a rule; no more than two steps in the staircase, after that, for me anyway, it's a signal that I am trying to do too much in one predicate. The other thing I have taken to doing is spending much more time reading the module documentation and using mmc-doc.

For example, I am parsing a '.err' file and after scanning the list of modules, I realised that a multi_map was the perfect solution for storing a parsed file as I was on the verge of rolling an ad-hoc structure and figured that I was going to waste my time.

I feel much more comfortable with Mercury these days, I've taken a few days out of my big transpiler project to work on a small utility that will integrate with the editor 'nano' which is all I use now for Mercury, I have created a custom nano syntax file based on Prolog and it works very well for me, I get a lot of mileage. On lazy days I go back to VSCode but not very often.

I hope to finish the project in the next few days and push to github, I will announce here in case anybody might find it useful...I have Paul Bone to thank for the inspiration for it but he doesn't know that yet!

Thanks again,
Sean.

> On 3 Mar 2022, at 04:25, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
> 
> 
> 2022-03-01 20:01 GMT+11:00 "Sean Charles (emacstheviking)" <objitsu at gmail.com>:
>> I guess what I am trying to ask is, is there a 'Mercury Way' to handling this.
> 
> There is no single standard way of handling this.
> 
> The Mercury compiler tries to give meaningful diagnostics for each kind of error,
> so in most such cases we write stair-case code, because that allows us to generate
> different error messages for different kinds of errors. The stair-case effect has not been
> a problem since we switched from eight space to four space indentation ages ago,
> because this allows pretty much even the deepest of our staircases to fit on a
> standard 80-column line.
> 
> But there are other ways of handling this problem, and some other parts of the
> Mercury system, which don't have the same need to generate failure-kind-specific
> error messages, do use them. See for example io_combinator.m in the deep_profiler
> directory, as well as both of the techniques you cite.
> 
> Which one you use in depends on your taste as well as the demands of the circumstances.
> 
> Zoltan.



More information about the users mailing list