22 Jul 2004 17:16
Re: [groovy-dev] dump() and inspect()
On 22 Jul 2004, at 15:56, John Stump wrote: > Greeting groovy developers, > > Can someone explain the purpose of the dump() and inspect() > methods in DefaultGroovyMethods.java? I understand what they do, > but wonder what the main goal is. > > dump() has an odd output format and dumps out only fields, > including private fields. Should this output *properties* > instead of *fields*? And should it exclude privates? dump() was intended as a way of showing the internal structure of a class, so yes it was fields. If you wanted properties wouldn't the properties() methods work? > inspect() *seems* like it can produce a string of an object > that, when evaluated, can reproduce itself. It falls short of > this goal on POGOs, but could possibly be implemented this way. > I see some potential for cheap object serialization using > inspect() *if* this is the intent of the method. :) Yes inspect() was kinda meant to show you the kinds of things you'd need to type into a command line shell to create the object. e.g. [1, 2, "hello"].inspect() -> '[1, 2, "hello"]' with some Java classes & their use of toString() (especially arrays) then things don't always map 1-1 James ------- http://radio.weblogs.com/0112098/
RSS Feed