Improving Pharo By Example

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

Re: Improving Pharo By Example

Damien Cassou

On Sat, May 10, 2014 at 5:01 PM, kilon alios <[hidden email]> wrote:
when I type 3 +  4 , it seems like it takes + as part of the pillar syntax and uses latex syntax and when it tries to generate the pdf it fails so I am forced now to type it as raw text like this : {{{3+4}}}

you can use eith ==3 + 4== for fixed-width font or 3 \+ 4 for normal text


--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without losing enthusiasm."
Winston Churchill
Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

kilon.alios
In reply to this post by Uko2
Thanks Damien and Yuriy


On Sat, May 10, 2014 at 6:51 PM, Yuriy Tymchuk <[hidden email]> wrote:

On 10 May 2014, at 17:01, kilon alios <[hidden email]> wrote:

I found a bug in Pillar syntax

when I type 3 +  4 , it seems like it takes + as part of the pillar syntax and uses latex syntax and when it tries to generate the pdf it fails so I am forced now to type it as raw text like this : {{{3+4}}}

It’s not a bug, it’s a feature :). I’d suggest you to use something like ==inline code== for wrapping of ‘’italic’'.


also I would like the ability to have a dark background for text like we do with smalltalk syntax .

I don’t really understand what you need. If you need to style the result, it should be done outside of pillar.

 

Pharo Tour chapters proceeds well, I compile to both latex html and pdf , I see no problems so far with my text, I copy my text directly from the latex files of the original PBE in github. 

I also improved the Readme. 


On Thu, May 8, 2014 at 9:16 AM, stepharo <[hidden email]> wrote:


I also added Chapter 1 - Quick Tour in Pharo. Just the first part , the chapter is of course still a WIP. 

I am not so sure what you mean about automated tests, are they for the example code ?


if you see in the tex when we have example we also have a tag that indicates that the code can be extracted
and run. I do not remember but oscar did a script and we where able to automatically verify that all the simple examples were correctly working with a version of Pharo.

Now in Pillar we should introduce the notion of tag to support at the word level.
    - index
    - comment
    - citation



I am all for automation. 


On Mon, May 5, 2014 at 11:08 PM, stepharo <[hidden email]> wrote:
This is really cool that people want to update the Pharo by Example book.
This is a really an important task and it will have a real impact.
You can also reduce the number of screenshots or point related to the interaction.

What would be good is to make the automated tests working again because we could spot
if we got some regressions.

Stef


How I can help improve Pharo by Example , add chapters and update current ones for Pharo 3 ?

What is the process ?







Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

kilon.alios
ok people I think I made pillar angry :D

I dont why, maybe I said something I should not have said, maybe I pushed her too much , maybe I smell too bad but since yesterday  she compiles but refuses to cooperate with me. 

In detail each time I try to use pillar syntax lets say "!! Finding classes" instead of seeing the syntax and compile to something like "1.2 Finding classes" it compiles it as it is "!! Finding classes" , it does the same thing with other pillar syntax too. 

I tried to redownload the repo , and reinstall pier and recompile from scratch again it does the same things. 

You can replicate this by  cloning the UpdatedPharoByExample github repo and just go to PharoTour.pier and add "!! Something something" and compile. The problem is evident in both the pdfs and hmtl outputs. 

Please help me make pillar friendly again, tell her I apologize and I lover her very much :) 


On Sat, May 10, 2014 at 7:09 PM, kilon alios <[hidden email]> wrote:
Thanks Damien and Yuriy


On Sat, May 10, 2014 at 6:51 PM, Yuriy Tymchuk <[hidden email]> wrote:

On 10 May 2014, at 17:01, kilon alios <[hidden email]> wrote:

I found a bug in Pillar syntax

when I type 3 +  4 , it seems like it takes + as part of the pillar syntax and uses latex syntax and when it tries to generate the pdf it fails so I am forced now to type it as raw text like this : {{{3+4}}}

It’s not a bug, it’s a feature :). I’d suggest you to use something like ==inline code== for wrapping of ‘’italic’'.


also I would like the ability to have a dark background for text like we do with smalltalk syntax .

I don’t really understand what you need. If you need to style the result, it should be done outside of pillar.

 

Pharo Tour chapters proceeds well, I compile to both latex html and pdf , I see no problems so far with my text, I copy my text directly from the latex files of the original PBE in github. 

I also improved the Readme. 


On Thu, May 8, 2014 at 9:16 AM, stepharo <[hidden email]> wrote:


I also added Chapter 1 - Quick Tour in Pharo. Just the first part , the chapter is of course still a WIP. 

I am not so sure what you mean about automated tests, are they for the example code ?


if you see in the tex when we have example we also have a tag that indicates that the code can be extracted
and run. I do not remember but oscar did a script and we where able to automatically verify that all the simple examples were correctly working with a version of Pharo.

Now in Pillar we should introduce the notion of tag to support at the word level.
    - index
    - comment
    - citation



I am all for automation. 


On Mon, May 5, 2014 at 11:08 PM, stepharo <[hidden email]> wrote:
This is really cool that people want to update the Pharo by Example book.
This is a really an important task and it will have a real impact.
You can also reduce the number of screenshots or point related to the interaction.

What would be good is to make the automated tests working again because we could spot
if we got some regressions.

Stef


How I can help improve Pharo by Example , add chapters and update current ones for Pharo 3 ?

What is the process ?








Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

Damien Cassou
On Mon, May 12, 2014 at 4:51 PM, kilon alios <[hidden email]> wrote:
> Please help me make pillar friendly again, tell her I apologize and I lover
> her very much :)


did you find a solution or do you still need help? Please send a private email

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill

Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

kilon.alios
no I did not, but I gave up cause copying from latex files is 10 times the work. I dont mind continue contributing but I have to first fix this bug , and second find an easier way to do this . If I could compile the tex file to pure text would make life easier. But first I need to solve this problem with pillar. Will message privately.


On Mon, May 19, 2014 at 6:34 PM, Damien Cassou <[hidden email]> wrote:
On Mon, May 12, 2014 at 4:51 PM, kilon alios <[hidden email]> wrote:
> Please help me make pillar friendly again, tell her I apologize and I lover
> her very much :)


did you find a solution or do you still need help? Please send a private email

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill


Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

kilon.alios
In reply to this post by Damien Cassou
In section 1.9  page 18 there is this text

"At other times you may have a good idea that a method exists, but will have no idea what it might be called. The method finder can still help! For example, suppose that you would like to find a method that turns a string into upper case, for example, it would translate 'eureka' into 'EUREKA'.

The method finder will suggest a method that does what you want.8

An asterisk at the beginning of a line in the right pane of the method finder indicates that this method is the one that was actually used to obtain the requested result. So, the asterisk in front of String asUppercase lets us know that the method asUppercase defined on the class String was executed and returned the result we wanted. The methods that do not have an asterisk are just the other methods that have the same name as the ones that returned the expected result. So Character»asUppercase was not executed on our example, because 'eureka' is not a Character object.

You can also use the method finder for methods with arguments; for example, if you are looking for a method that will find the greatest common factor of two integers, you might try 25. 35. 5 as an example. You can also give the method finder multiple examples to narrow the search space; the help text in the bottom pane explains how. "

I tried " 'eureka' . 'EUREKA '" and the other suggestion it does not seem to work , should I remove this section ? 





On Tue, May 20, 2014 at 12:17 AM, kilon alios <[hidden email]> wrote:
thanks Damien 


On Tue, May 20, 2014 at 12:10 AM, Damien Cassou <[hidden email]> wrote:
A quick tour of
quick

In this chapter we will give you a high-level tour of to help you get
comfortable with the environment.
There will be plenty of opportunities to try things out, so it would
be a good idea if you have a computer handy when you read this
chapter.

We will use this icon:  to mark places in the text where you should
try something out in .
In particular, you will fire up , learn about the different ways of
interacting with the system, and discover some of the basic tools.
You will also learn how to define a new method, create an object and
send it messages.


Getting started

is available as a free download from .
There are three parts that you will need to download, consisting of
four files (see download).








  The virtual machine (VM) is the only part of the system that is
different for each operating system and processor.  Pre-compiled
virtual machines are available for all the major computing
environments.  In download we see the VM for the selected platform is
called Pharo.exe.

  The sources file contains the source code for all of the parts of
that don't change very frequently. In download it is called
SqueakV39.sources.

  The current system image is a snapshot of a running system, frozen
in time.  It consists of two files: an .image file, which contains the
state of all of the objects in the system (including classes and
methods, since they are objects too), and a .changes file, which
contains a log of all of the changes to the source code of the system.
In download, these files are called pharo.image and pharo.changes.


Download and install on your computer.
We recommend that you use the image provided on the by Example web page.

sbeImage

Most of the introductory material in this book will work with any
version, so if you already have one installed, you may as well
continue to use it.
However, if you notice differences between the appearance or behaviour
of your system and what is described here, do not be surprised.


As you work in , the image and changes files are modified, so you need
to make sure that they are writable.
Always keep these two files together.
Never edit them directly with a text editor, as uses them to store the
objects you work with and to log the changes you make to the source
code.
It is a good idea to keep a backup copy of the downloaded image and
changes files so you can always start from a fresh image and reload
your code.

The sources file and the VM can be read-only---they can be shared
between different users.
All of these files can be placed in the same directory, but it is also
possible to put the Virtual Machine and sources file in separate
directory where everyone has access to them.
Do whatever works best for your style of working and your operating system.












Launching. To start , do whatever your operating system expects: drag
the .image file onto the icon of the virtual machine, or double-click
the .image file, or  at the command line type the name of the virtual
machine followed by the path to the .image file. (When you have
multiple VMs installed on your machine the operating system may not
automatically pick the right one; in this case it is safer to drag and
drop the image onto the virtual machine, or to use the command line.)

Once is running, you should see a single large window, possibly
containing some open workspace windows (see startup), and it's not
obvious how to proceed!
You might notice a menu bar, but mainly makes use of context-dependent
pop-up menus.



Start . You can dismiss any open workspaces by ing on the red button
in the top left corner of the workspace window.

You can minimize windows (so that they move to the dock on the bottom
of the screen) by ing on the orange button.  Clicking on the green
button will cause the window to take up the entire screen.


First Interaction.

A good place to get started is the world menu shown in threeButtons:click.

Click with the mouse on the background of the main window to show the
world menu, then choose Workspace to create a new workspace.






















morphic haloMorphic












was originally designed for a computer with a three button mouse.  If
your mouse has fewer than three buttons, you will have to press extra
keys while ing the mouse to simulate the extra buttons.  A two-button
mouse works quite well with , but if you have only a single-button
mouse, you should seriously consider buying a two-button mouse with a
clickable scroll wheel: it will make working with much more pleasant.

avoids terms like ``left mouse click'' because different computers,
mice, keyboards and personal configurations mean that different users
will need to press different physical buttons to achieve the same
effect.
Originally introduced colours to stand for the different mouse buttons.



Since many users will use various modifiers keys (control, ALT, meta )
to achieve the same effect, we will instead use the following terms:

[:] this is the most often used mouse button, and is normally
equivalent to ing a single-mouse button without any modifier key;  on
the image to bring up the ``World'' menu (threeButtons:click).
[:] this is the next most used button; it is used to bring up a
contextual menu, that is, a menu that offers different sets of actions
depending on where the mouse is pointing; see threeButtons:actclick.
If you do not have a multi-button mouse, then normally you will
configure the control modifier key to with the mouse button.
[:] Finally, you may on any object displayed in the image to activate
the ``morphic Morphichalo'', an array of handles that are used to
perform operations on the on-screen objects themselves, such as
rotating them or resizing them; see threeButtons:metaclick.
If you let the mouse linger over a handle, a help balloon will explain
its function.
In , how you depends on your operating system:
either you must hold shift ctrl or shift option while clicking.




Type Time now in the workspace.
Now in the workspace.
Select print it.













We recommend that right-handed people configure their mouse to with
the left button, with the right button, and with the  clickable scroll
wheel, if one is available.


If you are using a Macintosh without a second mouse button, you can
simulate one by holding down the  key while ing the mouse.  However,
if you are going to be using at all often, we recommend investing in a
mouse with at least two buttons.

You can configure your mouse to work the way you want by using the
preferences of your operating system and mouse driver.
How can I get meta-click without a three-finger salute?  Is this a secret?
has some preferences for customising the mouse and the meta keys on
your keyboard.
In the preference browser (System  Preferences  Preference Browser),
the keyboard category contains an option swapControlAndAltKeys that
switches the and functions.
There are also options to duplicate the various command keys.








The World menu


again on the background.
You will see the World menu again.
Most menus are not modal; you can leave them on the screen for as long
as you wish by ing the push pin icon in the top-right corner. Do this.


The world menu provides you a simple means to access many of the tools
that offers.

Have a closer look at the World and Tools  menus. (threeButtons:click)

You will see a list of several of the core tools in , including the
browser and the workspace.
We will encounter most of them in the coming chapters.


Sending messages

Open a workspace. Type in the following text:


BouncingAtomsMorph new openInWorld


Now . A menu should appear. Select do it (d). (See doit.)






A window containing a large number of bouncing atoms should open in
the top left of the image.

You have just evaluated your first expression!
You just sent the message new to the class, resulting in a new
instance, followed by the message openInWorld to this instance.
The class decided what to do with the new message, that is, it looked
up its methods for handling new message and reacted appropriately.
Similarly the instance looked up its method for responding to
openInWorld and took appropriate action.

If you talk to Smalltalkers for a while, you will quickly notice that
they generally do not use expressions like ``call an operation'' or
``invoke a method'', but instead they will say ``send a message''.
This reflects the idea that objects are responsible for their own actions.
You never tell an object what to do---instead you politely ask it to
do something by sending it a message.
The object, not you, selects the appropriate method for responding to
your message.


Saving, quitting and restarting a session

Now on the bouncing atoms window and drag it anywhere you like. You
now have the demo ``in hand''. Put it down by ing anywhere.













Select WorldSave as , enter the name ``myPharo'', and on the OK button.
Now select WorldSave and quit.

Now if you go to the location where the original image and changes
files were, you will find two new files called ``myPharo.image'' and
``myPharo.changes'' that represent the working state of the image at
the moment before you told to Save and quit.
If you wish, you can move these two files anywhere that you like on
your disk, but if you do so you may (depending on your operating
system) need to also move, copy or link to the virtual machine and the
sources file.

Start up from the newly created ``myPharo.image'' file.

Now you should find yourself in precisely the state you were when you
quit . The is there again and the atoms continue to bounce from where
they were when you quit.

When you start for the first time, the virtual machine loads the image
file that you provide. This file contains a snapshot of a large number
of objects, including a vast amount of pre-existing code and a large
number of programming tools (all of which are objects). As you work
with , you will send messages to these objects, you will create new
objects, and some of these objects will die and their memory will be
reclaimed (garbage-collected).

When you quit , you will normally save a snapshot that contains all of
your objects.  If you save normally, you will overwrite your old image
file with the new snapshot. Alternatively, you may save the image
under a new name, as we just did.

In addition to the .image file, there is also a .changes file.
This file contains a log of all the changes to the source code that
you have made using the standard tools.
Most of the time you do not need to worry about this file at all.
As we shall see, however, the .changes file can be very useful for
recovering from errors, or replaying lost changes.
More about this later!

The image that you have been working with is a descendant of the
original image created in the late 1970s.
Some of these objects have been around for decades!

You might think that the image is the key mechanism for storing and
managing software projects, but you would be wrong.
As we shall see very soon, there are much better tools for managing
code and sharing software developed by teams.
Images are very useful, but you should learn to be very cavalier about
creating and throwing away images, since tools like Monticello offer
much better ways to manage versions and share code amongst developers.

Using the mouse (and the appropriate modifier keys), on the .
You will see a collection of colored circles that are collectively
called the morphic Morphichalo.
Each circle is called a handle.
Click in the pink handle containing the cross; the should go away.


Workspaces and Transcripts
transcript

Close all open windows. Open a transcript and a workspace. (The
transcript can be opened from the WorldTools ... submenu.)

Position and resize the transcript and workspace windows so that the
workspace just overlaps the transcript.
You can resize windows either by dragging one of the corners, or by
ing the window to bring up the morphic halo, and dragging the yellow
(bottom right) handle.

At any time only one window is active; it is in front and has its
border highlighted.


The transcript is an object that is often used for logging system messages.
It is a kind of ``system console''.




Workspaces are useful for typing snippets of code that you would like
to experiment with.
You can also use workspaces simply for typing arbitrarily text that
you would like to remember, such as to-do lists or instructions for
anyone who will use your image.
Workspaces are often used to hold documentation about a captured
image, as is the case with the standard image that we downloaded
earlier (see startup).

Type the following text into the workspace:

Transcript show: 'hello world'; cr.


Try double-ing in the workspace at various points in the text you have
just typed.
Notice how an entire word, entire string, or the whole text is
selected, depending on whether you within a word, at the end of the
string, or at the end of the entire expression.

Select the text you have typed and .
Select do it (d).
Notice how the text ``hello world'' appears in the transcript window
(helloworld).
Do it again.
(The (d) in the menu item do it (d) tells you that the keyboard
shortcut to do it is d. More on this in the next section!)







Keyboard shortcuts

If you want  to evaluate an expression, you do not always have to .
Instead, you can use keyboard shortcuts. These are the parenthesized
expressions in the menu.  Depending on your platform, you may have to
press one of the modifier keys (control, alt, command, or meta).
(We will indicate these generically as key.)

