Hi list,
I'm building a metaprogramming system in Amber, and I need to edit the Smalltalk source of BlockClosures at run time. Is there a way to do this? If not, should we have one? Is it possible in other smalltalks? Ideally, I'd also like to have access to the objects bound in the BlockClosures's scope. Is that possible? best, Siemen -- You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
2014-04-04 10:18 GMT-07:00 Siemen Baader <[hidden email]>: Hi list, Hello, I'm building a metaprogramming system in Amber, and I need to edit the Smalltalk source of BlockClosures at run time. Is there a way to do this? If not, should we have one? Is it possible in other smalltalks? It is possible in other smalltalks such as Pharo/Squeak/VisualWorks. In Amber you may have some issues. One thing is that you need the amber compiler to be able to do that, which is usually not in a production amber application (but you could add it).
Another issue is that in case of javascript callbacks you cannot access the blockClosure source so you cannot know what part of the code to edit. example: jQuery
getJSON: filePath onSuccess: [:data | self callback: data]. It is impossible to get the source of this block '[:data | self callback: data]' at runtime because the javascript runtime lacks this feature.
But for most blocks it should be possible. You can look at how the debugger maps the closure to its source and enclosing method, then you'll just need to recompile the method enclosing the block with your new source.
In Pharo/Squeak/VisualWorks you can do it by inspecting the closure (the indexable fields of the closure are the objects bound to the closure scope). I tried in Amber and I didn't succeed to do it. As Amber's closures are bound to javascript functions, it may not be possible due to javascript lacking the feature...
You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Hi Clément,
thanks for these tips. I will go figure! best, Siemen On 04 Apr 2014, at 19:39, Clément Bera <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Clément Béra
Hi Again,
On 04 Apr 2014, at 19:39, Clément Bera <[hidden email]> wrote:
Could there be a way by adding the source as an underscored attribute? We already have eg. (function(){})._basicAt , so we could have (function(a,b){window.alert(a)})._smalltalkSource = '[:a | window alert: a]' in the JS runtime. If I understood your point correctly..?
I've been looking at the Compiler-* and Kernel-Methods packages and classes, but I don't have enough of the big picture to really find an entry point. Can you point me to the specific classes & methods where I could pass the ST source as a property to the generated BlockClosure instance? I think what we (I) need would be BlockClosure >> smalltalkSource >> recompileFrom: aString
Hm... I am in no way sure, but isn't that what the rewrite of JTalk to use a VM brought with it -- a VM that holds this info explicitly, eg for debugging & inspecting, since JS does not provide it? Anyone who knows this? best, Siemen You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Hey,
-- Usually one cannot directly compile a closure. You'll need to do: Compiler new compile: ' foo ^ [ 1 ]' forClass: Object "Answers the javascript code of the method" (Compiler new eval: (Compiler new compile: ' foo ^ [ 1 ]' forClass: Object )) "Answers the compiled method" From the compiled method object you can get the closure.
Btw, I work in the Pharo compiler and VM so my Amber knowledge is kind of limited. Someone that knows it better would answer more accurately. You received this message because you are subscribed to the Google Groups "amber-lang" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |