How do i list the execution order of statements inside a method?

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

How do i list the execution order of statements inside a method?

basilmir
Hello,

I have this piece of code (taken from ProfStef). How do i programmatically get the order in which the objects are executed by Squeak. I know the order of execution from smalltalk documentation. But what if i need this information inside an app i'm building.

tutorial: aTutorialClass lesson: aSelector
        | tutorial |
        tutorial := aTutorialClass new.
        self player tutorial: tutorial.
        self tutorial: aTutorialClass lessonAt: (tutorial indexOfLesson: aSelector).

Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

Camillo Bruni-3
The easiest way to figure that out is to debug the code and follow the execution step by step.

Note that you can basically develop in the debugger, unlike most other programming languages!

There are two ways to launch the debugger:
1. put a "self halt" in the code, this is the Smalltalk way of adding a breakpoint
2. Select a piece of code and debug it, right click and select debug

I hope this will help you

On 2013-01-25, at 10:43, mircea <[hidden email]> wrote:

> Hello,
>
> I have this piece of code (taken from ProfStef). How do i programmatically
> get the order in which the objects are executed by Squeak. I know the order
> of execution from smalltalk documentation. But what if i need this
> information inside an app i'm building.
>
> tutorial: aTutorialClass lesson: aSelector
>        | tutorial |
>        tutorial := aTutorialClass new.
>        self player tutorial: tutorial.
>        self tutorial: aTutorialClass lessonAt: (tutorial indexOfLesson:
> aSelector).
>
> Thank you!
>
>
>
> --
> View this message in context: http://forum.world.st/How-do-i-list-the-execution-order-of-statements-inside-a-method-tp4665303.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

basilmir
Thank you for the fast response.

However i don't need it myself. I want to use this in a small piece of software i'm writing. Essentially showing the execution order of any smalltalk code. I wanted to use the "way" pharo works itself to do this… instead of parsing the text myself and checking.

For example… in the Workspace… i can write a small piece of code that does something. When i select it and click Do It. Pharo goes on to execute the text… it first parses it i think and then figures out what to execute first and then pass the product of that object to the next thing and so on.

It might look like this

something dothis

anotherobject something dothis

finalobject [ anotherobject something do this ].





Pe 25.01.2013, la 11:47, Camillo Bruni <[hidden email]> a scris:

> The easiest way to figure that out is to debug the code and follow the execution step by step.
>
> Note that you can basically develop in the debugger, unlike most other programming languages!
>
> There are two ways to launch the debugger:
> 1. put a "self halt" in the code, this is the Smalltalk way of adding a breakpoint
> 2. Select a piece of code and debug it, right click and select debug
>
> I hope this will help you
>
> On 2013-01-25, at 10:43, mircea <[hidden email]> wrote:
>
>> Hello,
>>
>> I have this piece of code (taken from ProfStef). How do i programmatically
>> get the order in which the objects are executed by Squeak. I know the order
>> of execution from smalltalk documentation. But what if i need this
>> information inside an app i'm building.
>>
>> tutorial: aTutorialClass lesson: aSelector
>>       | tutorial |
>>       tutorial := aTutorialClass new.
>>       self player tutorial: tutorial.
>>       self tutorial: aTutorialClass lessonAt: (tutorial indexOfLesson:
>> aSelector).
>>
>> Thank you!
>>
>>
>>
>> --
>> View this message in context: http://forum.world.st/How-do-i-list-the-execution-order-of-statements-inside-a-method-tp4665303.html
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

Camillo Bruni-3
If you want to go more into details you can have a look at our almost-mature AST interpreter:

http://smalltalkhub.com/#!/~dh83/ast-interpreter

There is a configuration and a lot of tests which document how it works.
There you have complete control over what is executed where.
Simply override the method that handles sends and you should be able to easily add the things you want.

On 2013-01-25, at 10:54, Mircea Samoilă <[hidden email]> wrote:

> Thank you for the fast response.
>
> However i don't need it myself. I want to use this in a small piece of software i'm writing. Essentially showing the execution order of any smalltalk code. I wanted to use the "way" pharo works itself to do this… instead of parsing the text myself and checking.
>
> For example… in the Workspace… i can write a small piece of code that does something. When i select it and click Do It. Pharo goes on to execute the text… it first parses it i think and then figures out what to execute first and then pass the product of that object to the next thing and so on.
>
> It might look like this
>
> something dothis
>
> anotherobject something dothis
>
> finalobject [ anotherobject something do this ].
>
>
>
>
>
> Pe 25.01.2013, la 11:47, Camillo Bruni <[hidden email]> a scris:
>
>> The easiest way to figure that out is to debug the code and follow the execution step by step.
>>
>> Note that you can basically develop in the debugger, unlike most other programming languages!
>>
>> There are two ways to launch the debugger:
>> 1. put a "self halt" in the code, this is the Smalltalk way of adding a breakpoint
>> 2. Select a piece of code and debug it, right click and select debug
>>
>> I hope this will help you
>>
>> On 2013-01-25, at 10:43, mircea <[hidden email]> wrote:
>>
>>> Hello,
>>>
>>> I have this piece of code (taken from ProfStef). How do i programmatically
>>> get the order in which the objects are executed by Squeak. I know the order
>>> of execution from smalltalk documentation. But what if i need this
>>> information inside an app i'm building.
>>>
>>> tutorial: aTutorialClass lesson: aSelector
>>>      | tutorial |
>>>      tutorial := aTutorialClass new.
>>>      self player tutorial: tutorial.
>>>      self tutorial: aTutorialClass lessonAt: (tutorial indexOfLesson:
>>> aSelector).
>>>
>>> Thank you!
>>>
>>>
>>>
>>> --
>>> View this message in context: http://forum.world.st/How-do-i-list-the-execution-order-of-statements-inside-a-method-tp4665303.html
>>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

Göran Krampe
Hi!

Another way to answer:

1. If you want to show the order of the messages sent *without* actually
executing the code you need to compile the code and inspect the AST.
This is not that hard to do.

2. If you want to visualize the order while executing it - you could
look at how Debugger works and simply "debug" the code programmatically.
It basically means spawning a Process and sending "step" to it over and
over and looking at where it is etc. Funky enough the Debugger is "just
Smalltalk code". :)

regards, Göran


Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

basilmir
I was just in the debugger stepping through code right now. Interestingly enough stepping through code like this gives you snapshots of execution, if i were to overlay them in Photoshop all at once i would get something close to what i want.

But what happens if the code does not exist, class names are not valid, method names are just examples.

If i were to analyze something like an example someone has posted somewhere.

Question 1: Would "invalid" code compile anyway and i would get the execution order inspecting the AST, as errors would pop up at "run time"?

Question 2: Or… invalid code does not compile and i don't get to the stage where AST gives me anything useful (when using copy pasted code from anywhere) so i have to code some kind of smalltalk "text" parser and search for the patterns myself?


Pe 25.01.2013, la 13:09, Göran Krampe <[hidden email]> a scris:

> Hi!
>
> Another way to answer:
>
> 1. If you want to show the order of the messages sent *without* actually executing the code you need to compile the code and inspect the AST. This is not that hard to do.
>
> 2. If you want to visualize the order while executing it - you could look at how Debugger works and simply "debug" the code programmatically. It basically means spawning a Process and sending "step" to it over and over and looking at where it is etc. Funky enough the Debugger is "just Smalltalk code". :)
>
> regards, Göran
>
>


Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

Benjamin Van Ryseghem (Pharo)
In Squeak I can't say, but in Pharo, the Compiler can be "stupid" and compile more or less everything :)

Ben

On Jan 25, 2013, at 12:20 PM, Mircea Samoilă wrote:

> I was just in the debugger stepping through code right now. Interestingly enough stepping through code like this gives you snapshots of execution, if i were to overlay them in Photoshop all at once i would get something close to what i want.
>
> But what happens if the code does not exist, class names are not valid, method names are just examples.
>
> If i were to analyze something like an example someone has posted somewhere.
>
> Question 1: Would "invalid" code compile anyway and i would get the execution order inspecting the AST, as errors would pop up at "run time"?
>
> Question 2: Or… invalid code does not compile and i don't get to the stage where AST gives me anything useful (when using copy pasted code from anywhere) so i have to code some kind of smalltalk "text" parser and search for the patterns myself?
>
>
> Pe 25.01.2013, la 13:09, Göran Krampe <[hidden email]> a scris:
>
>> Hi!
>>
>> Another way to answer:
>>
>> 1. If you want to show the order of the messages sent *without* actually executing the code you need to compile the code and inspect the AST. This is not that hard to do.
>>
>> 2. If you want to visualize the order while executing it - you could look at how Debugger works and simply "debug" the code programmatically. It basically means spawning a Process and sending "step" to it over and over and looking at where it is etc. Funky enough the Debugger is "just Smalltalk code". :)
>>
>> regards, Göran
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

Marcus Denker-4
In reply to this post by basilmir
>
>
> Question 1: Would "invalid" code compile anyway and i would get the execution order inspecting the AST, as errors would pop up at "run time"?
>
Depending on which kind. Everything that is syntactically correct is compiled and then run. This can lead to runtime errors, e.g. when a method
is called that does not exist (other languages would catch that due to static typing at compile time).

> Question 2: Or… invalid code does not compile and i don't get to the stage where AST gives me anything useful (when using copy pasted code from anywhere) so i have to code some kind of smalltalk "text" parser and search for the patterns myself?
>
The good news is that the RBParser can compile even syntactically incorrect code.
(Camillo added this):

RBParser parseFaultyExpression: '1 +'

Im 3.0, we will use this for syntax highlighting (instead of the special parser now used).

But one fun experiment would be to extend the compiler (and the AST Interpreter) to actually
do the right thing: compile code for the correct part and raise an error at runtime for the
RBParseErrorNode. :-)

        Marcus
Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

basilmir
This is good. So to get this "execution order" and no run-time errors... i would need to get behind the complier and before the code actually runs. I don't want it to bump up errors but rather just "mark" the code, in a manner similar to code highlighting but not at the character/word level but at language level.

Mark unary, binary and keyword and have get execution pattern visible out of this.

Q1. Is there anywhere i can read more on this? How is this done? How i would be able to 

Q2. You mentioned Pharo 3.0 and i can see there is a 2.0 beta… i guess this functionality would be way off in the future?

Q3. This is not a question… but a request… since it seems you know what you are talking about, please bump me in the right direction!


Pe 25.01.2013, la 13:39, Marcus Denker <[hidden email]> a scris:



Question 1: Would "invalid" code compile anyway and i would get the execution order inspecting the AST, as errors would pop up at "run time"?

Depending on which kind. Everything that is syntactically correct is compiled and then run. This can lead to runtime errors, e.g. when a method
is called that does not exist (other languages would catch that due to static typing at compile time).

Question 2: Or… invalid code does not compile and i don't get to the stage where AST gives me anything useful (when using copy pasted code from anywhere) so i have to code some kind of smalltalk "text" parser and search for the patterns myself?

The good news is that the RBParser can compile even syntactically incorrect code.
(Camillo added this):

RBParser parseFaultyExpression: '1 +'

Im 3.0, we will use this for syntax highlighting (instead of the special parser now used).

But one fun experiment would be to extend the compiler (and the AST Interpreter) to actually
do the right thing: compile code for the correct part and raise an error at runtime for the
RBParseErrorNode. :-)

Marcus

Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

basilmir
In reply to this post by Marcus Denker-4
Wow… found this http://magaloma.seasidehosting.st/AST-Core

It seems the AST knows the difference between RBBlockNode and assignment… it seems to have everything …

Is this AST in use in Pharo right now?
Can i use RBConfigurableFormatter to do this?


Pe 25.01.2013, la 13:40, "Marcus Denker-4 [via Smalltalk]" <[hidden email]> a scris:

>
>
> Question 1: Would "invalid" code compile anyway and i would get the execution order inspecting the AST, as errors would pop up at "run time"?
>
Depending on which kind. Everything that is syntactically correct is compiled and then run. This can lead to runtime errors, e.g. when a method
is called that does not exist (other languages would catch that due to static typing at compile time).

> Question 2: Or… invalid code does not compile and i don't get to the stage where AST gives me anything useful (when using copy pasted code from anywhere) so i have to code some kind of smalltalk "text" parser and search for the patterns myself?
>
The good news is that the RBParser can compile even syntactically incorrect code.
(Camillo added this):

RBParser parseFaultyExpression: '1 +'

Im 3.0, we will use this for syntax highlighting (instead of the special parser now used).

But one fun experiment would be to extend the compiler (and the AST Interpreter) to actually
do the right thing: compile code for the correct part and raise an error at runtime for the
RBParseErrorNode. :-)

        Marcus



If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/How-do-i-list-the-execution-order-of-statements-inside-a-method-tp4665303p4665316.html
To unsubscribe from How do i list the execution order of statements inside a method?, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

Stéphane Ducasse
In reply to this post by basilmir
Mircea you should explain us what you are trying to achieve.


On Jan 25, 2013, at 8:58 AM, Mircea Samoilă wrote:

> This is good. So to get this "execution order" and no run-time errors... i would need to get behind the complier and before the code actually runs. I don't want it to bump up errors but rather just "mark" the code, in a manner similar to code highlighting but not at the character/word level but at language level.
>
> Mark unary, binary and keyword and have get execution pattern visible out of this.
>
> Q1. Is there anywhere i can read more on this? How is this done? How i would be able to
>
> Q2. You mentioned Pharo 3.0 and i can see there is a 2.0 beta… i guess this functionality would be way off in the future?
>
> Q3. This is not a question… but a request… since it seems you know what you are talking about, please bump me in the right direction!
>
>
> Pe 25.01.2013, la 13:39, Marcus Denker <[hidden email]> a scris:
>
>>>
>>>
>>> Question 1: Would "invalid" code compile anyway and i would get the execution order inspecting the AST, as errors would pop up at "run time"?
>>>
>> Depending on which kind. Everything that is syntactically correct is compiled and then run. This can lead to runtime errors, e.g. when a method
>> is called that does not exist (other languages would catch that due to static typing at compile time).
>>
>>> Question 2: Or… invalid code does not compile and i don't get to the stage where AST gives me anything useful (when using copy pasted code from anywhere) so i have to code some kind of smalltalk "text" parser and search for the patterns myself?
>>>
>> The good news is that the RBParser can compile even syntactically incorrect code.
>> (Camillo added this):
>>
>> RBParser parseFaultyExpression: '1 +'
>>
>> Im 3.0, we will use this for syntax highlighting (instead of the special parser now used).
>>
>> But one fun experiment would be to extend the compiler (and the AST Interpreter) to actually
>> do the right thing: compile code for the correct part and raise an error at runtime for the
>> RBParseErrorNode. :-)
>>
>> Marcus
>


Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

Marcus Denker-4
In reply to this post by basilmir

On Jan 25, 2013, at 1:25 PM, mircea <[hidden email]> wrote:

Wow… found this http://magaloma.seasidehosting.st/AST-Core

It seems the AST knows the difference between RBBlockNode and assignment… it seems to have everything …

Is this AST in use in Pharo right now?

The code is in, it is used for Refactoring, not yes for other things, but that will come.

Can i use RBConfigurableFormatter to do this?


You would need to write something like this (a visitor) or use the AST interpreter (which
is just a fancy visitor).

Marcus
Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

basilmir
In reply to this post by Stéphane Ducasse
Here goes,

I recently explained to someone else all of this in a rather lengthy e-mail. I'll trim it down and post it here. It's still long… take your time, maybe a cup of coffee.
I chose the example which is not technical as it illustrates very well what we are trying to achieve and everyone reading this can relate. On request i can provide other examples.

--
An example would be "playing imaginary chess"  vs "normal(real world) chess"  vs "a type of chess not invented yet".
And the relationship of chess to the player. People play chess "for" something, and that something i will describe below.