Evaluate the expression in the workspace again, but using the keyboard
shortcut: d.


In addition to do it, you will have noticed print it, inspect it and
explore it. Let's have a quick look at each of these.

Type the expression 3 + 4 into the workspace. Now do it with the
keyboard shortcut.

Do not be surprised if you saw nothing happen! What you just did is
send the message + with argument 4 to the number 3. Normally the
result 7 will have been computed and returned to you, but since the
workspace did not know what to do with this answer, it simply threw
the answer away.  If you want to see the result, you should print it
instead. print it actually compiles the expression, executes it, sends
the message printString to the result, and displays the resulting
string.

Select 3+4 and print it (p).
This time we see the result we expect (printit).








3
@TEST
3 + 4 --> 7


We use the notation --> as a convention in this book to indicate that
a particular expression yields a given result when you print it.

Delete the highlighted text ``7'' (should have selected it for you, so
you can just press the delete key). Select 3+4 again and this time
inspect it (i).

Now you should see a new window, called an inspector, with the heading
SmallInteger: 7 (inspectit).
The inspector is an extremely useful tool that will allow you to
browse and interact with any object in the system.
The title tells us that 7 is an instance of the class SmallInteger.
The left panel allows us to browse the instance variables of an
object, the values of which are shown in the right panel.
The bottom panel can be used to write expressions to send messages to
the object.






Type self squared in the bottom panel of the inspector on 7 and print it.

2
Close the inspector. Type the expression Object in a workspace and
this time explore it (I, uppercased i).



This time you should see a window labelled Object containing the text
 root: Object.
Click on the triangle to open it up (exploreit).






The explorer is similar to the inspector, but it offers a tree view of
a complex object.
In this case the object we are looking at is the Object class.
We can see directly all the information stored in this class, and we
can easily navigate to all its parts.


The Class Browser

The class browser
 is one of the key tools used for programming.
As we shall see, there are several interesting browsers available for
, but this is the basic one you will find in any image.
class browserbrowser

Open a browser by selecting World Class browser.









We can see a browser in classBrowser.
The title bar indicates that we are browsing the class Object.


When the browser first opens, all panes are empty but the leftmost one.
This first pane lists all known packages, which contain groups of
related classes.


Click on the Kernel package.
This causes the second pane to show a list of all of the classes in
the selected package.

Select the class Object.
Now the remaining two panes will be filled with text.
The third pane displays the protocols of the currently selected class.
These are convenient groupings of related methods.
If no protocol is selected you should see all methods in the fourth pane.

Select the printing protocol.
You may have to scroll down to find it.
Now you will see in the fourth pane only methods related to printing.

Select the ObjectprintString method.
Now we see in the bottom pane the source code of the printString
method, shared by all objects in the system (except those that
override it).


Finding classes

There are several ways to find a class in .  The first, as we have
just seen above, is to know (or guess) what category it is in, and to
navigate to it using the browser.

browser!finding classesclass, finding


A second way is to send the browse message to the class, asking it to
open a browser on itself.  Suppose we want to browse the class
Boolean.

Type Boolean browse into a workspace and do it.
A browser will open on the Boolean class (browseBoolean).
There is also a keyboard shortcut b (browse) that you can use in any
tool where you find a class name;

select the name and type b.

Use the keyboard shortcut to browse the class Boolean.







Notice that when the Boolean class is selected but no protocol or
method is selected, instead of the source code of a method, we see a
class definition (browseBoolean).
This is nothing more than an ordinary message that is sent to the
parent class, asking it to create a subclass.
Here we see that the class Object is being asked to create a subclass
named Boolean with no instance variables, class variables or ``pool
dictionaries'', and to put the class Boolean in the Kernel-Objects
category.

If you on the ? at the bottom of the class pane, you can see the class
classcomment in a dedicated pane (see classComment).







Often, the fastest way to find a class is to search for it by name.
For example, suppose that you are looking for some unknown class that
represents dates and times.

Put the mouse in the package pane of the browser and type f, or select
find class (f) by ing.  Type ``time'' in the dialog box and accept it.

You will be presented with a list of classes whose names contain
``time'' (see findit).  Choose one, say, Time, and the browser will
show it, along with a class comment that suggests other classes that
might be useful.  If you want to browse one of the others, select its
name (in any text pane), and type b.













Note that if you type the complete (and correctly capitalized) name of
a class in the find dialog, the browser will go directly to that class
without showing you the list of options.


Finding methods
quick:methodFinder

Sometimes you can guess the name of a method, or at least part of the
name of a method, more easily than the name of a class.  For example,
if you are interested in the current time, you might expect that there
would be a method called ``now'', or containing ``now'' as a
substring.   But where might it be?
The method finder can help you.
browser!finding methodsmethod, finding


Select World Tools ... Method finder.
Type ``now'' in the top left pane, and accept it (or just press the return key).
The method finder will display a list of all the method names that
contain the substring ``now''.
To scroll to now itself, move the cursor to the list and type ``n'';
this trick works in all scrolling windows.  Select ``now'' and the
right-hand pane shows you the classes that define a method with this
name, as shown in MethodFinder.  Selecting any one of them will open a
browser on it.







At other times you may have a good idea that a method exists, but will
have no idea what it might be called.
The method finder can still help!  For example, suppose that you would
like to find a method that turns a string into upper case, for
example, it would translate 'eureka' into 'EUREKA'.

Type 'eureka' . 'EUREKA' into the method finder and press
  the return key, as shown in
  methodFinder-example1.

The method finder will suggest a method that does what you want.

An asterisk at the beginning of a line in the right pane of the method
finder indicates that this method is the one that was actually used to
obtain the requested result.
So, the asterisk in front of String asUppercase lets us know that the
method StringasUppercase defined on the class String was executed and
returned the result we wanted. The methods that do not have an
asterisk are just the other methods that have the same name as the
ones that returned the expected result. So CharacterasUppercase was
not executed on our example, because 'eureka' is not a Character
object.







You can also use the method finder for methods with arguments; for
example, if you are looking for a method that will find the greatest
common factor of two integers, you might try 25. 35. 5 as an example.
You can also give the method finder multiple examples to narrow the
search space; the help text in the bottom pane explains how.


Defining a new method

The advent of Test Driven Development (TDD) has changed the way that
we write code.
The idea behind TDD is that we write a test that defines the desired
behaviour of our code before we write the code itself.
Only then do we write the code that satisfies the test.
Behavior Driven DevelopmentTest Driven Development


Suppose that our assignment is to write a method that ``says something
loudly and with emphasis''.  What exactly could that mean?  What would
be a good name for such a method?  How can we make sure  that
programmers who may have to maintain our method in the future have an
unambiguous description of what it should do?   We can answer all of
these questions by giving an example:


When we send the message shout to the string ``Don't panic'' the
result should be ``DON'T PANIC!''.



To make this example into something that the system can use, we turn
it into a test method:



3
[testShout]A test for a shout method
testShout
    self assert: ('Don''t panic' shout = 'DON''T PANICBANG')


How do we create a new method in ?   First, we have to decide which
class the method should belong to.
In this case, the shout method that we are testing will go in class
String, so the corresponding test will, by convention, go in a class
called StringTest.







Open a browser on the class StringTest, and select an appropriate
protocol for our method, in this case tests - converting, as shown in
newMethodTemplate.
The highlighted text in the bottom pane is a template that reminds you
what a method looks like.
Delete this and enter the code from  testShout.
Once you have typed the text into the browser, notice that the bottom
pane is outlined in red.  This is a reminder that the pane contains
unsaved changes.
So select accept (s) by ing in the bottom pane, or just type s, to
compile and save your method.


accept itkeyboard shortcut, accept

If this is the first time you have accepted any code in your image,
you will likely be prompted to enter your name. Since many people have
contributed code to the image, it is important to keep track of
everyone who creates or modifies methods. Simply enter your first and
last names, without any spaces, or separated by a dot.







Because there is as yet no method called shout, the browser will ask
you to confirm that this is the name that you really want---and it
will suggest some other names that you might have intended
(testShoutConfirm).
This can be quite useful if you have merely made a typing mistake, but
in this case, we really do mean shout, since that is the method we are
about to create, so we have to confirm this by selecting the first
option from the menu of choices, as shown in testShoutConfirm.

































Run your newly created test: open the SUnit TestRunner from the World menu.

The leftmost two panes are a bit like the top panes in the browser.
The left pane contains a list of categories, but it's restricted to
those categories that contain test classes.

Select CollectionsTests-Text and the pane to the right will show all
of the test classes in that category, which includes the class
StringTest.  The names of the classes are already selected, so Run
Selected to run all these tests.







You should see a message like that shown in testRunnerTestShout, which
indicates that there was an error in running the tests.  The list of
tests that gave rise to errors is shown in the bottom right pane; as
you can see, StringTest>>>#testShout is the culprit.
(Note that StringTest>>>#testShout is the Smalltalk convention to
identify the StringTesttestShout method of the StringTest class.)
If you on that line of text, the erroneous test will run again, this
time in such a way that you see the error happen:
``MessageNotUnderstood: ByteString>>>shout''.
>>Behavior, >>
Behavior>>

The window that opens with the error message is the debugger (see predebugger).

We will look at the debugger and how to use it in env.







The error is, of course, exactly what we expected:  running the test
generates an error because we haven't yet written a method that tells
strings how to shout.
Nevertheless, it's good practice to make sure that the test fails
because this confirms that we have set up the testing machinery
correctly and that the new test is actually being run.
Once you have seen the error, you can Abandon the running test, which
will close the debugger window.
Note that often with Smalltalk you can define the missing method using
the Create button, edit the newly-created method in the debugger, and
then Proceed with the test.

Now let's define the method that will make the test succeed!

Select class String in the browser, select the converting protocol,
type the text in shout over the method creation template, and accept
it.
(Note: to get a ^, type ).
[shout]The shout method
shout
    ^ self asUppercase, 'BANG'


The comma is the string concatenation operation, so the body of this
method appends an exclamation mark to an upper-case version of
whatever String object the shout message was sent to.
The  tells that the expression that follows is the answer to be
returned from the method, in this case the new concatenated string.
commaCollection, comma operator


Does this method work?  Let's run the tests and see.

Click on Run Selected again in the test runner, and this time you
should see a green bar and text indicating that all of the tests ran
with no failures and no errors.
When you get to a green bar, it's a good idea to save your work and
take a break.
So do that right now!














Chapter summary
This chapter has introduced you to the environment and shown you how
to use some of the major tools, such as the browser, the method
finder, and the test runner.   You have also seen a little of syntax,
even though you may not understand it all yet.


  A running system consists of a virtual machine, a sources file, and
image and changes files. Only these last two change, as they record a
snapshot of the running system.
  When you restore a image, you will find yourself in exactly the same
state---with the same running objects---that you had when you last
saved that image.
  is designed to work with a three-button mouse to , or .  If you
don't have a three-button mouse, you can use modifier keys to obtain
the same effect.
  You on the background to bring up the World menu and launch various tools.
  A workspace is a tool for writing and evaluating snippets of code.
You can also use it to store arbitrary text.
  You can use keyboard shortcuts on text in the workspace, or any
other tool, to evaluate code. The most important of these are do it
(d), print it (p), inspect it (i), explore it (I) and browse it (b).

  The browser is the main tool for browsing code, and for developing new code.
  The test runner is a tool for running unit tests. It also supports
Test Driven Development.




   jurabib
   scg








On Mon, May 19, 2014 at 10:11 PM, Damien Cassou <[hidden email]> wrote:
> On Mon, May 19, 2014 at 10:07 PM, kilon alios <[hidden email]> wrote:
>> hmm ok, is that normal ?
>
>
> the parser is waiting for the closing pair and don't emit anything
> before it finds it. I could do better but I would need to spend more
> time on the parser than I have right now.
>
>
>> I did not expect this kind of behaviour. I will have to be more careful from
>> here on. Thanks.
>>
>> Is there a way to obtain plain text from the tex file ? Dont care about
>> formated text etc, just something that will be easy to copy paste because I
>> cant paste from pdf and pasting from tex files is a huge pain cause I have
>> to remove all the text syntax.
>
> what about this?
> http://stackoverflow.com/questions/829408/extract-text-from-tex-remove-latex-tags
>
>
> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm."
> Winston Churchill



--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill


Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

kilon.alios
hey guys I just finished the Pharo Tour Chapter.  I will give it another read the next few days , but so far it looks ok. The pdf renders without any issues. 

So I think I have figured out the process of copying from PDFs, I think I understand now what PDF breaks. Looking into the tex file definetly helps out to find exactly what went wrong. I also think I have started understanding the latex syntax. 

It looks like there some unicodes the tex allows to, but none the less I decided to remove them all and replace them with regular ascii characters to make sure it does not create any problem at all. Though those unicodes did not brake the PDF creation. 

So from now on the plan is to slow down a bit, I will do 1 page per day with the goal of 1 Chapter per month. It should not take me more than 10 minutes per page (if pdf copy paste behaves I could do this even in 1 mimute) so I think its ideal for me. I will continue contributing since its so easy and hopefully finish the book in a year or so if I don't give up in the mean time. 

Make sure you give a read and report back any problems. Also please take a look at the problem I reported earlier on, documenting things that the viewer cannot verify is not good.  



On Wed, May 21, 2014 at 9:48 PM, kilon alios <[hidden email]> wrote:
In section 1.9  page 18 there is this text

"At other times you may have a good idea that a method exists, but will have no idea what it might be called. The method finder can still help! For example, suppose that you would like to find a method that turns a string into upper case, for example, it would translate 'eureka' into 'EUREKA'.

The method finder will suggest a method that does what you want.8

An asterisk at the beginning of a line in the right pane of the method finder indicates that this method is the one that was actually used to obtain the requested result. So, the asterisk in front of String asUppercase lets us know that the method asUppercase defined on the class String was executed and returned the result we wanted. The methods that do not have an asterisk are just the other methods that have the same name as the ones that returned the expected result. So Character»asUppercase was not executed on our example, because 'eureka' is not a Character object.

You can also use the method finder for methods with arguments; for example, if you are looking for a method that will find the greatest common factor of two integers, you might try 25. 35. 5 as an example. You can also give the method finder multiple examples to narrow the search space; the help text in the bottom pane explains how. "

I tried " 'eureka' . 'EUREKA '" and the other suggestion it does not seem to work , should I remove this section ? 





On Tue, May 20, 2014 at 12:17 AM, kilon alios <[hidden email]> wrote:
thanks Damien 


On Tue, May 20, 2014 at 12:10 AM, Damien Cassou <[hidden email]> wrote:
A quick tour of
quick

In this chapter we will give you a high-level tour of to help you get
comfortable with the environment.
There will be plenty of opportunities to try things out, so it would
be a good idea if you have a computer handy when you read this
chapter.

We will use this icon:  to mark places in the text where you should
try something out in .
In particular, you will fire up , learn about the different ways of
interacting with the system, and discover some of the basic tools.
You will also learn how to define a new method, create an object and
send it messages.


Getting started

is available as a free download from .
There are three parts that you will need to download, consisting of
four files (see download).








  The virtual machine (VM) is the only part of the system that is
different for each operating system and processor.  Pre-compiled
virtual machines are available for all the major computing
environments.  In download we see the VM for the selected platform is
called Pharo.exe.

  The sources file contains the source code for all of the parts of
that don't change very frequently. In download it is called
SqueakV39.sources.

  The current system image is a snapshot of a running system, frozen
in time.  It consists of two files: an .image file, which contains the
state of all of the objects in the system (including classes and
methods, since they are objects too), and a .changes file, which
contains a log of all of the changes to the source code of the system.
In download, these files are called pharo.image and pharo.changes.


Download and install on your computer.
We recommend that you use the image provided on the by Example web page.

sbeImage

Most of the introductory material in this book will work with any
version, so if you already have one installed, you may as well
continue to use it.
However, if you notice differences between the appearance or behaviour
of your system and what is described here, do not be surprised.


As you work in , the image and changes files are modified, so you need
to make sure that they are writable.
Always keep these two files together.
Never edit them directly with a text editor, as uses them to store the
objects you work with and to log the changes you make to the source
code.
It is a good idea to keep a backup copy of the downloaded image and
changes files so you can always start from a fresh image and reload
your code.

The sources file and the VM can be read-only---they can be shared
between different users.
All of these files can be placed in the same directory, but it is also
possible to put the Virtual Machine and sources file in separate
directory where everyone has access to them.
Do whatever works best for your style of working and your operating system.












Launching. To start , do whatever your operating system expects: drag
the .image file onto the icon of the virtual machine, or double-click
the .image file, or  at the command line type the name of the virtual
machine followed by the path to the .image file. (When you have
multiple VMs installed on your machine the operating system may not
automatically pick the right one; in this case it is safer to drag and
drop the image onto the virtual machine, or to use the command line.)

Once is running, you should see a single large window, possibly
containing some open workspace windows (see startup), and it's not
obvious how to proceed!
You might notice a menu bar, but mainly makes use of context-dependent
pop-up menus.



Start . You can dismiss any open workspaces by ing on the red button
in the top left corner of the workspace window.

You can minimize windows (so that they move to the dock on the bottom
of the screen) by ing on the orange button.  Clicking on the green
button will cause the window to take up the entire screen.


First Interaction.

A good place to get started is the world menu shown in threeButtons:click.

