On Apr 13, 2009, at 00:19 , Eero Saynatkari wrote:

> I think I am in agreement, but I  would like to amend the
> description of the three to confirm:
>
>  #to_s:    String representing the object mainly for output
>  #inspect: Internal details, ivars etc., mainly for debug
>  #dump:    Round-trip/evalable representation


I agree with this and thought/hoped that was the original intent of  
inspect.

In smalltalk (a stream-based IO system) they use #printOn: like our  
puts/to_s and  #storeOn: for something like a meld of your #dump and  
#inspect. storeOn: outputs the code that would eval to an object equal/ 
equivalent to the original (see below). Unfortunately, our #inspect  
for non-core objects don't default to a ruby expression.

I think #to_ruby would be a better name than #dump. It doesn't clash  
with Marshal/YAML and matches #to_s and friends.

> storeOn: aStream
> 	"Append to the argument aStream a sequence of characters that is an
> 	expression whose evaluation creates an object similar to the  
> receiver."
>
> 	aStream nextPut: $(.
> 	self class isVariable
> 		ifTrue: [aStream nextPutAll: '(', self class name, ' basicNew: ';
> 					store: self basicSize;
> 					nextPutAll: ') ']
> 		ifFalse: [aStream nextPutAll: self class name, ' basicNew'].
> 	1 to: self class instSize do:
> 		[:i |
> 		aStream nextPutAll: ' instVarAt: ';
> 			store: i;
> 			nextPutAll: ' put: ';
> 			store: (self instVarAt: i);
> 			nextPut: $;].
> 	1 to: self basicSize do:
> 		[:i |
> 		aStream nextPutAll: ' basicAt: ';
> 			store: i;
> 			nextPutAll: ' put: ';
> 			store: (self basicAt: i);
> 			nextPut: $;].
> 	aStream nextPutAll: ' yourself)'