New to Pharo; a bunch of questions.

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

New to Pharo; a bunch of questions.

CodeDmitry
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

Nicolai Hess-3-2

Hi and welcome!

2016-10-01 18:29 GMT+02:00 CodeDmitry <[hidden email]>:
I have a course at my university where I have to use Pharo for assignments.

I have a few questions about the Pharo environment.

1. Is it possible to turn off Pharo's "'" and "()" matching? If so how?

In Settings Browser (World menu -> System -> Settings)
Code Browser - > Code Completion -> Smart Characters

 

2. Is it possible to use system fonts in Pharo? If so how?
Again, Sytem Browser
Appearance -> Standard Fonts -> Select an entry , this will open the font chooser. In the font chooser presse "update" and it will load the available system fonts.
 

3. Is it possible to prevent Pharo from screwing up indenting of my class
definitions when I save?(It keeps replacing leading spaces with a tab). If
so how?

No, I don't think so. It just prints the class definition, not based on your input but just the definition. What is the problem with this, why do you need spaces instead of tabs?
 

4. How can I create a Pharo package from Playground using code?

5. How can I create a Pharo class from Playground using code?

The code for creating a class is just the same as the class definition you see in the system browser

Object subclass: #NameOfYourNewClass
    instanceVariableNames: ''
    classVariableNames: ''
    package: ''
 
You can evaluate this code in a playground and it will create this class



I suspect 4 and 5 are possible because Pharo allows dynamic
insertion/removal of methods from classes using the class method dictionary
and runtime compile.

Thanks ahead of time!


Feel free to ask more questions :)
And take a look at the pharo books -> http://files.pharo.org/books/
 



--
View this message in context: http://forum.world.st/New-to-Pharo-a-bunch-of-questions-tp4917701.html
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

CodeDmitry
This post was updated on .
In reply to this post by CodeDmitry
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

Peter Uhnak
In reply to this post by CodeDmitry
Couple more answers.

On Sat, Oct 01, 2016 at 09:29:51AM -0700, CodeDmitry wrote:
> 3. Is it possible to prevent Pharo from screwing up indenting of my class
> definitions when I save?(It keeps replacing leading spaces with a tab). If
> so how?

Yes and no, you can specify indent string in "Code Browsing > BlueInk Pretty Printing",
however when you press "tab" it will still insert tab. This setting only applies to autoformatting. (ctrl+shift+f).

As for class definition, the implementation is in ClassDescription>>definition, where you can see things like

        aStream cr; tab; nextPutAll: 'instanceVariableNames: ';
                store: self instanceVariablesString.

so you would need to change >aStream cr; tab< into >aStream cr; nextPutAll: 'your indentation spaces'<

Or you can do that en masse...

newCode := (ClassDescription>>#definition) sourceCode copyReplaceAll: 'tab;' with: '''    '';'.
ClassDescription compile: newCode.

And add that code into a StartupScript or somewhere.

>
> 4. How can I create a Pharo package from Playground using code?

RPackage organizer createPackageNamed: 'Hello'.

>
> I suspect 4 and 5 are possible because Pharo allows dynamic
> insertion/removal of methods from classes using the class method dictionary
> and runtime compile.

As a bonus in answer to "3." you can also see how to dynamically compile a method. :)

Peter

Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

CodeDmitry
This post was updated on .
In reply to this post by CodeDmitry
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

CodeDmitry
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

CodeDmitry
This post was updated on .
In reply to this post by CodeDmitry
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

stepharo
In reply to this post by CodeDmitry
But why do you want that? Why do you want to code everything in the
playground?


Le 1/10/16 à 21:58, CodeDmitry a écrit :

> Thanks Peter! I admit I couldnt really dynamically add methods to a class at
> runtime since I was doing it as follows:
>
> ([
>      (LOCell class) methodDict
>          at: #mouseAction
>          put: ((LOCell class) compile:
>              mouseAction: a
>                  ^ mouseAction := a
>          ).
> ] value).
>
> Which caused constant harassment by Pharo until I typed:
>
> (LOCell class) removeAllKeys.
>
> or
>
> (LOCell class) removeKey: #mouseAction.
>
> I'll try your method in a bit to see if it works better.

But you are using black magic incantation instead of using the class browser
So do not complain if you shoot in your feet in the future.

I would not code like that because you will just get frustrated and you
will
think pharo is bad while we are all using hyper fast and safe and we
keep black magic
for the place we want it.

Stef

