sounds good!
Can you give us the squeak version?
Ideally it would be good to have
Scriptloader install welcomeBeginnerWindow :)
Stef
On Nov 5, 2008, at 11:06 PM, Torsten Bergmann wrote:
What about a "Pharo/Smalltalk Beginners Workspace" with colored text
and some
interesting expressions to evaluate (or just hyperlink-click for a
simple doIt/printIt)
This should start with simple expressions, unary, binary and keyword
intro up
to some high level code or cool demos (turtle graphics, ....).
Ivan Tomek provided such a workspace (see http://lists.squeakfoundation.org/pipermail/squeak-dev/2000-April/013808.html)
and I once started to adapt it to Squeak (see below).
Bye
Torsten
-------------------------------------------------------------------------------------------
*************************************************************
* INTRODUCTION TO SMALLTALK IN x EASY STEPS
*************************************************************
This workspace introduces some of the concepts of Smalltalk -
the language behind Pharo. It''s contents is executable and you
should try all our suggested exercices.
There is much more to Smalltalk and the references listed at the
end provide additional information.
=================================
Part 1: Objects and messages
=================================
---------------------------------------------------------------------------------------------------------
-- 1. EVERYTHING IN SMALLTALK IS AN OBJECT, AND ALL WORK IS DONE
BY
-- SENDING MESSAGES TO OBJECTS
---------------------------------------------------------------------------------------------------------
To send a message we just have to enter text representing the object
itself
(which is the receiver of the message) and after that the message we
want
to send.
To execute the following examples,
- select the colored code text using the left mouse button (as in a
word
processor)
- we can execute the text and print the result by selecting ''print
it''
from the right mouse button <operate> menu
- alternatively you can select the text and press ALT + p
"
3 negated. "receiver is small integer 3, the message we
send is
''negated'' "
"The period is not necessary - it just preserves the color in this
text since
it marks the end of a Smalltalk statement.
Note that if we send a message the object always responds by either
returning a new object or by returning itself. In our example the
object
3 responds with a new object -3 when we send the message ''negated''.
When evaluating code using ''print it'' the responded object is
printed.
"
"Now lets send a different message"
3 squared. "receiver is 3 again - the message is now
squared"
"Lets try some more examples"
''abc'' asUppercase. "receiver is string ''abc'' "
''HelloWorld'' reverse. "Lets reverse a string"
200 factorial. "1 * 2 * 3 * 4 ... * 199 * 200 returns a large number
which is no problem for Smalltalk"
"Simple message send can be used to ask an object. Note that the
response
is always an object"
#(a b c) size. "lets ask an array for its size"
''123456'' isAllDigits. "is the string composed entirely of digits"
"Instead of printing the result using the print it we can also open
an inspector
window on the result. This is done"
"Note that compared to other languages even mathematical functions
are handled by sending a message. instead of writing sin(x) we just
have
to send the message #sin to a number"
1 sin.
"Converting objects is also typically done by sending messages"
123 asString. "you can convert an object to a string by sending
#asString"
12.33 asInteger. "convert a float object into an integer object"
''12.34'' asNumber. "returns a number - here a float"
"So the Smalltalk syntax simply is: Object always comes first
(receiver), message follows.
---------------------------------------------------------------------------------------------------------
-- 2. THERE ARE EXACTLY THREE KIND OF MESSAGES: Unary, binary and
keyword messages
---------------------------------------------------------------------------------------------------------
2.1. Unary messages
========================
We already know this type of message from the above examples. The
message we send to
an object is just a word, there are no arguments."
3 negated. "We already know this "
''Hello World'' subStrings. "This returns an array of substrings"
"2.2. Binary messages
========================
As the name implies we have two objects playing a role in this
message type - the receiver and
exactly one argument object. Each binary message is a binary
selector, constructed from one or two
characters followed by the argument object."
3 + 4. "send the message + to the receiver object 3 with the
argument 4 "
"Take care: compared to other languages where both sides of such an
expression are treated equally
in Smalltalk the objects in a binary message are clearly separated
into the receiver of the message
(the object in front of the binary message selector) and the
argument (the object behind the message
selector). Note the difference:
"
3 + 4.0. "here we send the message + to an integer with a float
as argument object"
4.0 + 3. "here we send the message + to a float with an integer
as argument object"
"Binary messages are typically used for arithmetic and comparing
objects. Some more examples: "
1 = 2. "we know it should return false"
2 * 3. "ohhh ... it''s so simple"
1 < 2. "The object 1 should tell us if it is smaller than 2 (the
argument)"
''Hello'', ''World''. "Concatenating string is done by sending the
message , (comma) with another string
as argument"
"----------------------------------------------------------------------------------------------------------
========================================
Part 2: Classes and their instances
========================================
---------------------------------------------------------------------------------------------------------
-- 1. AN OBJECT MAY HAVE PROPERTIES (state)
---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------
-- 2. EVERY OBJECT IS AN INSTANCE OF A CLASS
---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------
-- 3. A CLASS IS A TEMPLATE FOR CREATING ITS INSTANCES
---------------------------------------------------------------------------------------------------------
...
Free Books on Smalltalk (available as PDF)
http://www.iam.unibe.ch/~ducasse/FreeBooks.html
--
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project