[m-rev.] for post-commit review: clean up extras/xml

Zoltan Somogyi zoltan.somogyi at runbox.com
Sat Jun 25 06:45:23 AEST 2022


2022-06-24 16:17 GMT+10:00 "Julien Fischer" <jfischer at opturion.com>:
>> - "then", which prompted the email about funny syntax on m-users;
> 
> "next" or "then_do".

I chose "next".

> (I would also change the name of "and_then" to match whatever is picked.)

Done.

>> - lit, whose two different arity variants should have different names;
>>
>> - lit1, whose two different arity variants should also have different names,
>>  and a base name that differs from lit by more than one digit whose meaning
>>  is neither obvious nor documented;
> 
> * lit matches strings
> * lit1 matches characters
> * lit2 matches list of characters.
> 
> There are two variants of the first two, one which just matches and one which
> matches and returns a given value.
> 
> So perhaps:
> 
>     match_char
>     match_char_return
>     match_string
>     match_string_return
>     match_chars

I followed this scheme, but in an abbreviated form, because
xml.parse.chars.m contains many lines that contain several calls
to lit1 *each*, so brevity is key to allowing the Mercury code
to match the structure of the standard document it implements.
So the names I picked are mchr, mchr_return, mstr, mstr_return
and mchrs. (The _return versions are not used in that file.)
 
> (Looking at some of the parser combinator style parsers for XML written in
> Haskell that inspired this one, I don't think meaningful names was that much of
> a consideration ...)

Yes. I think that tradition was started not by Prolog, but by Lisp people.
Car and cdr may have been meaningful sixty years ago, but keeping it
unchanged all this time in (most) Lisp dialects has probably caused
almost as many programmers to bounce off Lisp as all the parentheses.

>> - x
> 
> is_a?

Done.

> The diff looks fine, although I have only skimmed it.

Thank you. The attached diff only implements what I described above,
so it does not need review.

Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Log.exml2
Type: application/octet-stream
Size: 167 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20220625/7f3d6401/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.exml2
Type: application/octet-stream
Size: 74319 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20220625/7f3d6401/attachment-0003.obj>


More information about the reviews mailing list