Imaginary chess:
Everyone can agree that playing chess without the board and pieces in front of you is harder that normal chess. Not only that, but everyone can agree that having the power to imagine the chessboard and all it pieces bears little importance on how well you play. 

In "Imaginary chess" you have to have two things to play 1. "the power to imagine all the pieces on the board and the board itself" and 2. "know the rules/conventions of chess"  

Normal chess:
Normal chess is "normal" since it's what you can do in the real world to "help" everyone play chess. In normal chess this first step above is eliminated by the "existence" of  embodied things which house all the "rules" needed to "imagine" and NOW all you have to know are 2. "the rules/convetions" to play. We can confidently say that the popularity of chess was helped tremendously by the creation of the chess board and pieces.

Type of chess not invented yet:
How would "a type of chess not invented yet" look like. Well you have to transfer the 2. rules and conventions of chess so they are in front of the player. Somehow when i'm about to move a piece, for example, and i touch it… all the possible positions that piece can go to or attack will light up.
This type of chess knows the rules "for me". Now i can come to the board and without knowing anything, i can move and find out the rules. Eventually i notice patterns, all the pawns move the same and so on.

One can say that this will not make you a good player BUT someone who does not know chess can sit at this board "alone" and move pieces around, and in time, figure out the rules… since the board will not let him move illegally. He does not need "training" from some other person to play. 

SO… here we arrive at the purpose of chess, why play it? Is it 1. To gain the power of imagining the board and pieces. OR 2. To know the conventions/rules of the game? or 3. Be a good player.

We can all agree the purpose is 3. Be a good player.

When all the conventions/rules of chess can be computed for any position of any piece on the board one can say that the burden of knowledge of the player has been lifted. All he needs to do is actually play and become good. The system will let him make mistakes but it will not let him make irrelevant mistakes.

This type of chess can be built on a computer, and some chess software "i imagine already have this "feature"" in them. I wouldn't know i'm not a chess fan… but it was a good example.
--


What does this have to do with smalltalk. 
To "code" you need three things:

1. The power to imagine the entire system. - get this and you are at Imaginary chess level (few people can do it)
2. Know the rules and conventions. - get 1. and this and you are at Normal chess level (anyone who knows how to read the rules can do it)
3. Become good at playing. get 1. 2. and this and you are New type of chess level… simple interactions with the system gives you feedback you are not allowed to make irrelevant mistakes (forgetting a . at the end of a statement, mistyping a variable name etc… all this is made impossible)

Right now we are ALMOST at the level of "normal" chess. We don't have to imagine the pieces of code, we can easily write them out on screen. I don't have to remember hundreds of lines of code, i don't have to model tens of objects in my head, i just write them down. Then why almost at "normal chess level"? The rules and conventions of smalltalk are simple so why not there yet. The problem is number of types of pieces. Chess only has a few but a useful app has much more types of objects.

What i, as a player, don't know, is how people before me played so far. I go into the code for the AST for example. I have no idea and no way of finding out what's the state "of the chess board". I would like to move, i would like to play but without the "creator" of the pieces, even i'm know the smalltalk rules and conventions i'm stuck making irrelevant mistakes.
Also this is not chess you can't standardize the pieces BUT from our early studies we found that patterns are more limited in number. And it is on patterns we need to concentrate. (more on this on request, but is not detailed here, conclusion is 90% of patterns are very simple and are reused, most are just mutated compositions of simple patterns, 5% are unique and really cool… la 5% are very strange)

Continuing from the example "chess" paradigm above if i want to ease my way into things all i have to do is find how to embody this knowledge into "stuff" that is in front of me, on screen. A couple of us here, in my group, have done this before in other fields, and we know the steps needed.

We deloped a way to "materializing" the patterns via the rules and conventions smalltalk has, into things on the computer screen. This way you get a richer view at your objects, one that let's your mind concentrate on playing. 

With this i hope to get smalltak and the world "ide" to "normal chess" level so that more people can play.

Right now i am at the level of getting all the rules and conventions of smalltalk into specially crafted visual objects on screen. *

After this is done. This visual pattern will be like a fingerprint for a certain method, giving instant visual feedback of what is going on inside (is the method long or short in it's implementation… does it access a variable… does it actually call some other… etc)

Next level will be the development of a "weird" navigation system that let's you "walk" through code and see lines of code (statements) as multiple of these visual method fingerprints in one go. The uniqueness of the visual field in front of you will give you a sense of where you are in the code, what the code does… it's relation to other objects etc…


That's it… normal chess level…
Next level is about patterns and is more abstract at this point, since all i can hope is that we have the same imagine in all of our brains, but i can't be sure since the image in front of me is missing, so it's safer to just build that first.




Pe 25.01.2013, la 14:34, Stéphane Ducasse [via Smalltalk] <[hidden email]> a scris:

Mircea you should explain us what you are trying to achieve.


On Jan 25, 2013, at 8:58 AM, Mircea Samoilă wrote:

> This is good. So to get this "execution order" and no run-time errors... i would need to get behind the complier and before the code actually runs. I don't want it to bump up errors but rather just "mark" the code, in a manner similar to code highlighting but not at the character/word level but at language level.
>
> Mark unary, binary and keyword and have get execution pattern visible out of this.
>
> Q1. Is there anywhere i can read more on this? How is this done? How i would be able to
>
> Q2. You mentioned Pharo 3.0 and i can see there is a 2.0 beta… i guess this functionality would be way off in the future?
>
> Q3. This is not a question… but a request… since it seems you know what you are talking about, please bump me in the right direction!
>
>
> Pe 25.01.2013, la 13:39, Marcus Denker <<a href="x-msg://180/user/SendEmail.jtp?type=node&amp;node=4665334&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]> a scris:
>
>>>
>>>
>>> Question 1: Would "invalid" code compile anyway and i would get the execution order inspecting the AST, as errors would pop up at "run time"?
>>>
>> Depending on which kind. Everything that is syntactically correct is compiled and then run. This can lead to runtime errors, e.g. when a method
>> is called that does not exist (other languages would catch that due to static typing at compile time).
>>
>>> Question 2: Or… invalid code does not compile and i don't get to the stage where AST gives me anything useful (when using copy pasted code from anywhere) so i have to code some kind of smalltalk "text" parser and search for the patterns myself?
>>>
>> The good news is that the RBParser can compile even syntactically incorrect code.
>> (Camillo added this):
>>
>> RBParser parseFaultyExpression: '1 +'
>>
>> Im 3.0, we will use this for syntax highlighting (instead of the special parser now used).
>>
>> But one fun experiment would be to extend the compiler (and the AST Interpreter) to actually
>> do the right thing: compile code for the correct part and raise an error at runtime for the
>> RBParseErrorNode. :-)
>>
>> Marcus
>




If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/How-do-i-list-the-execution-order-of-statements-inside-a-method-tp4665303p4665334.html
To unsubscribe from How do i list the execution order of statements inside a method?, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

Jesus Nuñez
Check out Moose and friends (Roasal, PetitParser, .. ) it may help in give shapes to your ideas; moreover most of what you describe at implementation level is already there. Hope this helps.

Without any warranties of being a good answer,

Jesus


2013/1/25 mircea <[hidden email]>
Here goes,

I recently explained to someone else all of this in a rather lengthy e-mail. I'll trim it down and post it here. It's still long… take your time, maybe a cup of coffee.
I chose the example which is not technical as it illustrates very well what we are trying to achieve and everyone reading this can relate. On request i can provide other examples.

--
An example would be "playing imaginary chess"  vs "normal(real world) chess"  vs "a type of chess not invented yet".
And the relationship of chess to the player. People play chess "for" something, and that something i will describe below.

Imaginary chess:
Everyone can agree that playing chess without the board and pieces in front of you is harder that normal chess. Not only that, but everyone can agree that having the power to imagine the chessboard and all it pieces bears little importance on how well you play. 

In "Imaginary chess" you have to have two things to play 1. "the power to imagine all the pieces on the board and the board itself" and 2. "know the rules/conventions of chess"  

