How can I specify the bindings when evaluating an expression?
I would like to be able to express Compiler new bindings: { a -> 3. b -> 4}; evaluate: 'a + b'; result and get 7 How can I do that? Stef
On 05 Dec 2014, at 15:18, stepharo <stepharo@free.fr> wrote:
I would like to be able to express
Compiler new bindings: { a -> 3. b -> 4}; evaluate: 'a + b'; result and get 7
How can I do that?
Not directly, as evaluate is just a doit⦠but it can be added as the machinery is there for evaluating in context in the debugger. I will have a look but not this weekend. Marcus
2014-12-06 11:18 GMT+01:00 Marcus Denker <marcus.denker@inria.fr>:
On 05 Dec 2014, at 15:18, stepharo <stepharo@free.fr> wrote:
I would like to be able to express
Compiler new bindings: { a -> 3. b -> 4}; evaluate: 'a + b'; result and get 7
How can I do that?
Not directly, as evaluate is just a doit⦠but it can be added as the machinery is there for evaluating in context in the debugger.
I will have a look but not this weekend.
Marcus
The easiest solution I have found: Smalltalk compiler evaluate:'a+b' notifying: (Dictionary newFrom:{ WorkspaceVariable key:#a value:3. WorkspaceVariable key:#b value:4}) logged:nil The dictionary is used as the receiver for the call to #bindingOf: and WorkspaceVariable acts like a LiteralVariable that implements emitValue/emitStore nicolai
Nicolai Hess wrote
Dictionary newFrom:{ WorkspaceVariable key:#a value:3. WorkspaceVariable key:#b value:4}
Thanks! That works great :) n.b. in Pharo 3.0, just replace the WorkspaceVariables with regular associations: Smalltalk compiler evaluate:'a+b' notifying: (Dictionary newFrom: { #a -> 3. #b -> 4 }) logged: nil ----- Cheers, Sean -- View this message in context: http://forum.world.st/How-can-I-specify-the-bindings-when-evaluating-an-expr... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
2015-02-04 23:07 GMT+01:00 Sean P. DeNigris <sean@clipperadams.com>:
Nicolai Hess wrote
Dictionary newFrom:{ WorkspaceVariable key:#a value:3. WorkspaceVariable key:#b value:4}
Thanks! That works great :)
n.b. in Pharo 3.0, just replace the WorkspaceVariables with regular associations: Smalltalk compiler evaluate:'a+b' notifying: (Dictionary newFrom: { #a -> 3. #b -> 4 }) logged: nil
That's interesting. We lost this feature in 40097 (13584 <https://pharo.fogbugz.com/default.asp?13584> Forward code generation for Globals and Class Vars to meta object)
----- Cheers, Sean -- View this message in context: http://forum.world.st/How-can-I-specify-the-bindings-when-evaluating-an-expr... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Nicolai Hess wrote
We lost this feature in 40097
Which feature? Using bare associations instead of WorkspaceVariables? ----- Cheers, Sean -- View this message in context: http://forum.world.st/How-can-I-specify-the-bindings-when-evaluating-an-expr... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
2015-02-05 2:20 GMT+01:00 Sean P. DeNigris <sean@clipperadams.com>:
Nicolai Hess wrote
We lost this feature in 40097
Which feature? Using bare associations instead of WorkspaceVariables?
Yes, maybe feature is the wrong word - ability? What is missing now is, convert an association into a "VariableBinding" similiar to WorkspaceVariable or GlobalVariable, that implements the code generation methods emitStore: and emitValue:
----- Cheers, Sean -- View this message in context: http://forum.world.st/How-can-I-specify-the-bindings-when-evaluating-an-expr... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
On 05 Feb 2015, at 10:09, Nicolai Hess <nicolaihess@web.de> wrote:
2015-02-05 2:20 GMT+01:00 Sean P. DeNigris <sean@clipperadams.com <mailto:sean@clipperadams.com>>: Nicolai Hess wrote
We lost this feature in 40097
Which feature? Using bare associations instead of WorkspaceVariables?
Yes, maybe feature is the wrong word - ability? What is missing now is, convert an association into a "VariableBinding" similiar to WorkspaceVariable or GlobalVariable, that implements the code generation methods emitStore: and emitValue:
yes, we could move it up to Association⦠but we should keep VariableBinding as a subclass of Literal so that people in the future e.g. can put a halt on a variable defined in the workspace. And yes, in general we need a nice API for the compiler to hand bindings to it⦠it is on my TODO list. Marcus
yes, we could move it up to Association⦠but we should keep VariableBinding as a subclass of Literal so that people in the future e.g. can put a halt on a variable defined in the workspace.
And yes, in general we need a nice API for the compiler to hand bindings to it⦠it is on my TODO list.
https://pharo.fogbugz.com/f/cases/15490/provide-a-way-to-specify-external-bi... This Slice adds an API to the compiler to set a dictionary with bindings to be taken into account. They are compiled as pushLinteralVariable: (thus refer to the association of the dictionary) Smalltalk compiler bindings: { #a -> 3 } asDictionary; evaluate: '1+a'. Internally this for now (ab)-uses the #requestor: API... later we will change this to be inverted: the requestors should privide binding and get notified using Announcements.
On 05 May 2015, at 13:39, Marcus Denker <marcus.denker@inria.fr> wrote:
yes, we could move it up to Association⦠but we should keep VariableBinding as a subclass of Literal so that people in the future e.g. can put a halt on a variable defined in the workspace.
And yes, in general we need a nice API for the compiler to hand bindings to it⦠it is on my TODO list.
https://pharo.fogbugz.com/f/cases/15490/provide-a-way-to-specify-external-bi... <https://pharo.fogbugz.com/f/cases/15490/provide-a-way-to-specify-external-bi...>
This Slice adds an API to the compiler to set a dictionary with bindings to be taken into account. They are compiled as pushLinteralVariable: (thus refer to the association of the dictionary)
Smalltalk compiler bindings: { #a -> 3 } asDictionary; evaluate: '1+aâ.
This is now in Pharo5 update #032 Marcus
2015-05-05 15:17 GMT+02:00 Marcus Denker <marcus.denker@inria.fr>:
On 05 May 2015, at 13:39, Marcus Denker <marcus.denker@inria.fr> wrote:
yes, we could move it up to Association... but we should keep VariableBinding as a subclass of Literal so that people in the future e.g. can put a halt on a variable defined in the workspace.
And yes, in general we need a nice API for the compiler to hand bindings to it... it is on my TODO list.
https://pharo.fogbugz.com/f/cases/15490/provide-a-way-to-specify-external-bi...
This Slice adds an API to the compiler to set a dictionary with bindings to be taken into account. They are compiled as pushLinteralVariable: (thus refer to the association of the dictionary)
Smalltalk compiler bindings: { #a -> 3 } asDictionary; evaluate: '1+a'.
This is now in Pharo5 update #032
Thanks Marcus, this should be very convenient. Thierry
Marcus
Marcus Denker-4 wrote
Smalltalk compiler bindings: { #a -> 3 } asDictionary; evaluate: '1+aâ.
This is now in Pharo5 update #032
Cool :) ----- Cheers, Sean -- View this message in context: http://forum.world.st/How-can-I-specify-the-bindings-when-evaluating-an-expr... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Nice :)
https://pharo.fogbugz.com/f/cases/15490/provide-a-way-to-specify-external-bi...
This Slice adds an API to the compiler to set a dictionary with bindings to be taken into account. They are compiled as pushLinteralVariable: (thus refer to the association of the dictionary)
Smalltalk compiler bindings: { #a -> 3 } asDictionary; evaluate: '1+a'.
Internally this for now (ab)-uses the #requestor: API... later we will change this to be inverted: the requestors should privide binding and get notified using Announcements.
Marcus could you add this issue somewhere because this is something that I'm expected from a compiler Stef Le 6/12/14 11:18, Marcus Denker a écrit :
On 05 Dec 2014, at 15:18, stepharo <stepharo@free.fr> wrote:
I would like to be able to express
Compiler new bindings: { a -> 3. b -> 4}; evaluate: 'a + b'; result and get 7
How can I do that?
Not directly, as evaluate is just a doit⦠but it can be added as the machinery is there for evaluating in context in the debugger.
I will have a look but not this weekend.
Marcus
On 23 Dec 2014, at 09:45, stepharo <stepharo@free.fr> wrote:
Marcus
could you add this issue somewhere because this is something that I'm expected from a compiler
Yes⦠I will check. Right now the API is too much focused on implementation artefacts vs. concepts. (requestor vs. binding, for example). In general, we need to do a *real* pass over the API of the compiler. But we can only do that after we remove the old one⦠Marcus
Stef Le 6/12/14 11:18, Marcus Denker a écrit :
On 05 Dec 2014, at 15:18, stepharo <stepharo@free.fr> wrote:
I would like to be able to express
Compiler new bindings: { a -> 3. b -> 4}; evaluate: 'a + b'; result and get 7
How can I do that?
Not directly, as evaluate is just a doit⦠but it can be added as the machinery is there for evaluating in context in the debugger.
I will have a look but not this weekend.
Marcus
participants (5)
-
Marcus Denker -
Nicolai Hess -
Sean P. DeNigris -
stepharo -
Thierry Goubier