caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: akalin@akalin.cx
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] ocamldebug and abstract record types
Date: Sun, 21 May 2006 18:57:24 +0900 (JST)	[thread overview]
Message-ID: <20060521.185724.74757566.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <B0430106-0F99-4458-BEA9-54E9EE8B23A7@akalin.cx>

From: Frederick Akalin <akalin@akalin.cx>

> At the risk of starting another flamewar, I have another question.  I  
> notice that if I have a record type that's defined in an .mli file, I  
> am able to print objects of that type and see its contents in the  
> debugger.  However, if I make that type abstract (only defining it in  
> the .ml file), I am unable to do so, instead seeing "<abstr>", unless  
> I am in the .ml file where the type is defined.
> 
> Surely this information is available to the debugger from anywhere in  
> the program?  Currently I make most of my types non-abstract simply  
> because it is impossible to debug my programs without being able to  
> check record contents, a practice which I would like to avoid having  
> to do.  I am used to gdb, which prints out all a struct's contents  
> regardless of protected/private modifiers, or Perl, which provides a  
> similar facility with the Data::Dumper module.

To be more precise, the debugger uses information from the .cmi file
to print values. The information is not included in the .cmo file,
even with the -g option. Printing automatically abstract type would
require a new infrastructure, saving type definitions in the .cmo.

Note that an intermediate step would be to declare your definitions as
private: they become semi-abstract (you cannot create values from
outside the module), but you can still print them.

> I am aware that the debugger lets you load printing functions, a  
> facility which I am now exploring.  Although my first impression is  
> that it requires a non-trivial amount of work, both on the coding and  
> debugging side.

This requires some work, but not as difficult as it may seem.
The pretty-printer is very easy to use, particularly Format.fprintf.

Jacques


  reply	other threads:[~2006-05-21  9:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-21  7:40 Frederick Akalin
2006-05-21  9:57 ` Jacques Garrigue [this message]
2006-05-22  9:05 ` [Caml-list] " Richard Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060521.185724.74757566.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=akalin@akalin.cx \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).