I think the reason it is const is just because no one asked for it (I was requesting this method for implementing some debugging features and didn’t need to alter it).
I can’t think of any scenario that might cause harms if you change the NamedValueSet. Take for instance the assignment of a UnqualifiedName:
void assign (const Scope& s, const var& newValue) const override
{
if (var* v = getPropertyPointer (s.scope, name))
*v = newValue;
else
s.root->setProperty (name, newValue);
}
So even if you do the most evil thing possible and delete a property (which I would not recommend), it just sets it again - we’ll ignore the race condition that might occur if you delete it on another thread just after the pointer was created in the if-condition since the whole engine is not threadsafe at all.
It would be more problematic if this assignment would store a pointer to a var in the NamedValueSet which changes as soon as you call a non const method on the NamedValueSet.