Click with the mouse on the background of the main window to show the
world menu, then choose Workspace to create a new workspace.






















morphic haloMorphic












was originally designed for a computer with a three button mouse.  If
your mouse has fewer than three buttons, you will have to press extra
keys while ing the mouse to simulate the extra buttons.  A two-button
mouse works quite well with , but if you have only a single-button
mouse, you should seriously consider buying a two-button mouse with a
clickable scroll wheel: it will make working with much more pleasant.

avoids terms like ``left mouse click'' because different computers,
mice, keyboards and personal configurations mean that different users
will need to press different physical buttons to achieve the same
effect.
Originally introduced colours to stand for the different mouse buttons.



Since many users will use various modifiers keys (control, ALT, meta )
to achieve the same effect, we will instead use the following terms:

[:] this is the most often used mouse button, and is normally
equivalent to ing a single-mouse button without any modifier key;  on
the image to bring up the ``World'' menu (threeButtons:click).
[:] this is the next most used button; it is used to bring up a
contextual menu, that is, a menu that offers different sets of actions
depending on where the mouse is pointing; see threeButtons:actclick.
If you do not have a multi-button mouse, then normally you will
configure the control modifier key to with the mouse button.
[:] Finally, you may on any object displayed in the image to activate
the ``morphic Morphichalo'', an array of handles that are used to
perform operations on the on-screen objects themselves, such as
rotating them or resizing them; see threeButtons:metaclick.
If you let the mouse linger over a handle, a help balloon will explain
its function.
In , how you depends on your operating system:
either you must hold shift ctrl or shift option while clicking.




Type Time now in the workspace.
Now in the workspace.
Select print it.













We recommend that right-handed people configure their mouse to with
the left button, with the right button, and with the  clickable scroll
wheel, if one is available.


If you are using a Macintosh without a second mouse button, you can
simulate one by holding down the  key while ing the mouse.  However,
if you are going to be using at all often, we recommend investing in a
mouse with at least two buttons.

You can configure your mouse to work the way you want by using the
preferences of your operating system and mouse driver.
How can I get meta-click without a three-finger salute?  Is this a secret?
has some preferences for customising the mouse and the meta keys on
your keyboard.
In the preference browser (System  Preferences  Preference Browser),
the keyboard category contains an option swapControlAndAltKeys that
switches the and functions.
There are also options to duplicate the various command keys.








The World menu


again on the background.
You will see the World menu again.
Most menus are not modal; you can leave them on the screen for as long
as you wish by ing the push pin icon in the top-right corner. Do this.


The world menu provides you a simple means to access many of the tools
that offers.

Have a closer look at the World and Tools  menus. (threeButtons:click)

You will see a list of several of the core tools in , including the
browser and the workspace.
We will encounter most of them in the coming chapters.


Sending messages

Open a workspace. Type in the following text:


BouncingAtomsMorph new openInWorld


Now . A menu should appear. Select do it (d). (See doit.)






A window containing a large number of bouncing atoms should open in
the top left of the image.

You have just evaluated your first expression!
You just sent the message new to the class, resulting in a new
instance, followed by the message openInWorld to this instance.
The class decided what to do with the new message, that is, it looked
up its methods for handling new message and reacted appropriately.
Similarly the instance looked up its method for responding to
openInWorld and took appropriate action.

If you talk to Smalltalkers for a while, you will quickly notice that
they generally do not use expressions like ``call an operation'' or
``invoke a method'', but instead they will say ``send a message''.
This reflects the idea that objects are responsible for their own actions.
You never tell an object what to do---instead you politely ask it to
do something by sending it a message.
The object, not you, selects the appropriate method for responding to
your message.


Saving, quitting and restarting a session

Now on the bouncing atoms window and drag it anywhere you like. You
now have the demo ``in hand''. Put it down by ing anywhere.













Select WorldSave as , enter the name ``myPharo'', and on the OK button.
Now select WorldSave and quit.

Now if you go to the location where the original image and changes
files were, you will find two new files called ``myPharo.image'' and
``myPharo.changes'' that represent the working state of the image at
the moment before you told to Save and quit.
If you wish, you can move these two files anywhere that you like on
your disk, but if you do so you may (depending on your operating
system) need to also move, copy or link to the virtual machine and the
sources file.

Start up from the newly created ``myPharo.image'' file.

Now you should find yourself in precisely the state you were when you
quit . The is there again and the atoms continue to bounce from where
they were when you quit.

When you start for the first time, the virtual machine loads the image
file that you provide. This file contains a snapshot of a large number
of objects, including a vast amount of pre-existing code and a large
number of programming tools (all of which are objects). As you work
with , you will send messages to these objects, you will create new
objects, and some of these objects will die and their memory will be
reclaimed (garbage-collected).

When you quit , you will normally save a snapshot that contains all of
your objects.  If you save normally, you will overwrite your old image
file with the new snapshot. Alternatively, you may save the image
under a new name, as we just did.

In addition to the .image file, there is also a .changes file.
This file contains a log of all the changes to the source code that
you have made using the standard tools.
Most of the time you do not need to worry about this file at all.
As we shall see, however, the .changes file can be very useful for
recovering from errors, or replaying lost changes.
More about this later!

The image that you have been working with is a descendant of the
original image created in the late 1970s.
Some of these objects have been around for decades!

You might think that the image is the key mechanism for storing and
managing software projects, but you would be wrong.
As we shall see very soon, there are much better tools for managing
code and sharing software developed by teams.
Images are very useful, but you should learn to be very cavalier about
creating and throwing away images, since tools like Monticello offer
much better ways to manage versions and share code amongst developers.

Using the mouse (and the appropriate modifier keys), on the .
You will see a collection of colored circles that are collectively
called the morphic Morphichalo.
Each circle is called a handle.
Click in the pink handle containing the cross; the should go away.


Workspaces and Transcripts
transcript

Close all open windows. Open a transcript and a workspace. (The
transcript can be opened from the WorldTools ... submenu.)

Position and resize the transcript and workspace windows so that the
workspace just overlaps the transcript.
You can resize windows either by dragging one of the corners, or by
ing the window to bring up the morphic halo, and dragging the yellow
(bottom right) handle.

At any time only one window is active; it is in front and has its
border highlighted.


The transcript is an object that is often used for logging system messages.
It is a kind of ``system console''.




Workspaces are useful for typing snippets of code that you would like
to experiment with.
You can also use workspaces simply for typing arbitrarily text that
you would like to remember, such as to-do lists or instructions for
anyone who will use your image.
Workspaces are often used to hold documentation about a captured
image, as is the case with the standard image that we downloaded
earlier (see startup).

Type the following text into the workspace:

Transcript show: 'hello world'; cr.


Try double-ing in the workspace at various points in the text you have
just typed.
Notice how an entire word, entire string, or the whole text is
selected, depending on whether you within a word, at the end of the
string, or at the end of the entire expression.

Select the text you have typed and .
Select do it (d).
Notice how the text ``hello world'' appears in the transcript window
(helloworld).
Do it again.
(The (d) in the menu item do it (d) tells you that the keyboard
shortcut to do it is d. More on this in the next section!)







Keyboard shortcuts

If you want  to evaluate an expression, you do not always have to .
Instead, you can use keyboard shortcuts. These are the parenthesized
expressions in the menu.  Depending on your platform, you may have to
press one of the modifier keys (control, alt, command, or meta).
(We will indicate these generically as key.)

Evaluate the expression in the workspace again, but using the keyboard
shortcut: d.


In addition to do it, you will have noticed print it, inspect it and
explore it. Let's have a quick look at each of these.

Type the expression 3 + 4 into the workspace. Now do it with the
keyboard shortcut.

Do not be surprised if you saw nothing happen! What you just did is
send the message + with argument 4 to the number 3. Normally the
result 7 will have been computed and returned to you, but since the
workspace did not know what to do with this answer, it simply threw
the answer away.  If you want to see the result, you should print it
instead. print it actually compiles the expression, executes it, sends
the message printString to the result, and displays the resulting
string.

Select 3+4 and print it (p).
This time we see the result we expect (printit).








3
@TEST
3 + 4 --> 7


We use the notation --> as a convention in this book to indicate that
a particular expression yields a given result when you print it.

Delete the highlighted text ``7'' (should have selected it for you, so
you can just press the delete key). Select 3+4 again and this time
inspect it (i).

Now you should see a new window, called an inspector, with the heading
SmallInteger: 7 (inspectit).
The inspector is an extremely useful tool that will allow you to
browse and interact with any object in the system.
The title tells us that 7 is an instance of the class SmallInteger.
The left panel allows us to browse the instance variables of an
object, the values of which are shown in the right panel.
The bottom panel can be used to write expressions to send messages to
the object.






Type self squared in the bottom panel of the inspector on 7 and print it.

2
Close the inspector. Type the expression Object in a workspace and
this time explore it (I, uppercased i).



