caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* ocamldebug and abstract record types
@ 2006-05-21  7:40 Frederick Akalin
  2006-05-21  9:57 ` [Caml-list] " Jacques Garrigue
  2006-05-22  9:05 ` Richard Jones
  0 siblings, 2 replies; 3+ messages in thread
From: Frederick Akalin @ 2006-05-21  7:40 UTC (permalink / raw)
  To: caml-list

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.

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.

Incidentally, how sophisticated is the debugger planned to be?  Is it  
only supposed to be used for quick-and-dirty debugging and not as a  
replacement for the toplevel?

Frederick Akalin


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] ocamldebug and abstract record types
  2006-05-21  7:40 ocamldebug and abstract record types Frederick Akalin
@ 2006-05-21  9:57 ` Jacques Garrigue
  2006-05-22  9:05 ` Richard Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Jacques Garrigue @ 2006-05-21  9:57 UTC (permalink / raw)
  To: akalin; +Cc: caml-list

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] ocamldebug and abstract record types
  2006-05-21  7:40 ocamldebug and abstract record types Frederick Akalin
  2006-05-21  9:57 ` [Caml-list] " Jacques Garrigue
@ 2006-05-22  9:05 ` Richard Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Jones @ 2006-05-22  9:05 UTC (permalink / raw)
  To: Frederick Akalin; +Cc: caml-list

On Sun, May 21, 2006 at 12:40:20AM -0700, Frederick Akalin wrote:
> 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.

Another solution -- not very elegant -- is to use the Std.dump
function from Extlib.  It's similar in principle to Perl's
Data::Dumper.

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-05-22  9:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-21  7:40 ocamldebug and abstract record types Frederick Akalin
2006-05-21  9:57 ` [Caml-list] " Jacques Garrigue
2006-05-22  9:05 ` Richard Jones

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).