Normal chess:
Normal chess is "normal" since it's what you can do in the real world to "help" everyone play chess. In normal chess this first step above is eliminated by the "existence" of  embodied things which house all the "rules" needed to "imagine" and NOW all you have to know are 2. "the rules/convetions" to play. We can confidently say that the popularity of chess was helped tremendously by the creation of the chess board and pieces.

Type of chess not invented yet:
How would "a type of chess not invented yet" look like. Well you have to transfer the 2. rules and conventions of chess so they are in front of the player. Somehow when i'm about to move a piece, for example, and i touch it… all the possible positions that piece can go to or attack will light up.
This type of chess knows the rules "for me". Now i can come to the board and without knowing anything, i can move and find out the rules. Eventually i notice patterns, all the pawns move the same and so on.

One can say that this will not make you a good player BUT someone who does not know chess can sit at this board "alone" and move pieces around, and in time, figure out the rules… since the board will not let him move illegally. He does not need "training" from some other person to play. 

SO… here we arrive at the purpose of chess, why play it? Is it 1. To gain the power of imagining the board and pieces. OR 2. To know the conventions/rules of the game? or 3. Be a good player.

We can all agree the purpose is 3. Be a good player.

When all the conventions/rules of chess can be computed for any position of any piece on the board one can say that the burden of knowledge of the player has been lifted. All he needs to do is actually play and become good. The system will let him make mistakes but it will not let him make irrelevant mistakes.

This type of chess can be built on a computer, and some chess software "i imagine already have this "feature"" in them. I wouldn't know i'm not a chess fan… but it was a good example.
--


What does this have to do with smalltalk. 
To "code" you need three things:

1. The power to imagine the entire system. - get this and you are at Imaginary chess level (few people can do it)
2. Know the rules and conventions. - get 1. and this and you are at Normal chess level (anyone who knows how to read the rules can do it)
3. Become good at playing. get 1. 2. and this and you are New type of chess level… simple interactions with the system gives you feedback you are not allowed to make irrelevant mistakes (forgetting a . at the end of a statement, mistyping a variable name etc… all this is made impossible)

Right now we are ALMOST at the level of "normal" chess. We don't have to imagine the pieces of code, we can easily write them out on screen. I don't have to remember hundreds of lines of code, i don't have to model tens of objects in my head, i just write them down. Then why almost at "normal chess level"? The rules and conventions of smalltalk are simple so why not there yet. The problem is number of types of pieces. Chess only has a few but a useful app has much more types of objects.

What i, as a player, don't know, is how people before me played so far. I go into the code for the AST for example. I have no idea and no way of finding out what's the state "of the chess board". I would like to move, i would like to play but without the "creator" of the pieces, even i'm know the smalltalk rules and conventions i'm stuck making irrelevant mistakes.
Also this is not chess you can't standardize the pieces BUT from our early studies we found that patterns are more limited in number. And it is on patterns we need to concentrate. (more on this on request, but is not detailed here, conclusion is 90% of patterns are very simple and are reused, most are just mutated compositions of simple patterns, 5% are unique and really cool… la 5% are very strange)

Continuing from the example "chess" paradigm above if i want to ease my way into things all i have to do is find how to embody this knowledge into "stuff" that is in front of me, on screen. A couple of us here, in my group, have done this before in other fields, and we know the steps needed.

We deloped a way to "materializing" the patterns via the rules and conventions smalltalk has, into things on the computer screen. This way you get a richer view at your objects, one that let's your mind concentrate on playing. 

With this i hope to get smalltak and the world "ide" to "normal chess" level so that more people can play.

Right now i am at the level of getting all the rules and conventions of smalltalk into specially crafted visual objects on screen. *

After this is done. This visual pattern will be like a fingerprint for a certain method, giving instant visual feedback of what is going on inside (is the method long or short in it's implementation… does it access a variable… does it actually call some other… etc)

Next level will be the development of a "weird" navigation system that let's you "walk" through code and see lines of code (statements) as multiple of these visual method fingerprints in one go. The uniqueness of the visual field in front of you will give you a sense of where you are in the code, what the code does… it's relation to other objects etc…


That's it… normal chess level…
Next level is about patterns and is more abstract at this point, since all i can hope is that we have the same imagine in all of our brains, but i can't be sure since the image in front of me is missing, so it's safer to just build that first.




Pe 25.01.2013, la 14:34, Stéphane Ducasse [via Smalltalk] <[hidden email]> a scris:

Mircea you should explain us what you are trying to achieve.


On Jan 25, 2013, at 8:58 AM, Mircea Samoilă wrote:

> This is good. So to get this "execution order" and no run-time errors... i would need to get behind the complier and before the code actually runs. I don't want it to bump up errors but rather just "mark" the code, in a manner similar to code highlighting but not at the character/word level but at language level.
>
> Mark unary, binary and keyword and have get execution pattern visible out of this.
>
> Q1. Is there anywhere i can read more on this? How is this done? How i would be able to
>
> Q2. You mentioned Pharo 3.0 and i can see there is a 2.0 beta… i guess this functionality would be way off in the future?
>
> Q3. This is not a question… but a request… since it seems you know what you are talking about, please bump me in the right direction!
>
>
> Pe 25.01.2013, la 13:39, Marcus Denker <<a href="x-msg://180/user/SendEmail.jtp?type=node&amp;node=4665334&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]> a scris:
>

>>>
>>>
>>> Question 1: Would "invalid" code compile anyway and i would get the execution order inspecting the AST, as errors would pop up at "run time"?
>>>
>> Depending on which kind. Everything that is syntactically correct is compiled and then run. This can lead to runtime errors, e.g. when a method
>> is called that does not exist (other languages would catch that due to static typing at compile time).
>>
>>> Question 2: Or… invalid code does not compile and i don't get to the stage where AST gives me anything useful (when using copy pasted code from anywhere) so i have to code some kind of smalltalk "text" parser and search for the patterns myself?
>>>
>> The good news is that the RBParser can compile even syntactically incorrect code.
>> (Camillo added this):
>>
>> RBParser parseFaultyExpression: '1 +'
>>
>> Im 3.0, we will use this for syntax highlighting (instead of the special parser now used).
>>
>> But one fun experiment would be to extend the compiler (and the AST Interpreter) to actually
>> do the right thing: compile code for the correct part and raise an error at runtime for the
>> RBParseErrorNode. :-)
>>
>> Marcus
>



If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/How-do-i-list-the-execution-order-of-statements-inside-a-method-tp4665303p4665334.html
To unsubscribe from How do i list the execution order of statements inside a method?, click here.
NAML

Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

basilmir
Thanks for the bump in that direction. Your help is appreciated.

Q: I just downloaded Pharo by Example, in an attempt to start somewhere... and at chapter 6.2 The Browser, the Kernel package seems to have changed entirely in Pharo 1.4. There are almost no similarities, from what i can gather it's been completely rewritten way beyond refactoring, the patterns are different.

It's like being a two-eyed man in a dark room with no flashlight. Your eyes are there, but without the flashlight there might as well be no room.

Without previous knowledge of how this AST is implemented my best bet is do the "architectural plan" example i gave Dale H.

Print all the methods on small pieces of paper and try to understand the thing as a whole first. Then focus on understanding the patterns and reason behind their use.



Pe 25.01.2013, la 22:58, Jesus Nuñez [via Smalltalk] <[hidden email]> a scris:

Check out Moose and friends (Roasal, PetitParser, .. ) it may help in give shapes to your ideas; moreover most of what you describe at implementation level is already there. Hope this helps.

Without any warranties of being a good answer,

Jesus


2013/1/25 mircea <<a href="x-msg://7/user/SendEmail.jtp?type=node&amp;node=4665437&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]>
Here goes,

I recently explained to someone else all of this in a rather lengthy e-mail. I'll trim it down and post it here. It's still long… take your time, maybe a cup of coffee.
I chose the example which is not technical as it illustrates very well what we are trying to achieve and everyone reading this can relate. On request i can provide other examples.

--
An example would be "playing imaginary chess"  vs "normal(real world) chess"  vs "a type of chess not invented yet".
And the relationship of chess to the player. People play chess "for" something, and that something i will describe below.