This time you should see a window labelled Object containing the text
 root: Object.
Click on the triangle to open it up (exploreit).






The explorer is similar to the inspector, but it offers a tree view of
a complex object.
In this case the object we are looking at is the Object class.
We can see directly all the information stored in this class, and we
can easily navigate to all its parts.


The Class Browser

The class browser
 is one of the key tools used for programming.
As we shall see, there are several interesting browsers available for
, but this is the basic one you will find in any image.
class browserbrowser

Open a browser by selecting World Class browser.









We can see a browser in classBrowser.
The title bar indicates that we are browsing the class Object.


When the browser first opens, all panes are empty but the leftmost one.
This first pane lists all known packages, which contain groups of
related classes.


Click on the Kernel package.
This causes the second pane to show a list of all of the classes in
the selected package.

Select the class Object.
Now the remaining two panes will be filled with text.
The third pane displays the protocols of the currently selected class.
These are convenient groupings of related methods.
If no protocol is selected you should see all methods in the fourth pane.

Select the printing protocol.
You may have to scroll down to find it.
Now you will see in the fourth pane only methods related to printing.

Select the ObjectprintString method.
Now we see in the bottom pane the source code of the printString
method, shared by all objects in the system (except those that
override it).


Finding classes

There are several ways to find a class in .  The first, as we have
just seen above, is to know (or guess) what category it is in, and to
navigate to it using the browser.

browser!finding classesclass, finding


A second way is to send the browse message to the class, asking it to
open a browser on itself.  Suppose we want to browse the class
Boolean.

Type Boolean browse into a workspace and do it.
A browser will open on the Boolean class (browseBoolean).
There is also a keyboard shortcut b (browse) that you can use in any
tool where you find a class name;

select the name and type b.

Use the keyboard shortcut to browse the class Boolean.







Notice that when the Boolean class is selected but no protocol or
method is selected, instead of the source code of a method, we see a
class definition (browseBoolean).
This is nothing more than an ordinary message that is sent to the
parent class, asking it to create a subclass.
Here we see that the class Object is being asked to create a subclass
named Boolean with no instance variables, class variables or ``pool
dictionaries'', and to put the class Boolean in the Kernel-Objects
category.

If you on the ? at the bottom of the class pane, you can see the class
classcomment in a dedicated pane (see classComment).







Often, the fastest way to find a class is to search for it by name.
For example, suppose that you are looking for some unknown class that
represents dates and times.

Put the mouse in the package pane of the browser and type f, or select
find class (f) by ing.  Type ``time'' in the dialog box and accept it.

You will be presented with a list of classes whose names contain
``time'' (see findit).  Choose one, say, Time, and the browser will
show it, along with a class comment that suggests other classes that
might be useful.  If you want to browse one of the others, select its
name (in any text pane), and type b.













Note that if you type the complete (and correctly capitalized) name of
a class in the find dialog, the browser will go directly to that class
without showing you the list of options.


Finding methods
quick:methodFinder

Sometimes you can guess the name of a method, or at least part of the
name of a method, more easily than the name of a class.  For example,
if you are interested in the current time, you might expect that there
would be a method called ``now'', or containing ``now'' as a
substring.   But where might it be?
The method finder can help you.
browser!finding methodsmethod, finding


Select World Tools ... Method finder.
Type ``now'' in the top left pane, and accept it (or just press the return key).
The method finder will display a list of all the method names that
contain the substring ``now''.
To scroll to now itself, move the cursor to the list and type ``n'';
this trick works in all scrolling windows.  Select ``now'' and the
right-hand pane shows you the classes that define a method with this
name, as shown in MethodFinder.  Selecting any one of them will open a
browser on it.







At other times you may have a good idea that a method exists, but will
have no idea what it might be called.
The method finder can still help!  For example, suppose that you would
like to find a method that turns a string into upper case, for
example, it would translate 'eureka' into 'EUREKA'.

Type 'eureka' . 'EUREKA' into the method finder and press
  the return key, as shown in
  methodFinder-example1.

The method finder will suggest a method that does what you want.

An asterisk at the beginning of a line in the right pane of the method
finder indicates that this method is the one that was actually used to
obtain the requested result.
So, the asterisk in front of String asUppercase lets us know that the
method StringasUppercase defined on the class String was executed and
returned the result we wanted. The methods that do not have an
asterisk are just the other methods that have the same name as the
ones that returned the expected result. So CharacterasUppercase was
not executed on our example, because 'eureka' is not a Character
object.







You can also use the method finder for methods with arguments; for
example, if you are looking for a method that will find the greatest
common factor of two integers, you might try 25. 35. 5 as an example.
You can also give the method finder multiple examples to narrow the
search space; the help text in the bottom pane explains how.


Defining a new method

The advent of Test Driven Development (TDD) has changed the way that
we write code.
The idea behind TDD is that we write a test that defines the desired
behaviour of our code before we write the code itself.
Only then do we write the code that satisfies the test.
Behavior Driven DevelopmentTest Driven Development


Suppose that our assignment is to write a method that ``says something
loudly and with emphasis''.  What exactly could that mean?  What would
be a good name for such a method?  How can we make sure  that
programmers who may have to maintain our method in the future have an
unambiguous description of what it should do?   We can answer all of
these questions by giving an example:


When we send the message shout to the string ``Don't panic'' the
result should be ``DON'T PANIC!''.



To make this example into something that the system can use, we turn
it into a test method:



3
[testShout]A test for a shout method
testShout
    self assert: ('Don''t panic' shout = 'DON''T PANICBANG')


How do we create a new method in ?   First, we have to decide which
class the method should belong to.
In this case, the shout method that we are testing will go in class
String, so the corresponding test will, by convention, go in a class
called StringTest.







Open a browser on the class StringTest, and select an appropriate
protocol for our method, in this case tests - converting, as shown in
newMethodTemplate.
The highlighted text in the bottom pane is a template that reminds you
what a method looks like.
Delete this and enter the code from  testShout.
Once you have typed the text into the browser, notice that the bottom
pane is outlined in red.  This is a reminder that the pane contains
unsaved changes.
So select accept (s) by ing in the bottom pane, or just type s, to
compile and save your method.


accept itkeyboard shortcut, accept

If this is the first time you have accepted any code in your image,
you will likely be prompted to enter your name. Since many people have
contributed code to the image, it is important to keep track of
everyone who creates or modifies methods. Simply enter your first and
last names, without any spaces, or separated by a dot.







Because there is as yet no method called shout, the browser will ask
you to confirm that this is the name that you really want---and it
will suggest some other names that you might have intended
(testShoutConfirm).
This can be quite useful if you have merely made a typing mistake, but
in this case, we really do mean shout, since that is the method we are
about to create, so we have to confirm this by selecting the first
option from the menu of choices, as shown in testShoutConfirm.

































Run your newly created test: open the SUnit TestRunner from the World menu.

The leftmost two panes are a bit like the top panes in the browser.
The left pane contains a list of categories, but it's restricted to
those categories that contain test classes.

Select CollectionsTests-Text and the pane to the right will show all
of the test classes in that category, which includes the class
StringTest.  The names of the classes are already selected, so Run
Selected to run all these tests.







You should see a message like that shown in testRunnerTestShout, which
indicates that there was an error in running the tests.  The list of
tests that gave rise to errors is shown in the bottom right pane; as
you can see, StringTest>>>#testShout is the culprit.
(Note that StringTest>>>#testShout is the Smalltalk convention to
identify the StringTesttestShout method of the StringTest class.)
If you on that line of text, the erroneous test will run again, this
time in such a way that you see the error happen:
``MessageNotUnderstood: ByteString>>>shout''.
>>Behavior, >>
Behavior>>

The window that opens with the error message is the debugger (see predebugger).

We will look at the debugger and how to use it in env.







The error is, of course, exactly what we expected:  running the test
generates an error because we haven't yet written a method that tells
strings how to shout.
Nevertheless, it's good practice to make sure that the test fails
because this confirms that we have set up the testing machinery
correctly and that the new test is actually being run.
Once you have seen the error, you can Abandon the running test, which
will close the debugger window.
Note that often with Smalltalk you can define the missing method using
the Create button, edit the newly-created method in the debugger, and
then Proceed with the test.

Now let's define the method that will make the test succeed!

Select class String in the browser, select the converting protocol,
type the text in shout over the method creation template, and accept
it.
(Note: to get a ^, type ).
[shout]The shout method
shout
    ^ self asUppercase, 'BANG'


The comma is the string concatenation operation, so the body of this
method appends an exclamation mark to an upper-case version of
whatever String object the shout message was sent to.
The  tells that the expression that follows is the answer to be
returned from the method, in this case the new concatenated string.
commaCollection, comma operator


Does this method work?  Let's run the tests and see.

