[m-users.] Debugging with foreign types
Mark Brown
mark at mercurylang.org
Thu May 28 17:57:20 AEST 2015
On Sun, May 24, 2015 at 8:44 PM, Zoltan Somogyi
<zoltan.somogyi at runbox.com> wrote:
> On Sat, 23 May 2015 13:13:18 +0100, matthias.guedemann at googlemail.com (Matthias Güdemann) wrote:
>> But using queries is a good idea to explore a bit.
>
> Unfortunately, using queries does not help the problem at hand.
>
> Mdb implements queries by writing out a small Mercury program,
> compiling it, dynamically linking it into the running program (the
> one being debugged), executing it, then unlinking that small program.
Yes. But this means the query is in the same process, so foreign types
can be passed to it even if they encode a memory location. The
external debugger runs queries on the server side, so the same applies
here, too.
>
> When the query involves Mercury terms, this works fine. But if you
> want to pass a value of a foreign type to the query, then for each
> foreign type, the programmer would have to supply not just an
> unparser for the type (to allow the creation of the text of the query
> program), but also a parser (so that the Mercury code of the query
> program could give that value back to foreign code).
The diff I posted doesn't require any data to be serialized.
>
> Using queries thus makes the problem harder to solve, not easier.
For looking at a foreign infinite precision integer, I imagine a
programmer would:
(1) Write a query that converts it to a Mercury int, which will be
printed in the normal fashion.
(2) If that overflows, write a query that converts it to a float instead.
(3) If that overflows, write a query that returns its size as a Mercury integer.
Generally, there will be some domain-specific queries to usefully
convert a foreign value into Mercury ones.
Cheers,
Mark.
More information about the users
mailing list