Imaginary chess:
Everyone can agree that playing chess without the board and pieces in front of you is harder that normal chess. Not only that, but everyone can agree that having the power to imagine the chessboard and all it pieces bears little importance on how well you play. 

In "Imaginary chess" you have to have two things to play 1. "the power to imagine all the pieces on the board and the board itself" and 2. "know the rules/conventions of chess"  

Normal chess:
Normal chess is "normal" since it's what you can do in the real world to "help" everyone play chess. In normal chess this first step above is eliminated by the "existence" of  embodied things which house all the "rules" needed to "imagine" and NOW all you have to know are 2. "the rules/convetions" to play. We can confidently say that the popularity of chess was helped tremendously by the creation of the chess board and pieces.

Type of chess not invented yet:
How would "a type of chess not invented yet" look like. Well you have to transfer the 2. rules and conventions of chess so they are in front of the player. Somehow when i'm about to move a piece, for example, and i touch it… all the possible positions that piece can go to or attack will light up.
This type of chess knows the rules "for me". Now i can come to the board and without knowing anything, i can move and find out the rules. Eventually i notice patterns, all the pawns move the same and so on.

One can say that this will not make you a good player BUT someone who does not know chess can sit at this board "alone" and move pieces around, and in time, figure out the rules… since the board will not let him move illegally. He does not need "training" from some other person to play. 

SO… here we arrive at the purpose of chess, why play it? Is it 1. To gain the power of imagining the board and pieces. OR 2. To know the conventions/rules of the game? or 3. Be a good player.

We can all agree the purpose is 3. Be a good player.

When all the conventions/rules of chess can be computed for any position of any piece on the board one can say that the burden of knowledge of the player has been lifted. All he needs to do is actually play and become good. The system will let him make mistakes but it will not let him make irrelevant mistakes.

This type of chess can be built on a computer, and some chess software "i imagine already have this "feature"" in them. I wouldn't know i'm not a chess fan… but it was a good example.
--


What does this have to do with smalltalk. 
To "code" you need three things:

1. The power to imagine the entire system. - get this and you are at Imaginary chess level (few people can do it)
2. Know the rules and conventions. - get 1. and this and you are at Normal chess level (anyone who knows how to read the rules can do it)
3. Become good at playing. get 1. 2. and this and you are New type of chess level… simple interactions with the system gives you feedback you are not allowed to make irrelevant mistakes (forgetting a . at the end of a statement, mistyping a variable name etc… all this is made impossible)

Right now we are ALMOST at the level of "normal" chess. We don't have to imagine the pieces of code, we can easily write them out on screen. I don't have to remember hundreds of lines of code, i don't have to model tens of objects in my head, i just write them down. Then why almost at "normal chess level"? The rules and conventions of smalltalk are simple so why not there yet. The problem is number of types of pieces. Chess only has a few but a useful app has much more types of objects.

What i, as a player, don't know, is how people before me played so far. I go into the code for the AST for example. I have no idea and no way of finding out what's the state "of the chess board". I would like to move, i would like to play but without the "creator" of the pieces, even i'm know the smalltalk rules and conventions i'm stuck making irrelevant mistakes.
Also this is not chess you can't standardize the pieces BUT from our early studies we found that patterns are more limited in number. And it is on patterns we need to concentrate. (more on this on request, but is not detailed here, conclusion is 90% of patterns are very simple and are reused, most are just mutated compositions of simple patterns, 5% are unique and really cool… la 5% are very strange)

Continuing from the example "chess" paradigm above if i want to ease my way into things all i have to do is find how to embody this knowledge into "stuff" that is in front of me, on screen. A couple of us here, in my group, have done this before in other fields, and we know the steps needed.

We deloped a way to "materializing" the patterns via the rules and conventions smalltalk has, into things on the computer screen. This way you get a richer view at your objects, one that let's your mind concentrate on playing. 

With this i hope to get smalltak and the world "ide" to "normal chess" level so that more people can play.

Right now i am at the level of getting all the rules and conventions of smalltalk into specially crafted visual objects on screen. *

After this is done. This visual pattern will be like a fingerprint for a certain method, giving instant visual feedback of what is going on inside (is the method long or short in it's implementation… does it access a variable… does it actually call some other… etc)

Next level will be the development of a "weird" navigation system that let's you "walk" through code and see lines of code (statements) as multiple of these visual method fingerprints in one go. The uniqueness of the visual field in front of you will give you a sense of where you are in the code, what the code does… it's relation to other objects etc…


That's it… normal chess level…
Next level is about patterns and is more abstract at this point, since all i can hope is that we have the same imagine in all of our brains, but i can't be sure since the image in front of me is missing, so it's safer to just build that first.




Pe 25.01.2013, la 14:34, Stéphane Ducasse [via Smalltalk] <[hidden email]> a scris:

Mircea you should explain us what you are trying to achieve.


On Jan 25, 2013, at 8:58 AM, Mircea Samoilă wrote:

> This is good. So to get this "execution order" and no run-time errors... i would need to get behind the complier and before the code actually runs. I don't want it to bump up errors but rather just "mark" the code, in a manner similar to code highlighting but not at the character/word level but at language level.
>
> Mark unary, binary and keyword and have get execution pattern visible out of this.
>
> Q1. Is there anywhere i can read more on this? How is this done? How i would be able to
>
> Q2. You mentioned Pharo 3.0 and i can see there is a 2.0 beta… i guess this functionality would be way off in the future?
>
> Q3. This is not a question… but a request… since it seems you know what you are talking about, please bump me in the right direction!
>
>
> Pe 25.01.2013, la 13:39, Marcus Denker <<a href="<a href="x-msg://180/user/SendEmail.jtp?type=node&amp;amp;node=4665334&amp;amp;i=0">x-msg://180/user/SendEmail.jtp?type=node&amp;node=4665334&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]> a scris:
>

>>>
>>>
>>> Question 1: Would "invalid" code compile anyway and i would get the execution order inspecting the AST, as errors would pop up at "run time"?
>>>
>> Depending on which kind. Everything that is syntactically correct is compiled and then run. This can lead to runtime errors, e.g. when a method
>> is called that does not exist (other languages would catch that due to static typing at compile time).
>>
>>> Question 2: Or… invalid code does not compile and i don't get to the stage where AST gives me anything useful (when using copy pasted code from anywhere) so i have to code some kind of smalltalk "text" parser and search for the patterns myself?
>>>
>> The good news is that the RBParser can compile even syntactically incorrect code.
>> (Camillo added this):
>>
>> RBParser parseFaultyExpression: '1 +'
>>
>> Im 3.0, we will use this for syntax highlighting (instead of the special parser now used).
>>
>> But one fun experiment would be to extend the compiler (and the AST Interpreter) to actually
>> do the right thing: compile code for the correct part and raise an error at runtime for the
>> RBParseErrorNode. :-)
>>
>> Marcus
>


If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/How-do-i-list-the-execution-order-of-statements-inside-a-method-tp4665303p4665334.html
To unsubscribe from How do i list the execution order of statements inside a method?, click here.
NAML





If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/How-do-i-list-the-execution-order-of-statements-inside-a-method-tp4665303p4665437.html
To unsubscribe from How do i list the execution order of statements inside a method?, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

Stéphane Ducasse

On Jan 26, 2013, at 8:25 AM, mircea wrote:

> Thanks for the bump in that direction. Your help is appreciated.
>
> Q: I just downloaded Pharo by Example, in an attempt to start somewhere... and at chapter 6.2 The Browser, the Kernel package seems to have changed entirely in Pharo 1.4. There are almost no similarities, from what i can gather it's been completely rewritten way beyond refactoring, the patterns are different.

No it did not change that much (unfortunately).
What are you looking for.


> It's like being a two-eyed man in a dark room with no flashlight. Your eyes are there, but without the flashlight there might as well be no room.
>
> Without previous knowledge of how this AST is implemented my best bet is do the "architectural plan" example i gave Dale H.