Click on Run Selected again in the test runner, and this time you
should see a green bar and text indicating that all of the tests ran
with no failures and no errors.
When you get to a green bar, it's a good idea to save your work and
take a break.
So do that right now!














Chapter summary
This chapter has introduced you to the environment and shown you how
to use some of the major tools, such as the browser, the method
finder, and the test runner.   You have also seen a little of syntax,
even though you may not understand it all yet.


  A running system consists of a virtual machine, a sources file, and
image and changes files. Only these last two change, as they record a
snapshot of the running system.
  When you restore a image, you will find yourself in exactly the same
state---with the same running objects---that you had when you last
saved that image.
  is designed to work with a three-button mouse to , or .  If you
don't have a three-button mouse, you can use modifier keys to obtain
the same effect.
  You on the background to bring up the World menu and launch various tools.
  A workspace is a tool for writing and evaluating snippets of code.
You can also use it to store arbitrary text.
  You can use keyboard shortcuts on text in the workspace, or any
other tool, to evaluate code. The most important of these are do it
(d), print it (p), inspect it (i), explore it (I) and browse it (b).

  The browser is the main tool for browsing code, and for developing new code.
  The test runner is a tool for running unit tests. It also supports
Test Driven Development.




   jurabib
   scg








On Mon, May 19, 2014 at 10:11 PM, Damien Cassou <[hidden email]> wrote:
> On Mon, May 19, 2014 at 10:07 PM, kilon alios <[hidden email]> wrote:
>> hmm ok, is that normal ?
>
>
> the parser is waiting for the closing pair and don't emit anything
> before it finds it. I could do better but I would need to spend more
> time on the parser than I have right now.
>
>
>> I did not expect this kind of behaviour. I will have to be more careful from
>> here on. Thanks.
>>
>> Is there a way to obtain plain text from the tex file ? Dont care about
>> formated text etc, just something that will be easy to copy paste because I
>> cant paste from pdf and pasting from tex files is a huge pain cause I have
>> to remove all the text syntax.
>
> what about this?
> http://stackoverflow.com/questions/829408/extract-text-from-tex-remove-latex-tags
>
>
> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm."
> Winston Churchill



--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill



Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

Ben Coman
In reply to this post by kilon.alios
kilon alios wrote:
In section 1.9  page 18 there is this text

"At other times you may have a good idea that a method exists, but will have no idea what it might be called. The method finder can still help! For example, suppose that you would like to find a method that turns a string into upper case, for example, it would translate 'eureka' into 'EUREKA'.

The method finder will suggest a method that does what you want.8

An asterisk at the beginning of a line in the right pane of the method finder indicates that this method is the one that was actually used to obtain the requested result. So, the asterisk in front of String asUppercase lets us know that the method asUppercase defined on the class String was executed and returned the result we wanted. The methods that do not have an asterisk are just the other methods that have the same name as the ones that returned the expected result. So Character»asUppercase was not executed on our example, because 'eureka' is not a Character object.

You can also use the method finder for methods with arguments; for example, if you are looking for a method that will find the greatest common factor of two integers, you might try 25. 35. 5 as an example. You can also give the method finder multiple examples to narrow the search space; the help text in the bottom pane explains how. "

I tried " 'eureka' . 'EUREKA '" and the other suggestion it does not seem to work , should I remove this section ? 

It works for me...
* World > Tools > Finder
* Type...   'eureka' . 'EUREKA'
* Change [Selectors] to [Examples]


Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

kilon.alios
oh yes I completely missed the "examples" option. Great ! One thing less to worry about , thanks Ben :) 


On Thu, May 22, 2014 at 1:42 AM, Ben Coman <[hidden email]> wrote:
kilon alios wrote:
In section 1.9  page 18 there is this text

"At other times you may have a good idea that a method exists, but will have no idea what it might be called. The method finder can still help! For example, suppose that you would like to find a method that turns a string into upper case, for example, it would translate 'eureka' into 'EUREKA'.

The method finder will suggest a method that does what you want.8

An asterisk at the beginning of a line in the right pane of the method finder indicates that this method is the one that was actually used to obtain the requested result. So, the asterisk in front of String asUppercase lets us know that the method asUppercase defined on the class String was executed and returned the result we wanted. The methods that do not have an asterisk are just the other methods that have the same name as the ones that returned the expected result. So Character»asUppercase was not executed on our example, because 'eureka' is not a Character object.

You can also use the method finder for methods with arguments; for example, if you are looking for a method that will find the greatest common factor of two integers, you might try 25. 35. 5 as an example. You can also give the method finder multiple examples to narrow the search space; the help text in the bottom pane explains how. "

I tried " 'eureka' . 'EUREKA '" and the other suggestion it does not seem to work , should I remove this section ? 

It works for me...
* World > Tools > Finder
* Type...   'eureka' . 'EUREKA'
* Change [Selectors] to [Examples]



Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

kilon.alios
Finished Chapter 3 , no errors or warnings reporting with pdf generation.

I am moving to Chapter 2 now, which for some strange reason I skipped. 


On Thu, May 22, 2014 at 11:19 AM, kilon alios <[hidden email]> wrote:
oh yes I completely missed the "examples" option. Great ! One thing less to worry about , thanks Ben :) 


On Thu, May 22, 2014 at 1:42 AM, Ben Coman <[hidden email]> wrote:
kilon alios wrote:
In section 1.9  page 18 there is this text

"At other times you may have a good idea that a method exists, but will have no idea what it might be called. The method finder can still help! For example, suppose that you would like to find a method that turns a string into upper case, for example, it would translate 'eureka' into 'EUREKA'.

The method finder will suggest a method that does what you want.8

An asterisk at the beginning of a line in the right pane of the method finder indicates that this method is the one that was actually used to obtain the requested result. So, the asterisk in front of String asUppercase lets us know that the method asUppercase defined on the class String was executed and returned the result we wanted. The methods that do not have an asterisk are just the other methods that have the same name as the ones that returned the expected result. So Character»asUppercase was not executed on our example, because 'eureka' is not a Character object.

You can also use the method finder for methods with arguments; for example, if you are looking for a method that will find the greatest common factor of two integers, you might try 25. 35. 5 as an example. You can also give the method finder multiple examples to narrow the search space; the help text in the bottom pane explains how. "

I tried " 'eureka' . 'EUREKA '" and the other suggestion it does not seem to work , should I remove this section ? 

It works for me...
* World > Tools > Finder
* Type...   'eureka' . 'EUREKA'
* Change [Selectors] to [Examples]




Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

kilon.alios
So I have finished  the second chapter , but, there is a sub section about Squeaksource which I don't think many people use anymore , will you keep this as it is ? Cause I was thinking maybe deleting that part and talk instead about Smalltalkhub. 

For the time being I have ported Squeaksource part as it is. 


On Sat, May 24, 2014 at 11:44 AM, kilon alios <[hidden email]> wrote:
Finished Chapter 3 , no errors or warnings reporting with pdf generation.

I am moving to Chapter 2 now, which for some strange reason I skipped. 


On Thu, May 22, 2014 at 11:19 AM, kilon alios <[hidden email]> wrote:
oh yes I completely missed the "examples" option. Great ! One thing less to worry about , thanks Ben :) 


On Thu, May 22, 2014 at 1:42 AM, Ben Coman <[hidden email]> wrote:
kilon alios wrote:
In section 1.9  page 18 there is this text

"At other times you may have a good idea that a method exists, but will have no idea what it might be called. The method finder can still help! For example, suppose that you would like to find a method that turns a string into upper case, for example, it would translate 'eureka' into 'EUREKA'.

The method finder will suggest a method that does what you want.8

An asterisk at the beginning of a line in the right pane of the method finder indicates that this method is the one that was actually used to obtain the requested result. So, the asterisk in front of String asUppercase lets us know that the method asUppercase defined on the class String was executed and returned the result we wanted. The methods that do not have an asterisk are just the other methods that have the same name as the ones that returned the expected result. So Character»asUppercase was not executed on our example, because 'eureka' is not a Character object.

You can also use the method finder for methods with arguments; for example, if you are looking for a method that will find the greatest common factor of two integers, you might try 25. 35. 5 as an example. You can also give the method finder multiple examples to narrow the search space; the help text in the bottom pane explains how. "

I tried " 'eureka' . 'EUREKA '" and the other suggestion it does not seem to work , should I remove this section ? 

It works for me...
* World > Tools > Finder
* Type...   'eureka' . 'EUREKA'
* Change [Selectors] to [Examples]





Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

Ben Coman
kilon alios wrote:
So I have finished  the second chapter , but, there is a sub section about Squeaksource which I don't think many people use anymore , will you keep this as it is ? Cause I was thinking maybe deleting that part and talk instead about Smalltalkhub. 

For the time being I have ported Squeaksource part as it is.

Thanks kilon. Thats an important effort.  I would vote for changing it to SmalltalkHub. The Squeaksource home page says its disabled creation of new projects. 

