[Glass] Compiler interface ...

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

[Glass] Compiler interface ...

GLASS mailing list
I would like to do the following:

[ :a :b :c | a + b + c ]


How can I compile a string like "[ :a :b :c | a + b + c ]" in Gemstone
as a compiled method and store it in the database.

I would like to make sure, that the block closure is closed (only block
arguments are references).

A hint, where I could look at ?


Marten
--
Marten Feldtmann
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Compiler interface ...

GLASS mailing list


On Wed, Nov 12, 2014 at 9:27 AM, [hidden email] via Glass <[hidden email]> wrote:
I would like to do the following:

[ :a :b :c | a + b + c ]


How can I compile a string like "[ :a :b :c | a + b + c ]" in Gemstone
as a compiled method and store it in the database.


'[ :a :b :c | a + b + c ]' evaluate

That would give you a ExecBlock (closure), but not a CompiledMethod. But I don't understand why would you want a CompiledMethod rather than a closure...
 
I would like to make sure, that the block closure is closed (only block
arguments are references).


I have been wondering this as well. For Fuel development, in Pharo, we added #isClean, which checked exactly what you said. I am not fully sure in GemStone. I found #isSimple but I am not sure. 

 
A hint, where I could look at ?

 
I would check in ExecBlock hierarchy. 
 

Marten
--
Marten Feldtmann
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass



--

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Compiler interface ...

GLASS mailing list
In reply to this post by GLASS mailing list


On Wed, Nov 12, 2014 at 4:27 AM, [hidden email] via Glass <[hidden email]> wrote:
I would like to do the following:

[ :a :b :c | a + b + c ]


How can I compile a string like "[ :a :b :c | a + b + c ]" in Gemstone
as a compiled method and store it in the database.

The following will produce a compiled method (GsNMethod instance):

   '[:a :b :c | a + b + c]' _compileInContext: nil symbolList: SymbolList new oldLitVars: nil environmentId: 0

and the following will produce an ExecBlock:

  ('[:a :b :c | a + b + c]' _compileInContext: nil symbolList: nil oldLitVars: nil environmentId: 0)
    _executeInContext: nil

If you look at the args to _compileInContext:... you will see that no context, global varas or external variables are declared, so you'll get a compile error if there are any out of block scope references.

I would like to make sure, that the block closure is closed (only block
arguments are references).
 
As Mariano mentions, #isSimple can be sent to a BlockClosure and if it  returns true, then the block has no external references and is closed.


A hint, where I could look at ?


Marten
--
Marten Feldtmann
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Compiler interface ...

GLASS mailing list


On Wed, Nov 12, 2014 at 9:45 AM, Dale Henrichs <[hidden email]> wrote:


On Wed, Nov 12, 2014 at 4:27 AM, [hidden email] via Glass <[hidden email]> wrote:
I would like to do the following:

[ :a :b :c | a + b + c ]


How can I compile a string like "[ :a :b :c | a + b + c ]" in Gemstone
as a compiled method and store it in the database.

The following will produce a compiled method (GsNMethod instance):

   '[:a :b :c | a + b + c]' _compileInContext: nil symbolList: SymbolList new oldLitVars: nil environmentId: 0

nil can be used as an arg to symboList: so th eabove should have been:

   '[:a :b :c | a + b + c]' _compileInContext: nil symbolList: nil oldLitVars: nil environmentId: 0

Dale

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Compiler interface ...

GLASS mailing list
I forgot to mention that in GemStone it is a convention that methods beginning with a $_ are private methods and we reserve the right to change the interface and/or remove private methods at will ... in this particular area we are not likely to remove the functionality in future releases but we may tweak the argument list from time to time ...

Dale

On Wed, Nov 12, 2014 at 9:47 AM, Dale Henrichs <[hidden email]> wrote:


On Wed, Nov 12, 2014 at 9:45 AM, Dale Henrichs <[hidden email]> wrote:


On Wed, Nov 12, 2014 at 4:27 AM, [hidden email] via Glass <[hidden email]> wrote:
I would like to do the following:

[ :a :b :c | a + b + c ]


How can I compile a string like "[ :a :b :c | a + b + c ]" in Gemstone
as a compiled method and store it in the database.

The following will produce a compiled method (GsNMethod instance):

   '[:a :b :c | a + b + c]' _compileInContext: nil symbolList: SymbolList new oldLitVars: nil environmentId: 0

nil can be used as an arg to symboList: so th eabove should have been:

   '[:a :b :c | a + b + c]' _compileInContext: nil symbolList: nil oldLitVars: nil environmentId: 0

Dale


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass