Also i have more 'intel' on the problem form questions i posted elsewhere.

I will serve as a conduit for this and try to keep every place update to the 
latest developments. In the end i think it will create a kind of cohesion 
between ideas, hopefully enough to generate something real.

Here goes:

        First advice: You should use the debugger to go to the "edge" of the 
logic inside your code and "code from there" onwards.
"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 "

        Second advice: It should make execution clear to the user.

"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 ]."

        Third advice: Go in and do this after the code is compiled, this will 
give exact data of that the code really compiles to and not just a layer that 
parses text.
"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."

        Forth advice: Showing the execution order as you create code, should 
also work for illegal code so you can can create without the backfire of an 
error (works best with dynamically typed languages) and this to be done 
"debugger" style at the very edge of the logic in your code, this is where you 
create… and should have a free but "helped and guided" hand.

"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". :) 

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.

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

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. "

        The AST-Interpreter part: It seems we can do this with the help of the 
AST, which has a certain implementation that requires a precise pattern of 
interaction, and it's called the "visitor pattern". I also received a bump in 
the direction of "Moose and friends (Roasal, PetitParser, .. )" which might 
shed a little more light on the subject.

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

" Execute (Point>>#x) parseTree explore 
in the Workspace to see a little of AST's power of going into classes and check 
out below for a more detailed information
(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."

PS. I will try to build a wiki to host this on a server so we can have a 
central reference. Right now i will have to keep things in sync by hand.
PPS. I will try to keep a reference of who said what so that we can see ideas 
from multiple people merging to a coherent solution.





Pe 28.01.2013, la 18:09, dcorking [via Smalltalk] 
<[email protected]> a scris:

> A member of the AST-Interpreter[1] team posted a very interesting 
> answer on Stack Overflow.[2] 
> 
> 1 - http://smalltalkhub.com/#!/~dh83/ast-interpreter
> 2 - 
> http://stackoverflow.com/questions/14520133/programmatically-get-the-execution-order-of-objects-inside-a-method
> 
> Have fun! David 
> _______________________________________________ 
> Beginners mailing list 
> [hidden email] 
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> 
> 
> 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-objects-inside-a-method-tp4665301p4665876.html
> To unsubscribe from How do i list the execution order of objects inside a 
> method?, click here.
> NAML





--
View this message in context: 
http://forum.world.st/How-do-i-list-the-execution-order-of-objects-inside-a-method-tp4665301p4666537.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.
_______________________________________________
Beginners mailing list
[email protected]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to