cheers -ben



On Sat, May 24, 2014 at 11:44 AM, kilon alios <[hidden email]> wrote:
Finished Chapter 3 , no errors or warnings reporting with pdf generation.

I am moving to Chapter 2 now, which for some strange reason I skipped. 


On Thu, May 22, 2014 at 11:19 AM, kilon alios <[hidden email]> wrote:
oh yes I completely missed the "examples" option. Great ! One thing less to worry about , thanks Ben :) 


On Thu, May 22, 2014 at 1:42 AM, Ben Coman <[hidden email]> wrote:
kilon alios wrote:
In section 1.9  page 18 there is this text

"At other times you may have a good idea that a method exists, but will have no idea what it might be called. The method finder can still help! For example, suppose that you would like to find a method that turns a string into upper case, for example, it would translate 'eureka' into 'EUREKA'.

The method finder will suggest a method that does what you want.8

An asterisk at the beginning of a line in the right pane of the method finder indicates that this method is the one that was actually used to obtain the requested result. So, the asterisk in front of String asUppercase lets us know that the method asUppercase defined on the class String was executed and returned the result we wanted. The methods that do not have an asterisk are just the other methods that have the same name as the ones that returned the expected result. So Character»asUppercase was not executed on our example, because 'eureka' is not a Character object.

You can also use the method finder for methods with arguments; for example, if you are looking for a method that will find the greatest common factor of two integers, you might try 25. 35. 5 as an example. You can also give the method finder multiple examples to narrow the search space; the help text in the bottom pane explains how. "

I tried " 'eureka' . 'EUREKA '" and the other suggestion it does not seem to work , should I remove this section ? 

It works for me...
* World > Tools > Finder
* Type...   'eureka' . 'EUREKA'
* Change [Selectors] to [Examples]






Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

stepharo
In reply to this post by kilon.alios
Nice to see some progress on that front.
I checked a bit and just a remark: pay attention to the coherent of word uppercasing in titles.

A quick tour of Pharo

vs.

A Quick tout of Pharo.

In PBE we do not use uppercase in title except for names.
I read fast the QuickTour and fix them all.

Also use '' '' for italic. Because this is nice to have stress in the text.
Keep pushing.

Stef

On 1/6/14 17:54, kilon alios wrote:
So I have finished  the second chapter , but, there is a sub section about Squeaksource which I don't think many people use anymore , will you keep this as it is ? Cause I was thinking maybe deleting that part and talk instead about Smalltalkhub. 

For the time being I have ported Squeaksource part as it is. 


On Sat, May 24, 2014 at 11:44 AM, kilon alios <[hidden email]> wrote:
Finished Chapter 3 , no errors or warnings reporting with pdf generation.

I am moving to Chapter 2 now, which for some strange reason I skipped. 


On Thu, May 22, 2014 at 11:19 AM, kilon alios <[hidden email]> wrote:
oh yes I completely missed the "examples" option. Great ! One thing less to worry about , thanks Ben :) 


On Thu, May 22, 2014 at 1:42 AM, Ben Coman <[hidden email]> wrote:
kilon alios wrote:
In section 1.9  page 18 there is this text

"At other times you may have a good idea that a method exists, but will have no idea what it might be called. The method finder can still help! For example, suppose that you would like to find a method that turns a string into upper case, for example, it would translate 'eureka' into 'EUREKA'.

The method finder will suggest a method that does what you want.8

An asterisk at the beginning of a line in the right pane of the method finder indicates that this method is the one that was actually used to obtain the requested result. So, the asterisk in front of String asUppercase lets us know that the method asUppercase defined on the class String was executed and returned the result we wanted. The methods that do not have an asterisk are just the other methods that have the same name as the ones that returned the expected result. So Character»asUppercase was not executed on our example, because 'eureka' is not a Character object.

You can also use the method finder for methods with arguments; for example, if you are looking for a method that will find the greatest common factor of two integers, you might try 25. 35. 5 as an example. You can also give the method finder multiple examples to narrow the search space; the help text in the bottom pane explains how. "

I tried " 'eureka' . 'EUREKA '" and the other suggestion it does not seem to work , should I remove this section ? 

It works for me...
* World > Tools > Finder
* Type...   'eureka' . 'EUREKA'
* Change [Selectors] to [Examples]






Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

stepharo
I also fixed

     kjhjkhjh . -> lkjlkjklj.

     lkjkl , kkklj -> lkjkl, kkklj

there is no space because diacritics in english so

     Pharo ? -> Pharo?

And I suggest to add some screen shots in the tour on pharo.


I converted also extra bold into == == because code should be in == ==


I think that we should have a special tag for the "exercises" right now
I put a bullet.
Stef

Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

kilon.alios
Thanks Stef , I will try to take account all you mentioned from now on to anything I port. I used spaces because it makes it much easier for me to read. 

I have not added more screenshots because you told me you wanted less. Obviously less screenshots is less work for me. I have tried to add all the basic ones like system browser, inspector etc.

In any case I like to note here that my work need a lot of proof reading. I am fully aware there will be problems with my work and I don't read line by line everything I port because that would be extremely time consuming and would slow me down severely. But I do always make sure the pdf renders properly and the text looks readable. 

So please if you find any problems with the pdf/html , either fix it yourselves or if you dont have access to github / dont have the time to fix it , please report here and I will fix it for you. 

Whats the verdict with the Squeksource section ? Do I covert it to a SmalltalkHub section or do I continue to chapter 4 ? 

"Thanks kilon. Thats an important effort.  I would vote for changing it to SmalltalkHub. The Squeaksource home page says its disabled creation of new projects.  "

well last time I checked the old Squeaksource was dead, there was something like Squeaksource3 that can be found here that allows the creation of new projects and I think its what squeakers use for their projects


but I have not used it since I left Squeak for Pharo a year ago. 

I dont have an issues making a similar size section about Smalltalkhub , I agree its the most sensible solution but I would like to check it our first with Stef and the rest of the team because I know its extra work for people doing the translations and such. 


On Sun, Jun 1, 2014 at 9:13 PM, stepharo <[hidden email]> wrote:
I also fixed

    kjhjkhjh . -> lkjlkjklj.

    lkjkl , kkklj -> lkjkl, kkklj

there is no space because diacritics in english so

    Pharo ? -> Pharo?

And I suggest to add some screen shots in the tour on pharo.


I converted also extra bold into == == because code should be in == ==


I think that we should have a special tag for the "exercises" right now I put a bullet.
Stef


Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

stepharo
In reply to this post by stepharo
I did a full pass on Syntax in  nutshell and I fixed tons of glitches.

Stef

Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

stepharo
In reply to this post by Damien Cassou
I fixed that!

On 10/5/14 18:06, Damien Cassou wrote:

On Sat, May 10, 2014 at 5:01 PM, kilon alios <[hidden email]> wrote:
when I type 3 +  4 , it seems like it takes + as part of the pillar syntax and uses latex syntax and when it tries to generate the pdf it fails so I am forced now to type it as raw text like this : {{{3+4}}}

you can use eith ==3 + 4== for fixed-width font or 3 \+ 4 for normal text


--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without losing enthusiasm."
Winston Churchill

Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

Damien Cassou
In reply to this post by kilon.alios
On Sun, Jun 1, 2014 at 8:54 PM, kilon alios <[hidden email]> wrote:
> Whats the verdict with the Squeksource section ? Do I covert it to a
> SmalltalkHub section or do I continue to chapter 4 ?


I think you can keep the section about squeaksource and replace it
with ss3 and smalltalkhub instead.

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill

Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

David T. Lewis
On Sun, Jun 01, 2014 at 09:09:21PM +0200, Damien Cassou wrote:
> On Sun, Jun 1, 2014 at 8:54 PM, kilon alios <[hidden email]> wrote:
> > Whats the verdict with the Squeksource section ? Do I covert it to a
> > SmalltalkHub section or do I continue to chapter 4 ?
>
>
> I think you can keep the section about squeaksource and replace it
> with ss3 and smalltalkhub instead.
>

That sounds right. Squeaksource.com remains operational, but readers should
be guided to use smalltalkhub and ss3 for new work.

Dave

Reply | Threaded
Open this post in threaded view
|

Re: Improving Pharo By Example

kilon.alios
In reply to this post by Damien Cassou
ok will do that and you can take it from there and edit it later on if you want to add additional info. 


On Sun, Jun 1, 2014 at 10:09 PM, Damien Cassou <[hidden email]> wrote:
On Sun, Jun 1, 2014 at 8:54 PM, kilon alios <[hidden email]> wrote:
> Whats the verdict with the Squeksource section ? Do I covert it to a
> SmalltalkHub section or do I continue to chapter 4 ?


I think you can keep the section about squeaksource and replace it
with ss3 and smalltalkhub instead.

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill


12345