Slots only drive access to the instance variables and the association
"literal" is already a message send. But I guess you wold be able to do
such behavior with own Opal plugin.

-- Pavel

2017-03-01 15:56 GMT+01:00 Ben Coman <[email protected]>:

>
> I'm not sure I'm thinking straight, but I wonder...
> Can you put Slots inside an Association?
>
> For example, could have two slots x and y,
> and then be able to do the following...
>
>     (x -> y) substitute: (1 -> 2).
>     self assert: x equals: 1.
>     self assert: y equals: 2.
>
> So the association method #substitute:
> assigns into the relevant variables.
>
> And even better if you could do...
>     (x -> y) := (1 -> 2).
> and...
>     { x. y ) := #(1 2).
>
> For example, when you're hacking fast and want to return two values from a
> method without mucking around with creating an object for this, it might
> look like...
>     myCalc
>         ^#(1 2)
>
> but instead of...
>     result := inst myCalc.
>     x := result at: 1.
>     y := result at: 2.
>
> you could do...
>     { x . y } := inst myCalc.
>
> cheers -ben
>

Reply via email to