Saving your work from interactive Io session?

View: New views
3 Messages — Rating Filter:   Alert me  

Saving your work from interactive Io session?

by dennisf486 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Suppose I'm testing out code at the Io> prompt and I've created some objects and methods I really like and I want to save them.  Is there a command that will allow me to either save my session history to a *.io file, or to stream out the objects I've created into a *.io file?


Re: Saving your work from interactive Io session?

by Jeremy Tregunna-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Check out your ~/.io_history file (might not have a _ in the filename,  
i can't remember). If you've got history available, i.e., up arrow  
works, that file is created.

On 2009-10-21, at 4:15 PM, dennisf486 wrote:

> Suppose I'm testing out code at the Io> prompt and I've created some  
> objects and methods I really like and I want to save them.  Is there  
> a command that will allow me to either save my session history to a  
> *.io file, or to stream out the objects I've created into a *.io file?
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>

Regards,

Jeremy Tregunna
jeremy.tregunna@...




Re: Saving your work from interactive Io session?

by Steve Dekorte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 2009-10-21, at 1:15 PM, dennisf486 wrote:
> Suppose I'm testing out code at the Io> prompt and I've created some  
> objects and methods I really like and I want to save them.  Is there  
> a command that will allow me to either save my session history to a  
> *.io file, or to stream out the objects I've created into a *.io file?


You can get the source for a method/block by sending it a code message:

foo := method(v, v + 1)
getSlot("foo") code
==> method(v, v +(1))

If you defined a code method (we should probably rename it asCode) on  
the primitives you could do something like:

Object asCode := method(
        self proto type .. " clone do(" .. \
        self slotNames map(k, k .. " = " .. self getSlot(k) asCode) join
("\n") .. \
        ")"
)

But anything like this opens the whole can of worms of how far you  
should follow references and how to deal with reference loops.