>
>
>
>
>
> --
> View this message in context: http://forum.world.st/New-to-Pharo-a-bunch-of-questions-tp4917701p4917706.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

stepharo
In reply to this post by CodeDmitry
You see Pharo as a file syntax too.
You did all that because you do not like you use the code browser but
you should try it.
because coding in the playground for now does not really scales.


Le 1/10/16 à 22:39, CodeDmitry a écrit :

> Ok I got the proof of concept down, but I can't get it all to run at once
> since Pharo realizes that the class does not exist(at the time of running),
> even though it will exist by the time it gets to that line.
>
> Is there a way to modify the following Transcript code make the following
> code run "at once". Ignoring the fact that classes are not created at time
> of writing?
>
> ([
>      SimpleSwitchMorph subclass: #LOCell
>          instanceVariableNames: 'mouseAction'
>          classVariableNames: ''
>          package: 'PBE-LightsOut'
> ] value).
>
> ([
>      BorderedMorph subclass: #LOGame
>          instanceVariableNames: 'cells'
>          classVariableNames: ''
>          package: 'PBE-LightsOut'
> ] value).
>
> ([
>      LOCell compile:
>          'mouseAction: a', (String cr),
>          '    ^ mouseAction := a'.
> ] value).
>
> ([
>      LOCell compile:
>          'mouseUp: e', (String cr),
>          '   mouseAction value'
> ] value).
>
> ([
>      LOCell compile:
>          'initialize', (String cr),
>          '    super initialize.', (String cr),
>          '    self label: ''''.', (String cr),
>          '    self borderWidth: 2.', (String cr),
>          '    bounds := (0@0) corner: (16@16).', (String cr),
>          '    offColor := Color paleYellow.', (String cr),
>          '    onColor := Color paleBlue darker.', (String cr),
>          '    self useSquareCorners.', (String cr),
>          '    self turnOff.'
> ] value).
>
> ([
>      LOGame compile:
>          'cellsPerSide', (String cr),
>          '    ^10'
> ] value).
>
> ([
>      LOGame compile:
>          'toggleNeighboursOfCellAt: i at: j', (String cr),
>          '    (i > 1) ifTrue: [', (String cr),
>          '        (cells at: i - 1 at: j) toggleState.', (String cr),
>          '    ].', (String cr),
>          (String cr),
>          '    (i < self cellsPerSide) ifTrue: [', (String cr),
>          '        (cells at: i + 1 at: j) toggleState.', (String cr),
>          '    ].', (String cr),
>          (String cr),
>          '    (j > 1) ifTrue: [', (String cr),
>          '        (cells at: i at: j - 1) toggleState.', (String cr),
>          '    ].', (String cr),
>          (String cr),
>          '    (j < self cellsPerSide) ifTrue: [', (String cr),
>          '        (cells at: i at: j + 1) toggleState.', (String cr),
>          '    ].'
> ] value).
>
> ([
>      LOGame compile:
>          'newCellAt: i at: j', (String cr),
>          '    | c origin | ', (String cr),
>          (String cr),
>          '    c := LOCell new.', (String cr),
>          '    origin := self innerBounds origin.', (String cr),
>          (String cr),
>          '    self addMorph: c.', (String cr),
>          '    ', (String cr),
>          '    c position: ([', (String cr),
>          '        | x_index y_index c_width c_height |', (String cr),
>          (String cr),
>          '        x_index := i - 1.', (String cr),
>          '        y_index := j - 1.', (String cr),
>          '        c_width := c width.', (String cr),
>          '        c_height := c height.', (String cr),
>          '        ', (String cr),
>          '        (x_index * c_width)@(y_index * c_height) + origin', (String
> cr),
>          '    ] value).', (String cr),
>          (String cr),
>          '    c mouseAction: [', (String cr),
>          '        self toggleNeighboursOfCellAt: i at: j.', (String cr),
>          '    ].', (String cr),
>          '    ^ c.', (String cr)
> ] value).
>
> ([
>      LOGame compile:
>          'initialize', (String cr),
>          '    | sampleCell width height n |', (String cr),
>          (String cr),
>          '    super initialize.', (String cr),
>          '    n := self cellsPerSide.', (String cr),
>          (String cr),
>          '    sampleCell := LOCell new.', (String cr),
>          '    width := sampleCell width.', (String cr),
>          '    height := sampleCell height.', (String cr),
>          (String cr),
>          '    self bounds: ', (String cr),
>          '        ((5@5) extent:', (String cr),
>          '            (width * n)@(height * n) + ', (String cr),
>          '            (2 * (self borderWidth))).', (String cr),
>          (String cr),
>          '    cells := Matrix new: n tabulate: [:i :j |', (String cr),
>          '        self newCellAt: i at: j.', (String cr),
>          '    ].'
> ] value).
>
>
>
>
> --
> View this message in context: http://forum.world.st/New-to-Pharo-a-bunch-of-questions-tp4917701p4917707.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

kilon.alios
In reply to this post by stepharo
This a problem I have long identified with Smalltalk that Pharo inherits. The fact that workspace is disconnected from System Browser.

But I never bothered fixing because of other priorities.

Personally I am suprised you ask why one would want a more close connection between System Browser and Workspace/Playground , isn't it obvious it would speed up workflow considerably ?

My workaround has been not to use Playground at all and instead work directly with System Browser. I use playground only to trigger class execution. Even that is not necessary because of the script pragma which makes possible to trigger execution directly from System Browser.

This is not just a problem of Workspace only , all tools inside Smaltalkl are disconnected with exception of inspector and debugger . The king of integration and the best example of how to connect a tool with others is GTSpotter. Of course that is also what makes GTSpotter so popular.

On Sun, 2 Oct 2016 at 08:19, stepharo <[hidden email]> wrote:
But why do you want that? Why do you want to code everything in the
playground?


Le 1/10/16 à 21:58, CodeDmitry a écrit :
> Thanks Peter! I admit I couldnt really dynamically add methods to a class at
> runtime since I was doing it as follows:
>
> ([
>      (LOCell class) methodDict
>          at: #mouseAction
>          put: ((LOCell class) compile:
>              mouseAction: a
>                  ^ mouseAction := a
>          ).
> ] value).
>
> Which caused constant harassment by Pharo until I typed:
>
> (LOCell class) removeAllKeys.
>
> or
>
> (LOCell class) removeKey: #mouseAction.
>
> I'll try your method in a bit to see if it works better.

But you are using black magic incantation instead of using the class browser
So do not complain if you shoot in your feet in the future.

I would not code like that because you will just get frustrated and you
will
think pharo is bad while we are all using hyper fast and safe and we
keep black magic
for the place we want it.

Stef
>
>
>
>
>
> --
> View this message in context: http://forum.world.st/New-to-Pharo-a-bunch-of-questions-tp4917701p4917706.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

CodeDmitry
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

Peter Uhnak
In reply to this post by CodeDmitry
Hi,

a) creating a class is message send like any other... and the returned value is the newly created class.

So you can do

locellClass := Object subclass: #LOCell.
locellClass compile: 'myMethod'.

b) Alternatively (what I usually do), is `#MyClass asClass` (or Smalltalk classNamed: #MyClass).

Note that using the former (`asClass`) is (justly) frowned upon when used in regular code, but it is perfectly fine in Playground. (Just like 'MyPackage' asPackage, etc.)

As for distribution (which you've mentioned in another mail), I write code like this in my startup scripts, e.g. https://github.com/peteruhnak/pharo-scripts/blob/master/config/5.0/roassal-zoomableInteraction.st

Likewise you can just file-out a method, class, or package(s) and send that to another person, who can just file it in.

Final note regarding your string operations... try to avoid using comma to concat many strings, using stream is preferable (from both performance and readability), e.g.

LOCell compile: (String streamContents: [ :stream |
        stream
                nextPutAll: 'initialize'; cr;
                nextPutAll: '    super initialize.'; cr.
]).

Also Pharo understands multiline strings just fine, so you can do this:

LOCell compile: 'initialize
    super initialize.
    self label: ''''.
    self borderWidth: 2'


If you need to specify parameters, take a look at String>>format:

'Today is {1}.' format: {Date today}.
'Today is {date}.' format: (Dictionary with: #date->Date today).

Peter


On Sat, Oct 01, 2016 at 12:39:26PM -0700, CodeDmitry wrote:

>
> ([
>     LOCell compile:
>         'initialize', (String cr),
>         '    super initialize.', (String cr),
>         '    self label: ''''.', (String cr),
>         '    self borderWidth: 2.', (String cr),
>         '    bounds := (0@0) corner: (16@16).', (String cr),
>         '    offColor := Color paleYellow.', (String cr),
>         '    onColor := Color paleBlue darker.', (String cr),
>         '    self useSquareCorners.', (String cr),
>         '    self turnOff.'    
> ] value).
>
> ([
>     LOGame compile:    
>         'cellsPerSide', (String cr),
>         '    ^10'
> ] value).    
>
> ([
>     LOGame compile:
>         'toggleNeighboursOfCellAt: i at: j', (String cr),
>         '    (i > 1) ifTrue: [', (String cr),
>         '        (cells at: i - 1 at: j) toggleState.', (String cr),
>         '    ].', (String cr),
>         (String cr),
>         '    (i < self cellsPerSide) ifTrue: [', (String cr),
>         '        (cells at: i + 1 at: j) toggleState.', (String cr),
>         '    ].', (String cr),
>         (String cr),
>         '    (j > 1) ifTrue: [', (String cr),
>         '        (cells at: i at: j - 1) toggleState.', (String cr),
>         '    ].', (String cr),
>         (String cr),
>         '    (j < self cellsPerSide) ifTrue: [', (String cr),
>         '        (cells at: i at: j + 1) toggleState.', (String cr),
>         '    ].'        
> ] value).
>
> ([
>     LOGame compile:
>         'newCellAt: i at: j', (String cr),
>         '    | c origin | ', (String cr),
>         (String cr),
>         '    c := LOCell new.', (String cr),
>         '    origin := self innerBounds origin.', (String cr),
>         (String cr),
>         '    self addMorph: c.', (String cr),
>         '    ', (String cr),
>         '    c position: ([', (String cr),
>         '        | x_index y_index c_width c_height |', (String cr),
>         (String cr),
>         '        x_index := i - 1.', (String cr),
>         '        y_index := j - 1.', (String cr),
>         '        c_width := c width.', (String cr),
>         '        c_height := c height.', (String cr),
>         '        ', (String cr),
>         '        (x_index * c_width)@(y_index * c_height) + origin', (String
> cr),
>         '    ] value).', (String cr),
>         (String cr),
>         '    c mouseAction: [', (String cr),
>         '        self toggleNeighboursOfCellAt: i at: j.', (String cr),
>         '    ].', (String cr),
>         '    ^ c.', (String cr)    
> ] value).
>
> ([
>     LOGame compile:
>         'initialize', (String cr),
>         '    | sampleCell width height n |', (String cr),
>         (String cr),
>         '    super initialize.', (String cr),
>         '    n := self cellsPerSide.', (String cr),
>         (String cr),            
>         '    sampleCell := LOCell new.', (String cr),
>         '    width := sampleCell width.', (String cr),
>         '    height := sampleCell height.', (String cr),
>         (String cr),            
>         '    self bounds: ', (String cr),
>         '        ((5@5) extent:', (String cr),
>         '            (width * n)@(height * n) + ', (String cr),
>         '            (2 * (self borderWidth))).', (String cr),
>         (String cr),            
>         '    cells := Matrix new: n tabulate: [:i :j |', (String cr),
>         '        self newCellAt: i at: j.', (String cr),
>         '    ].'        
> ] value).
>
>
>
>
> --
> View this message in context: http://forum.world.st/New-to-Pharo-a-bunch-of-questions-tp4917701p4917707.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

Ben Coman
On Sun, Oct 2, 2016 at 8:10 PM, Peter Uhnak <[hidden email]> wrote:

> Hi,
>
> a) creating a class is message send like any other... and the returned value is the newly created class.
>
> So you can do
>
> locellClass := Object subclass: #LOCell.
> locellClass compile: 'myMethod'.
>
> b) Alternatively (what I usually do), is `#MyClass asClass` (or Smalltalk classNamed: #MyClass).
>
> Note that using the former (`asClass`) is (justly) frowned upon when used in regular code, but it is perfectly fine in Playground. (Just like 'MyPackage' asPackage, etc.)
>
> As for distribution (which you've mentioned in another mail), I write code like this in my startup scripts, e.g. https://github.com/peteruhnak/pharo-scripts/blob/master/config/5.0/roassal-zoomableInteraction.st
>
> Likewise you can just file-out a method, class, or package(s) and send that to another person, who can just file it in.
>
> Final note regarding your string operations... try to avoid using comma to concat many strings, using stream is preferable (from both performance and readability), e.g.

The performance aspect is not absolute and depends on usage...
http://forum.world.st/Stream-instead-of-string-concatenation-td4856891.html
http://forum.world.st/When-to-use-a-stream-for-concatenating-text-td4811093.html

cheers -ben

>
> LOCell compile: (String streamContents: [ :stream |
>         stream
>                 nextPutAll: 'initialize'; cr;
>                 nextPutAll: '    super initialize.'; cr.
> ]).
>
> Also Pharo understands multiline strings just fine, so you can do this:
>
> LOCell compile: 'initialize
>     super initialize.
>     self label: ''''.
>     self borderWidth: 2'
>
>
> If you need to specify parameters, take a look at String>>format:
>
> 'Today is {1}.' format: {Date today}.
> 'Today is {date}.' format: (Dictionary with: #date->Date today).
>
> Peter
>
>
> On Sat, Oct 01, 2016 at 12:39:26PM -0700, CodeDmitry wrote:
>>
>> ([
>>     LOCell compile:
>>         'initialize', (String cr),
>>         '    super initialize.', (String cr),
>>         '    self label: ''''.', (String cr),
>>         '    self borderWidth: 2.', (String cr),
>>         '    bounds := (0@0) corner: (16@16).', (String cr),
>>         '    offColor := Color paleYellow.', (String cr),
>>         '    onColor := Color paleBlue darker.', (String cr),
>>         '    self useSquareCorners.', (String cr),
>>         '    self turnOff.'
>> ] value).
>>
>> ([
>>     LOGame compile:
>>         'cellsPerSide', (String cr),
>>         '    ^10'
>> ] value).
>>
>> ([
>>     LOGame compile:
>>         'toggleNeighboursOfCellAt: i at: j', (String cr),
>>         '    (i > 1) ifTrue: [', (String cr),
>>         '        (cells at: i - 1 at: j) toggleState.', (String cr),
>>         '    ].', (String cr),
>>         (String cr),
>>         '    (i < self cellsPerSide) ifTrue: [', (String cr),
>>         '        (cells at: i + 1 at: j) toggleState.', (String cr),
>>         '    ].', (String cr),
>>         (String cr),
>>         '    (j > 1) ifTrue: [', (String cr),
>>         '        (cells at: i at: j - 1) toggleState.', (String cr),
>>         '    ].', (String cr),
>>         (String cr),
>>         '    (j < self cellsPerSide) ifTrue: [', (String cr),
>>         '        (cells at: i at: j + 1) toggleState.', (String cr),
>>         '    ].'
>> ] value).
>>
>> ([
>>     LOGame compile:
>>         'newCellAt: i at: j', (String cr),
>>         '    | c origin | ', (String cr),
>>         (String cr),
>>         '    c := LOCell new.', (String cr),
>>         '    origin := self innerBounds origin.', (String cr),
>>         (String cr),
>>         '    self addMorph: c.', (String cr),
>>         '    ', (String cr),
>>         '    c position: ([', (String cr),
>>         '        | x_index y_index c_width c_height |', (String cr),
>>         (String cr),
>>         '        x_index := i - 1.', (String cr),
>>         '        y_index := j - 1.', (String cr),
>>         '        c_width := c width.', (String cr),
>>         '        c_height := c height.', (String cr),
>>         '        ', (String cr),
>>         '        (x_index * c_width)@(y_index * c_height) + origin', (String
>> cr),
>>         '    ] value).', (String cr),
>>         (String cr),
>>         '    c mouseAction: [', (String cr),
>>         '        self toggleNeighboursOfCellAt: i at: j.', (String cr),
>>         '    ].', (String cr),
>>         '    ^ c.', (String cr)
>> ] value).
>>
>> ([
>>     LOGame compile:
>>         'initialize', (String cr),
>>         '    | sampleCell width height n |', (String cr),
>>         (String cr),
>>         '    super initialize.', (String cr),
>>         '    n := self cellsPerSide.', (String cr),
>>         (String cr),
>>         '    sampleCell := LOCell new.', (String cr),
>>         '    width := sampleCell width.', (String cr),
>>         '    height := sampleCell height.', (String cr),
>>         (String cr),
>>         '    self bounds: ', (String cr),
>>         '        ((5@5) extent:', (String cr),
>>         '            (width * n)@(height * n) + ', (String cr),
>>         '            (2 * (self borderWidth))).', (String cr),
>>         (String cr),
>>         '    cells := Matrix new: n tabulate: [:i :j |', (String cr),
>>         '        self newCellAt: i at: j.', (String cr),
>>         '    ].'
>> ] value).
>>
>>
>>
>>
>> --
>> View this message in context: http://forum.world.st/New-to-Pharo-a-bunch-of-questions-tp4917701p4917707.html
>> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

stepharo
In reply to this post by CodeDmitry
Better use the fileout menu you will get all the code of your
class/package inside a file.


Stef


Le 2/10/16 à 12:02, CodeDmitry a écrit :

> It's just nice to have a standalone code that I can give to my friends that
> they can read and run to create the structure without having to setup
> everything themselves, but at the same time not needing to use a package. A
> standalone script is quite elegant for situations like that, since it well
> encapsulates the automation without forcing people to understand packaging.
>
>
>
> --
> View this message in context: http://forum.world.st/New-to-Pharo-a-bunch-of-questions-tp4917701p4917764.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

askoh
Administrator
In reply to this post by CodeDmitry
Hi:

Welcome to Pharo. Which university is teaching you Smalltalk? What is the course title? Are the students appreciating the features of Smalltalk? Hope you are.

All the best,
Aik-Siong Koh
Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

CodeDmitry
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

stepharo
Excellent :)
We did not know that Ryerson was using Pharo!

Stef

> @askoh
>
> Ryerson University, Pragmatic Programming Languages teaches smalltalk, and
> Introduction to Object Oriented Programming does too.
>
>
>
> --
> View this message in context: http://forum.world.st/New-to-Pharo-a-bunch-of-questions-tp4917701p4917808.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

Richard Sargent
Administrator
In reply to this post by CodeDmitry
CodeDmitry wrote
@askoh

Ryerson University, Pragmatic Programming Languages teaches Smalltalk, and Introduction to Object Oriented Programming does too.
Well, be sure to check out the Toronto Smalltalk User Group! http://www.smalltalk.ca/ says they meet at Ryerson. I'm not sure that's always / still true. But you will be welcomed.

There was also a club I think where people did Smalltalk coding, but I never really visited it so I may have been lied to.

@stepharo

heh you're right! I haven't noticed that feature, it's handy.

Umm I created a category Dummy, with class Dumbo, with method meep that does trivial text printing, and file-out'd it, but I don't know how to put it back in, it's not a valid Playground-script.

Object subclass: #Dumbo
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        category: 'Dummy'!

!Dumbo methodsFor: 'as yet unclassified' stamp: 'Anonymous 10/2/2016 21:19'!
meep
    Transcript show: 'Hello, World!!'.! !
Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

Richard Sargent
Administrator
In reply to this post by CodeDmitry
CodeDmitry wrote
It's just nice to have a standalone code that I can give to my friends that they can read and run to create the structure without having to setup everything themselves, but at the same time not needing to use a package.

A standalone script is quite elegant for situations like that, since it well encapsulates the automation without forcing people to understand packaging.

I don't mind shooting myself in the foot, I want to understand how Pharo runtime works, it has this strange circularity to it that I can't quite wrap my mind around.

I just like doing everything in Code if possible. I see no reason to use the browser other to inspect system state at the moment.
Bear in mind, the browsers were created by the original authors to facilitate repetitive actions. They are tools for interacting with the objects in the system, just as are the debugger and inspector.


That being said, I do agree i is important to understand how the tools do what they do. You should definitely browse the Behavior hierarchy. It contains all the code for creating classes, compiling (and installing!) methods, removing methods, and so on.


Also, I noticed in your examples that you like to write ([ ... ] value). Why? Why not just write the actual code (shown as ... in my example)?


Personally I've never had more fun with Smalltalk as I did writing this proof of concept.
Reply | Threaded
Open this post in threaded view
|

Re: New to Pharo; a bunch of questions.

Richard Sargent
Administrator
In reply to this post by CodeDmitry
CodeDmitry wrote
Ok I got the proof of concept down, but I can't get it all to run at once since Pharo realizes that the class does not exist(at the time of running), even though it will exist by the time it gets to that line.

Is there a way to modify the following Transcript code make the following code run "one block at a time". Ignoring the fact that classes are not created at time of writing?

I think I need some way to "reflectively find a class by class name at runtime".

steps.st

([
    SimpleSwitchMorph subclass: #LOCell
        instanceVariableNames: 'mouseAction'
        classVariableNames: ''
        package: 'PBE-LightsOut'
] value).

     <snip>
Well, that was an excruciating read. Did you find it easy to read? I'll bet you also found it hard to write.

If you look at the file-out format (also called chunk format), you can just simply write the code you want as a result and it would be infinitely more comprehensible to you and to those you would share it with.

There are times when writing things along the lines that you have are essential. For example, if you are writing a code generator you would want to generate source strings and compile them.
12