(Point>>#x) parseTree explore
will show you the tree then you can navigate in it.


> Print all the methods on small pieces of paper and try to understand the thing as a whole first. Then focus on understanding the patterns and reason behind their use.
>

Do you know what is a visitor?
If not you should read the pattern because on a AST you can pass a visitor and it can produce many different shapes


>
>
> Pe 25.01.2013, la 22:58, Jesus Nuñez [via Smalltalk] <[hidden email]> a scris:
>
>> Check out Moose and friends (Roasal, PetitParser, .. ) it may help in give shapes to your ideas; moreover most of what you describe at implementation level is already there. Hope this helps.
>>
>> Without any warranties of being a good answer,
>>
>> Jesus
>>
>>
>> 2013/1/25 mircea <<a href="x-msg://7/user/SendEmail.jtp?type=node&amp;node=4665437&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]>
>> Here goes,
>>
>> I recently explained to someone else all of this in a rather lengthy e-mail. I'll trim it down and post it here. It's still long… take your time, maybe a cup of coffee.
>> I chose the example which is not technical as it illustrates very well what we are trying to achieve and everyone reading this can relate. On request i can provide other examples.
>>
>> --
>> An example would be "playing imaginary chess"  vs "normal(real world) chess"  vs "a type of chess not invented yet".
>> And the relationship of chess to the player. People play chess "for" something, and that something i will describe below.
>>
>> Imaginary chess:
>> Everyone can agree that playing chess without the board and pieces in front of you is harder that normal chess. Not only that, but everyone can agree that having the power to imagine the chessboard and all it pieces bears little importance on how well you play.
>>
>> In "Imaginary chess" you have to have two things to play 1. "the power to imagine all the pieces on the board and the board itself" and 2. "know the rules/conventions of chess"  
>>
>> Normal chess:
>> Normal chess is "normal" since it's what you can do in the real world to "help" everyone play chess. In normal chess this first step above is eliminated by the "existence" of  embodied things which house all the "rules" needed to "imagine" and NOW all you have to know are 2. "the rules/convetions" to play. We can confidently say that the popularity of chess was helped tremendously by the creation of the chess board and pieces.
>>
>> Type of chess not invented yet:
>> How would "a type of chess not invented yet" look like. Well you have to transfer the 2. rules and conventions of chess so they are in front of the player. Somehow when i'm about to move a piece, for example, and i touch it… all the possible positions that piece can go to or attack will light up.
>> This type of chess knows the rules "for me". Now i can come to the board and without knowing anything, i can move and find out the rules. Eventually i notice patterns, all the pawns move the same and so on.
>>
>> One can say that this will not make you a good player BUT someone who does not know chess can sit at this board "alone" and move pieces around, and in time, figure out the rules… since the board will not let him move illegally. He does not need "training" from some other person to play.
>>
>> SO… here we arrive at the purpose of chess, why play it? Is it 1. To gain the power of imagining the board and pieces. OR 2. To know the conventions/rules of the game? or 3. Be a good player.
>>
>> We can all agree the purpose is 3. Be a good player.
>>
>> When all the conventions/rules of chess can be computed for any position of any piece on the board one can say that the burden of knowledge of the player has been lifted. All he needs to do is actually play and become good. The system will let him make mistakes but it will not let him make irrelevant mistakes.
>>
>> This type of chess can be built on a computer, and some chess software "i imagine already have this "feature"" in them. I wouldn't know i'm not a chess fan… but it was a good example.
>> --
>>
>>
>> What does this have to do with smalltalk.
>> To "code" you need three things:
>>
>> 1. The power to imagine the entire system. - get this and you are at Imaginary chess level (few people can do it)
>> 2. Know the rules and conventions. - get 1. and this and you are at Normal chess level (anyone who knows how to read the rules can do it)
>> 3. Become good at playing. get 1. 2. and this and you are New type of chess level… simple interactions with the system gives you feedback you are not allowed to make irrelevant mistakes (forgetting a . at the end of a statement, mistyping a variable name etc… all this is made impossible)
>>
>> Right now we are ALMOST at the level of "normal" chess. We don't have to imagine the pieces of code, we can easily write them out on screen. I don't have to remember hundreds of lines of code, i don't have to model tens of objects in my head, i just write them down. Then why almost at "normal chess level"? The rules and conventions of smalltalk are simple so why not there yet. The problem is number of types of pieces. Chess only has a few but a useful app has much more types of objects.
>>
>> What i, as a player, don't know, is how people before me played so far. I go into the code for the AST for example. I have no idea and no way of finding out what's the state "of the chess board". I would like to move, i would like to play but without the "creator" of the pieces, even i'm know the smalltalk rules and conventions i'm stuck making irrelevant mistakes.
>> Also this is not chess you can't standardize the pieces BUT from our early studies we found that patterns are more limited in number. And it is on patterns we need to concentrate. (more on this on request, but is not detailed here, conclusion is 90% of patterns are very simple and are reused, most are just mutated compositions of simple patterns, 5% are unique and really cool… la 5% are very strange)
>>
>> Continuing from the example "chess" paradigm above if i want to ease my way into things all i have to do is find how to embody this knowledge into "stuff" that is in front of me, on screen. A couple of us here, in my group, have done this before in other fields, and we know the steps needed.
>>
>> We deloped a way to "materializing" the patterns via the rules and conventions smalltalk has, into things on the computer screen. This way you get a richer view at your objects, one that let's your mind concentrate on playing.
>>
>> With this i hope to get smalltak and the world "ide" to "normal chess" level so that more people can play.
>>
>> Right now i am at the level of getting all the rules and conventions of smalltalk into specially crafted visual objects on screen. *
>>
>> After this is done. This visual pattern will be like a fingerprint for a certain method, giving instant visual feedback of what is going on inside (is the method long or short in it's implementation… does it access a variable… does it actually call some other… etc)
>>
>> Next level will be the development of a "weird" navigation system that let's you "walk" through code and see lines of code (statements) as multiple of these visual method fingerprints in one go. The uniqueness of the visual field in front of you will give you a sense of where you are in the code, what the code does… it's relation to other objects etc…
>>
>>
>> That's it… normal chess level…
>> Next level is about patterns and is more abstract at this point, since all i can hope is that we have the same imagine in all of our brains, but i can't be sure since the image in front of me is missing, so it's safer to just build that first.
>>
>>
>>
>>
>> Pe 25.01.2013, la 14:34, Stéphane Ducasse [via Smalltalk] <[hidden email]> a scris:
>>
>>> Mircea you should explain us what you are trying to achieve.
>>>
>>>
>>> On Jan 25, 2013, at 8:58 AM, Mircea Samoilă wrote:
>>>
>>> > This is good. So to get this "execution order" and no run-time errors... i would need to get behind the complier and before the code actually runs. I don't want it to bump up errors but rather just "mark" the code, in a manner similar to code highlighting but not at the character/word level but at language level.
>>> >
>>> > Mark unary, binary and keyword and have get execution pattern visible out of this.
>>> >
>>> > Q1. Is there anywhere i can read more on this? How is this done? How i would be able to
>>> >
>>> > Q2. You mentioned Pharo 3.0 and i can see there is a 2.0 beta… i guess this functionality would be way off in the future?
>>> >
>>> > Q3. This is not a question… but a request… since it seems you know what you are talking about, please bump me in the right direction!
>>> >
>>> >
>>> > Pe 25.01.2013, la 13:39, Marcus Denker <<a href="<a href="x-msg://180/user/SendEmail.jtp?type=node&amp;amp;node=4665334&amp;amp;i=0">x-msg://180/user/SendEmail.jtp?type=node&amp;node=4665334&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]> a scris:
>>> >
>>>
>>> >>>
>>> >>>
>>> >>> Question 1: Would "invalid" code compile anyway and i would get the execution order inspecting the AST, as errors would pop up at "run time"?
>>> >>>
>>> >> Depending on which kind. Everything that is syntactically correct is compiled and then run. This can lead to runtime errors, e.g. when a method
>>> >> is called that does not exist (other languages would catch that due to static typing at compile time).
>>> >>
>>> >>> Question 2: Or… invalid code does not compile and i don't get to the stage where AST gives me anything useful (when using copy pasted code from anywhere) so i have to code some kind of smalltalk "text" parser and search for the patterns myself?
>>> >>>
>>> >> The good news is that the RBParser can compile even syntactically incorrect code.
>>> >> (Camillo added this):
>>> >>
>>> >> RBParser parseFaultyExpression: '1 +'
>>> >>
>>> >> Im 3.0, we will use this for syntax highlighting (instead of the special parser now used).
>>> >>
>>> >> But one fun experiment would be to extend the compiler (and the AST Interpreter) to actually
>>> >> do the right thing: compile code for the correct part and raise an error at runtime for the
>>> >> RBParseErrorNode. :-)
>>> >>
>>> >> Marcus
>>> >
>>>
>>> If you reply to this email, your message will be added to the discussion below:
>>> http://forum.world.st/How-do-i-list-the-execution-order-of-statements-inside-a-method-tp4665303p4665334.html
>>> To unsubscribe from How do i list the execution order of statements inside a method?, click here.
>>> NAML
>>
>>
>> View this message in context: Re: How do i list the execution order of statements inside a method?
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>
>>
>>
>> If you reply to this email, your message will be added to the discussion below:
>> http://forum.world.st/How-do-i-list-the-execution-order-of-statements-inside-a-method-tp4665303p4665437.html
>> To unsubscribe from How do i list the execution order of statements inside a method?, click here.
>> NAML
>
>
> View this message in context: Re: How do i list the execution order of statements inside a method?
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

basilmir
I will reply for each. Detailing my thought pattern. I know all the "rules and conventions" of smalltalk but i "can't play" very well.

At first 
(Point>>#x) parseTree explore
just looks weird. 

Then things start to settle. () Paranthesis means i don't actually have to care what is in there, conclusion is whatever happens the product of () will be an object. I'm actually scared of >>, since i don't know what it does… i've seen it in old code snippets of class definitions.

parseTree seems to be a method, and so does explore.

Going on… it seems to be a chain of unary messages.

Based on first trial conclusion it might be a statement even though the "." at the end is missing.
I paste in the Workspace and right click 'Do It' on the whole thing. 

A window opens with lots of information in it. I can't make sense of it since i have no idea what i just did. 

I need more information on what i just did.

Restart from the beginning.

"Point" might be a point like in a cardinal system… x is there so i might be right. 
I replace x with y and 'Do It' again… another window pop open… seems to be quite similar to the first one only it has y in it instead of x.
I continue the assumption and replace y with z.
I get a KeyNotFound:, i don't understand this but it's similar to MessageNotUnderstood:. Since success would have meant i would get a similar window as in the x y case, getting a different window means the test failed.

I can only use x and y in the statement as it is now.

Point might be a class, i search for it… it seems to have instance variable names by that name. I add z to its list of instance variable names, save, replace it in the command… error. Assumption was incorrect. I look at the Point class again notice it also has accessor methods by that name, just x and y … there is no z. Agrees with the failure of earlier experiment, i might be on the right track.
I choose another method of Point. Execute the command again… get the "success" window with lots of information on it.
I choose another class and one of its methods, execute the command again… get the "success" windows with lots of information on it.

Conclusion… I can put any class name and choose any method it has and the command will pop up information about if. I don't understand the information from the pop up.

Restart from the beginning. 

I search for parseTree in the browser and there seems to be a lot of implementors of that method.
I search for explore in the browser and Object seems to implement it.
I 'Inspect It' on just the (Point>>#x) part and it seems to be producing a CompiledMethod object.

Based on assumption from the beginning whatever happens between () is an object this object then responds to parseTree. 
I 'Inspect It' on just (Point>>#x) parseTree and get an RBMethodNode object. Seems the parseTree gets CompiledMethod as input and outputs this different kind of object called RBMethodNode.

Adding explore, based on the fact that explore is a method of object, seems to be just a generic printout of this entire object.

The end. Time elapsed, a little over 3 min. Took longer to write the email.

Pending questions:

What exactly does >> do here? 
I know # is followed by a string literal normally in '' but since there are no spaces just the characters will do.









Pe 26.01.2013, la 13:41, Stéphane Ducasse [via Smalltalk] <[hidden email]> a scris:

> It's like being a two-eyed man in a dark room with no flashlight. Your eyes are there, but without the flashlight there might as well be no room. 
> 
> Without previous knowledge of how this AST is implemented my best bet is do the "architectural plan" example i gave Dale H. 

(Point>>#x) parseTree explore 
will show you the tree then you can navigate in it. 

Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

basilmir
In reply to this post by Stéphane Ducasse
Visitor pattern.
I read about this pattern, and i can understand it. Again i know the "rules and conventions" but i'm a novice player.

I won't detail my thought pattern again… it's based on trial and error… I found a match, an example that i can relate to from experience.

"Consider the design of a 2D CAD system. At its core there are several types to represent basic geometric shapes like circles, lines and arcs. The entities are ordered into layers, and at the top of the type hierarchy is the drawing, which is simply a list of layers, plus some additional properties.
A fundamental operation on this type hierarchy is saving the drawing to the system's native file format. At first glance it may seem acceptable to add local save methods to all types in the hierarchy. But then we also want to be able to save drawings to other file formats, and adding more and more methods for saving into lots of different file formats soon clutters the relatively pure geometric data structure we started out with.
A naive way to solve this would be to maintain separate functions for each file format. Such a save function would take a drawing as input, traverse it and encode into that specific file format. But if you do this for several different formats, you soon begin to see lots of duplication between the functions, e.g. lots of type-of if statements and traversal loops. Another problem with this approach is how easy it is to miss a certain shape in some saver.
Instead, you could apply the Visitor pattern. The Visitor pattern encodes a logical operation on the whole hierarchy into a single class containing one method per type. In our CAD example, each save function would be implemented as a separate Visitor subclass. This would remove all duplication of type checks and traversal steps. It would also make the compiler complain if you leave out a shape.
Another motivation is to reuse iteration code."

Based on the above text i can extract the basic pattern of interaction and apply it to our example.

Essentially "passing a visitor" as you say would involve me creating a class that has a method or methods for each type of object i want to "draw a picture" for. Per from your text, i would pass this visitor to the AST to produce these images from the input that AST gets from some example code or something.

Please be so kind as to point out anything that i might have misunderstood.


Pe 26.01.2013, la 13:41, Stéphane Ducasse [via Smalltalk] <[hidden email]> a scris:

> Print all the methods on small pieces of paper and try to understand the thing as a whole first. Then focus on understanding the patterns and reason behind their use. 
> 

Do you know what is a visitor? 
If not you should read the pattern because on a AST you can pass a visitor and it can produce many different shapes 

Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

Jesus Nuñez
In reply to this post by basilmir
About your pending question, you should read the very basics of smalltalk before trying to understand its abstrations. Just to give you a hint (I will use the Point example):


 (Point>>#x) "==> (Point>>#x "a CompiledMethod(880017408)")"

#aSymbol is just a singletone version of the string "aSymbol"; In what to classes concerns it is used as a unique identifier in the method dictionary. The rest is just syntax ">>" is the selector(s) (method(s))  accessor, it will retrieve the keyed selector (in this case #x which again is unique in the class) value, which is a CompiledMethod(atSomeAddress). 

Now you can also get the contents  as a string if you want to parse it yourself (compare to (Point>>#x) parseTree ):

(Point>>#x) definition "==> 'x
"Answer the x coordinate."
^x'"
Which is nothing more than the contents of the selector #x. I suggest, if you want to get a "personalized" version of the parse tree, to try PetitParser, there are many examples and even a Smalltalk80 parser in there. 

Hope this helps,


Jesus


2013/1/26 mircea <[hidden email]>
I will reply for each. Detailing my thought pattern. I know all the "rules and conventions" of smalltalk but i "can't play" very well.

At first 
(Point>>#x) parseTree explore
just looks weird. 

Then things start to settle. () Paranthesis means i don't actually have to care what is in there, conclusion is whatever happens the product of () will be an object. I'm actually scared of >>, since i don't know what it does… i've seen it in old code snippets of class definitions.

parseTree seems to be a method, and so does explore.

Going on… it seems to be a chain of unary messages.

Based on first trial conclusion it might be a statement even though the "." at the end is missing.
I paste in the Workspace and right click 'Do It' on the whole thing. 

A window opens with lots of information in it. I can't make sense of it since i have no idea what i just did. 

I need more information on what i just did.

Restart from the beginning.

"Point" might be a point like in a cardinal system… x is there so i might be right. 
I replace x with y and 'Do It' again… another window pop open… seems to be quite similar to the first one only it has y in it instead of x.
I continue the assumption and replace y with z.
I get a KeyNotFound:, i don't understand this but it's similar to MessageNotUnderstood:. Since success would have meant i would get a similar window as in the x y case, getting a different window means the test failed.

I can only use x and y in the statement as it is now.

Point might be a class, i search for it… it seems to have instance variable names by that name. I add z to its list of instance variable names, save, replace it in the command… error. Assumption was incorrect. I look at the Point class again notice it also has accessor methods by that name, just x and y … there is no z. Agrees with the failure of earlier experiment, i might be on the right track.
I choose another method of Point. Execute the command again… get the "success" window with lots of information on it.
I choose another class and one of its methods, execute the command again… get the "success" windows with lots of information on it.

Conclusion… I can put any class name and choose any method it has and the command will pop up information about if. I don't understand the information from the pop up.

Restart from the beginning. 

I search for parseTree in the browser and there seems to be a lot of implementors of that method.
I search for explore in the browser and Object seems to implement it.
I 'Inspect It' on just the (Point>>#x) part and it seems to be producing a CompiledMethod object.

Based on assumption from the beginning whatever happens between () is an object this object then responds to parseTree. 
I 'Inspect It' on just (Point>>#x) parseTree and get an RBMethodNode object. Seems the parseTree gets CompiledMethod as input and outputs this different kind of object called RBMethodNode.

Adding explore, based on the fact that explore is a method of object, seems to be just a generic printout of this entire object.

The end. Time elapsed, a little over 3 min. Took longer to write the email.

Pending questions:

What exactly does >> do here? 
I know # is followed by a string literal normally in '' but since there are no spaces just the characters will do.









Pe 26.01.2013, la 13:41, Stéphane Ducasse [via Smalltalk] <[hidden email]> a scris:

> It's like being a two-eyed man in a dark room with no flashlight. Your eyes are there, but without the flashlight there might as well be no room. 
> 
> Without previous knowledge of how this AST is implemented my best bet is do the "architectural plan" example i gave Dale H. 

(Point>>#x) parseTree explore 
will show you the tree then you can navigate in it. 




Reply | Threaded
Open this post in threaded view
|

Re: How do i list the execution order of statements inside a method?

basilmir
Thank you for taking the time to explain this in such technical detail. 

I reread my answer to the example Stéphane Ducasse gave me, and i realize some of you might have gotten the impression in never fully understood the code and what i meant.

I may lack the technical background to express this, but i did fully figure out what it meant and how it would help me.

Gathered more "intel" form other sources.

"Check out our AST interpreter that will give you fine-grained control over the execution of Smalltalk code.

With underlying AST as execution format it is very easy to map the currently executed code back to the source code."


The keywords contained in the answer have indeed assured me that in am indeed looking into the direction. I've since compiled a list of all the things i am supposed to know before i can attack the problem myself, and happily started my journey to knowledge.

Conceptually i think i have the solution, as all the pieces seem to be available, but i think it will take some time before i slowly transition this mental model to a "working" model, given my lack of practical expertise.

I have high hopes that what i'm trying to achieve will also help alleviate some of the caveats OO has now, a rather opaqueness of objects, a "hiding" of relevant information behind something else, and the need to "know" the model of all the separate packages involved, but which you don't actually need to build something rather small in between.

I find it rather peculiar that it is in this field also, the best advice of how to fix things comes from people complaining.
I may not share the expertise of the writer but i can say, with confidence, that i am quite familiar with the feeling.

Regards.

Pe 26.01.2013, la 21:26, Jesus Nuñez <[hidden email]> a scris:

About your pending question, you should read the very basics of smalltalk before trying to understand its abstrations. Just to give you a hint (I will use the Point example):


 (Point>>#x) "==> (Point>>#x "a CompiledMethod(880017408)")"

#aSymbol is just a singletone version of the string "aSymbol"; In what to classes concerns it is used as a unique identifier in the method dictionary. The rest is just syntax ">>" is the selector(s) (method(s))  accessor, it will retrieve the keyed selector (in this case #x which again is unique in the class) value, which is a CompiledMethod(atSomeAddress). 

Now you can also get the contents  as a string if you want to parse it yourself (compare to (Point>>#x) parseTree ):

(Point>>#x) definition "==> 'x
"Answer the x coordinate."
^x'"
Which is nothing more than the contents of the selector #x. I suggest, if you want to get a "personalized" version of the parse tree, to try PetitParser, there are many examples and even a Smalltalk80 parser in there. 

Hope this helps,


Jesus


2013/1/26 mircea <[hidden email]>
I will reply for each. Detailing my thought pattern. I know all the "rules and conventions" of smalltalk but i "can't play" very well.

At first 
(Point>>#x) parseTree explore
just looks weird. 

Then things start to settle. () Paranthesis means i don't actually have to care what is in there, conclusion is whatever happens the product of () will be an object. I'm actually scared of >>, since i don't know what it does… i've seen it in old code snippets of class definitions.

parseTree seems to be a method, and so does explore.

Going on… it seems to be a chain of unary messages.

Based on first trial conclusion it might be a statement even though the "." at the end is missing.
I paste in the Workspace and right click 'Do It' on the whole thing. 

A window opens with lots of information in it. I can't make sense of it since i have no idea what i just did. 

I need more information on what i just did.

Restart from the beginning.

"Point" might be a point like in a cardinal system… x is there so i might be right. 
I replace x with y and 'Do It' again… another window pop open… seems to be quite similar to the first one only it has y in it instead of x.
I continue the assumption and replace y with z.
I get a KeyNotFound:, i don't understand this but it's similar to MessageNotUnderstood:. Since success would have meant i would get a similar window as in the x y case, getting a different window means the test failed.

I can only use x and y in the statement as it is now.

Point might be a class, i search for it… it seems to have instance variable names by that name. I add z to its list of instance variable names, save, replace it in the command… error. Assumption was incorrect. I look at the Point class again notice it also has accessor methods by that name, just x and y … there is no z. Agrees with the failure of earlier experiment, i might be on the right track.
I choose another method of Point. Execute the command again… get the "success" window with lots of information on it.
I choose another class and one of its methods, execute the command again… get the "success" windows with lots of information on it.

Conclusion… I can put any class name and choose any method it has and the command will pop up information about if. I don't understand the information from the pop up.

Restart from the beginning. 

I search for parseTree in the browser and there seems to be a lot of implementors of that method.
I search for explore in the browser and Object seems to implement it.
I 'Inspect It' on just the (Point>>#x) part and it seems to be producing a CompiledMethod object.

Based on assumption from the beginning whatever happens between () is an object this object then responds to parseTree. 
I 'Inspect It' on just (Point>>#x) parseTree and get an RBMethodNode object. Seems the parseTree gets CompiledMethod as input and outputs this different kind of object called RBMethodNode.

Adding explore, based on the fact that explore is a method of object, seems to be just a generic printout of this entire object.

The end. Time elapsed, a little over 3 min. Took longer to write the email.

Pending questions:

What exactly does >> do here? 
I know # is followed by a string literal normally in '' but since there are no spaces just the characters will do.









Pe 26.01.2013, la 13:41, Stéphane Ducasse [via Smalltalk] <[hidden email]> a scris:

> It's like being a two-eyed man in a dark room with no flashlight. Your eyes are there, but without the flashlight there might as well be no room. 
> 
> Without previous knowledge of how this AST is implemented my best bet is do the "architectural plan" example i gave Dale H. 

(Point>>#x) parseTree explore 
will show you the tree then you can navigate in it.