Subject: Re: [proto] Visitor Design Pattern
From: Eric Niebler (eric_at_[hidden])
Date: 2012-07-22 19:07:17
On 10/25/2010 10:03 PM, Eric Niebler wrote:
> On 10/25/2010 10:01 PM, Joel.Falcou_at_[hidden] wrote:
>>> There, that's better. I don't think I'll mess with it any more. Go ahead
>>> and use it, Thomas.
>> just a small question: what if I need a transform that use external data ?
>> in nt2, we have thsi compute trnsform that recursively eats the AST and
>> call the approprite function passing a n dimension position tuple as a
>> I guess I could pass it as a state but will we have any other alternative ?
> You could pass it as state or bundle it with the external transforms.
> All you need is a nested when template. Does that help?
[Resurrecting this ancient thread]
This was the thread that led to the current design of external
transforms, which uses the data parameter. Joel here wanted to know how
to use external transforms if you're already using the data parameter
for something else. I never felt good about the answer, and now I have a
better one: use the transform environment slot I've created for this
MyEval( expr, state, (proto::data = foo, proto::transforms = bar) );
In this case, bar is an object of a type derived from
proto::external_transforms that contains the mapping from rules to
The proto::_data transform will only return the value of foo.
The change is backward compatible. If the "proto::transform" key is not
found in the environment, or the environment is an old-style blob,
things behave as they did before.
This change lives on trunk and will be moved to release after 1.51 ships.
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Proto list run by eric at boostpro.com