How can I save changes on memory ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I save changes on memory ?

JeremieRegnault
Hi,

I would like to know how to save modifications (e.g creating a
class/method ) in the memory.

Have a nice day,

--
Jérémie Regnault

Reply | Threaded
Open this post in threaded view
|

Re: How can I save changes on memory ?

Ron Teitelbaum
Hi Jérémie,

Welcome to Pharo.  

There are a number of different types of memory so it's difficult to answer your question. 

The first big divide is Development vs Production.  in Development you create code that is stored in a repository.  Your changes can also be captured in a change set, or automatically in the changes file.  When you create a new class it creates a change which will go to the changes file.   You can get back your code by selecting World > Tools... > Recover lost changes. See http://files.pharo.org/books-pdfs/updated-pharo-by-example/2017-01-14-UpdatedPharoByExample.pdf.  It may also add your code to a change set.  See "Change sets and the change sorter" in the same link.  You might also save code in a Monticello Repository, or even have your files written into a Git repository.  

Once you have your code written and saved in a repository you can create a production image for your users.  That process usually requires that you use a base image, load your changes and save the image.  It might also include locking down the image, turning off developer tools, and packaging it in an installer.  At that point, you can send your classes and methods to others to use as an application.  You could also deploy your Pharo image as a server on your computer and allow users to interact with it using other methods like http or tcp.  
There is a third method to save modifications in memory during runtime.  The basic way to do that is to just create instances from your classes (MyClass new) add your data and execute your methods and save the image, or write out the data to a database or file so that those instances can later be read in and recreated by your program.  In that way, your program saves its state and can reload it later in memory.

It's not clear from your question what type of memory or program you are talking about.  Good luck with your programming, hopefully, that will be helpful!  

All the best,

Ron Teitelbaum 





On Tue, Jun 20, 2017 at 8:54 AM Jérémie Regnault <[hidden email]> wrote:
Hi,

I would like to know how to save modifications (e.g creating a
class/method ) in the memory.

Have a nice day,

--
Jérémie Regnault

Reply | Threaded
Open this post in threaded view
|

Re: How can I save changes on memory ?

Marcus Denker-4
In reply to this post by JeremieRegnault

> On 20 Jun 2017, at 14:54, Jérémie Regnault <[hidden email]> wrote:
>
> Hi,
>
> I would like to know how to save modifications (e.g creating a
> class/method ) in the memory.
>

Classes:

        - Definitions: Classes are already in memory: the definition you see in the browser
        are kind of “decompiled” (created by the class object).
                        Object definition
        - in addition it is logged to the .changes, but that is not needed to look at a class, it is just
          logged to have it in case of a crash before the image is saved.
        - Comments: they are in the .changes or .sources, classes point to them (via the organiser)
          using a RemoteString.  (this is done by the class ClassOrganization )

Methods.
        - When you compile they point to the .changes or .sources via an offset that is at the end of the
          bytecode (the so called trailer).

        - there is code in the system to store instead of that pointer the whole code in the trailer.

        - methods can be created with embedded sources (not needing to store in  .changes) by calling
           #generateWithSource instead of #generate on the AST root node.
          (this is used for Doit compilation right now).

           Methods that use a source pointer can be converted by calling #embeddSourceInTrailer on them.

        Marcus