[m-rev.] for review: Improve Mercury's temporary files and directories predicates.

Julien Fischer jfischer at opturion.com
Wed Apr 13 17:29:46 AEST 2016


Hi Paul,

On Wed, 13 Apr 2016, Paul Bone wrote:

> On Wed, Apr 13, 2016 at 03:37:57PM +1000, Julien Fischer wrote:
>>
>> Hi Paul,
>>
>> On Wed, 13 Apr 2016, Paul Bone wrote:
>>
>>> On Wed, Apr 13, 2016 at 02:15:32PM +1000, Julien Fischer wrote:
>>>>
>>>> Hi Paul,
>>>>
>>>>> +
>>>>> +:- pred system_temp_dir(string::out, int::out, io::di, io::uo) is det.
>>>>
>>>> Use a bool rather than an int for the second argument.
>>>> (bool.YES and bool.NO in Java; mr_bool.YES and mr_bool.NO in C#)
>>>>
>>>
>>> The other suggestions are fine, however I cannot follow through on this one.
>>> Your recent change to allow this for the Java backend needs a couple of
>>> weeks to bootstrap (which I can live with).
>>
>> This is nothing to do with my upcoming changes to the Java backend.
>> The export of the Mercury constructors yes/0 and no/0 to Java under
>> the above names has been supported for years.   See the section
>> ``Java data passing conventions'' in the reference manual.
>
> Ah, What is changing then?

With regard to the way Mercury's bool/0 type is accessed from foreign
language code: nothing.  The additions to the Java backend mean that
foreign_types for the Java backend can now be Java primitive types,
including Java's boolean type.  Note that Mercury's bool/0 type 
is *not* implemented using Java's boolean type (which is what I think
may be confusing you here).

>> As for Erlang, I think you just need to return {yes} or {no} as
>> appropriate.  (Peter can correct me on that, if I'm wrong!)
>>
>>> And the Erlang backend doesn't seem to support this.
>>
>> ``Erlang data passing conventions'' in the reference manual.
>
> I opened this section and searched for "bool" there were no matches.

It doesn't require any special support for the Erlang backend.  From
that section of the manual:

      Mercury variables whose type is a Mercury discriminated union type
      will be passed as an Erlang tuple with the first element of the
      tuple being an Erlang atom named after the Mercury data constructor.
      For example, values of the type:

          :- type maybe_int
              --->    yes(int)
              ;       no.

      would be represented in Erlang as ‘{yes, integer}’ and ‘{no}’.

bool/0 is a discriminated union type, so {yes} and {no}.

Julien.


More information about the reviews mailing list