On Sunday, July 16, 2017 at 10:24:51 AM UTC-5, Edward K. Ream wrote: > > developing with @button or @test already simulates instant reload pretty well. > Today, right now, Leo devs and script writers can develop python code *more *easily in Leo than in SmallTalk.
After more thought, the first statement seems more accurate :-) Leo and SmallTalk each have their own advantages. Here are step-by-step instructions for developing code in Leo without having to reload Leo. *tl;dr:* Read the summary. But devs should consider reading all of this carefully ;-) *1. Create a dev node* This node (in the Leo outline) defines your development environment. This can be an @test node, an @button node, or an @command node. Using a plain outline node would be less convenient because you won't be able to execute it so easily. The *dev script* is the script in the dev node itself. The *code under development *is the code exercised by the dev script. *This is (by far) the most important step!* Once you say to yourself, "Ok, I'm going to be clever and develop my code using the Stupendous Aha <http://leoeditor.com/FAQ.html#what-is-the-stupendous-aha-and-why-does-it-matter>", everything else in this post is going to happen naturally. It may not always be easy, but the programming process itself will lead you to the next action. Otoh, If you *don't* create a custom dev environment you will have to reload Leo to test your new code. That will be much slower. *2. Set up your dev node so you can execute it quickly* There are several ways to run your dev script easily: - Use a marked @test node and use run-marked-unit-tests-locally. - Disable or ignore all other @test nodes and then use run-all-unit-tests-locally. - Bind a keystroke to an @button or @command node. - Run an @button or @command node the first time from the minibuffer, and thereafter re-execute it with Ctrl-P (repeat-complex-command. Choose any way you like. What matters is being able to run your dev script with a single keystroke. *2. Define or access the code under development*There are two main ways to do this: A. Define the code as (possibly cloned) children of the dev node, and access the code using @others in the top-level node. B. Import a module. *Important*: typically your dev script will use imp.reload to ensure that imported module is up-to-date. *3. Create new instances of objects* You *must not *use existing Leo objects when testing Leo code. This includes *all* objects accessible via c, g and p, either directly or indirectly. For example, you must not use c, c.frame, c.frame.body, etc., etc., even if you have reloaded all of Leo's modules! You can, however, use any Leo code when developing *other* (unmodified) code. You will seldom need to worry about reloading code if you use @others to define the code under test. *4. Run the test, edit, repeat* After creating the dev node you simply run the dev script until everything works :-) The details depend on the code being developed. Otoh, we can safely assume that devs can handle problems as they arise. *Summary* @test, @command or @button can be thought of as defining an (almost) pristine dev environment. This is another way of describing the Stupendous Aha. Dev scripts should create a new, pristine environment every time it they are executed, using imp.reload as needed. Dev scripts should always create *new *objects for testing. Dev scripts may use Leo's core objects provided they have not been modified. SmallTalk does most of this automagically. However, dev scripts have their own advantages: - Dev scripts can access code using clones. - Dev scripts can use outlines to organize the code under development. - Dev scripts form a permanent record of completed work. - Dev scripts can morph into unit tests. - Dev scripts work for Python! Dev scripts bring most of the advantages of SmallTalk to Leo. The initial cost of creating dev nodes pays off immediately. All comments welcome. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
