Thanks for your explanations.

IHMO, from a user point of view, the interface of open()/prepare() is
not well designed. It specifies to hand-in a Java-Map, and you would not
expect that a Map is not modifiable.

Would it be possible to change the parameter type to
clojure.lang.APersistentMap ? This would expose the persistent nature of
the map to the user. Not sure if this is possible, due to compatibility
issues... It's just a thought.

-Matthias


On 04/23/2015 06:10 PM, Bobby Evans wrote:
> Yes you could all assoc on the Map, if you cast the map to an IPersistentMap 
> and call the assoc method on it, but if you do it blindly without checking 
> they actual type of the Map passed in you may run into issues in the future, 
> if we do change some internals away from java.
>  - Bobby
>  
> 
> 
>      On Thursday, April 23, 2015 9:07 AM, Jeremy Heiler 
> <[email protected]> wrote:
>    
> 
>  On Thu, Apr 23, 2015 at 4:42 AM, Matthias J. Sax <
> [email protected]> wrote:
> 
>> In my case, I use a class hierarchy with abstract spouts/bolts and
>> multiple concrete spouts/bolts. The abstract class uses some default
>> values (if not provided in the given config) similar to the derived
>> classes. However, some derived classes overwrite the default values for
>> the abstract class, ie, if no value is given in the config, some derived
>> classes set the values and other do not. Additionally, open()/prepare()
>> of the abstract class is called, too, and set the default value if the
>> value was neither provided by the user, not by the derived class.
>>
>>
> The idiomatic way to update an immutable field like this in Clojure would
> be to use an atom. Here you could store the conf in an AtomicReference
> field, call .assoc on the map to update it, and .compareAndSet it on the
> AtomicReference. I'm not sure you'll need this, but I figured I'd mention
> it as how you would use a PersistentHashMap in your situation.
> 
> 
>   
> 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to