[Glass] Creating (or converting) SimpleBlocks

Dale Henrichs via Glass glass at lists.gemtalksystems.com
Mon Jun 13 11:43:52 PDT 2016


Johan,

Here's the skinny from engineering:

 > As Paul mentioned, we did add a number of optimizations to 3.x based 
on Paul's findings

 > In v3.2 and above , a Simple block does reference it's home method which
 > in turn references the class in which the home method was compiled.  
But those references
 > are only for debugging information.    If you create a block with
 >    ' [ :a : b |  a < b ]'  evaluate
 > Then the class of the home method is nil .
 >
 > For 3.4 we could consider making a SimpleBlock not reference its home 
method,
 > but then in debugging situations you would not be able to determine 
where the
 > block was created .
 >
 > We could discuss further if you want

Dale

On 06/11/2016 12:53 AM, Johan Brichau via Glass wrote:
> Hi there,
>
> We are creating and storing a decent amount of blockclosures in persistent objects. We want these to be simple blocks as they do not need any values from their lexical scope and we wish to ensure they do not reference any objects that might otherwise be gc’ed.
>
> The way we do this right now is by passing these blocks through the following method:
>
> convertToSimpleBlock: aBlock
> 	^ aBlock _sourceString evaluate
>
> I’m not totally fond of this way: it uses a private Gs method.
> However, creating blocks from strings directly in our application code makes it harder to use code refactoring tools as the code inside the string is not taken into consideration.
> Another way to ensure that block’s lexical scope does not reference any undesirable objects is by following a code convention that explicitly creates a method in the object that will store it, and mind that there are no method arguments. However, some of these blocks are to be created in a class method, which would mean they reference that version of the class forever (undesirable in the light of future class migrations).
>
> Is there any other way to create simple blocks? :)
>
> Thanks for any suggestions
> Johan
> _______________________________________________
> Glass mailing list
> Glass at lists.gemtalksystems.com
> http://lists.gemtalksystems.com/mailman/listinfo/glass



More information about the Glass mailing list