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 <[hidden email]> 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 <[hidden email]>:
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 |
In reply to this post by Marcus Denker-4
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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 >> >> >> > > |
Administrator
|
In reply to this post by Nicolai Hess
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 |
2015-02-04 23:07 GMT+01:00 Sean P. DeNigris <[hidden email]>: Nicolai Hess wrote That's interesting. We lost this feature in 40097
|
Administrator
|
Which feature? Using bare associations instead of WorkspaceVariables?
Cheers,
Sean |
2015-02-05 2:20 GMT+01:00 Sean P. DeNigris <[hidden email]>: Nicolai Hess wrote 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:
|
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
|
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 |
2015-05-05 15:17 GMT+02:00 Marcus Denker <[hidden email]>:
Thanks Marcus, this should be very convenient. Thierry
|
Administrator
|
In reply to this post by Marcus Denker-4
Cool :)
Cheers,
Sean |
In reply to this post by Marcus Denker-4
Nice :)
|
Free forum by Nabble | Edit this page |