@@ -22,32 +22,32 @@ any::any(const any& val) : type(val.type) {
2222 case Type::Double: d = val.d; break;
2323 case Type::Character: c = val.c; break;
2424 case Type::Boolean: b = val.b; break;
25− case Type::String: new (&s) shared_string (val.s); break;
26− case Type::Map: new (&m) shared_map (val.m); break;
27− case Type::Vector: new (&v) shared_vector (val.v); break;
28− case Type::Function: new (&f) shared_fn (val.f); break;
29− case Type::EffFunction: new (&e) shared_eff_fn (val.e); break;
30− case Type::Thunk: new (&t) shared_thunk (val.t); break;
31− case Type::Pointer: new (&p) shared_void_ptr (val.p); break;
25+ case Type::String: new (&s) shared<string> (val.s); break;
26+ case Type::Map: new (&m) shared<map> (val.m); break;
27+ case Type::Vector: new (&v) shared<vector> (val.v); break;
28+ case Type::Function: new (&f) shared<fn> (val.f); break;
29+ case Type::EffFunction: new (&e) shared<eff_fn> (val.e); break;
30+ case Type::Thunk: new (&t) shared<thunk> (val.t); break;
31+ case Type::Pointer: new (&p) shared<void> (val.p); break;
3232
3333 default: assert(false && "Unsupported type in copy ctor");
3434 }
3535}
3636
37−void any::swap(any&& val) {
37+void any::swap(any&& val) const {
3838 type = val.type;
3939 switch (type) {
4040 case Type::Integer: i = val.i; break;
4141 case Type::Double: d = val.d; break;
4242 case Type::Character: c = val.c; break;
4343 case Type::Boolean: b = val.b; break;
44− case Type::String: new (&s) shared_string (std::move(val.s)); break;
45− case Type::Map: new (&m) shared_map (std::move(val.m)); break;
46− case Type::Vector: new (&v) shared_vector (std::move(val.v)); break;
47− case Type::Function: new (&f) shared_fn (std::move(val.f)); break;
48− case Type::EffFunction: new (&e) shared_eff_fn (std::move(val.e)); break;
49− case Type::Thunk: new (&t) shared_thunk (std::move(val.t)); break;
50− case Type::Pointer: new (&p) shared_void_ptr (std::move(val.p)); break;
44+ case Type::String: new (&s) shared<string> (std::move(val.s)); break;
45+ case Type::Map: new (&m) shared<map> (std::move(val.m)); break;
46+ case Type::Vector: new (&v) shared<vector> (std::move(val.v)); break;
47+ case Type::Function: new (&f) shared<fn> (std::move(val.f)); break;
48+ case Type::EffFunction: new (&e) shared<eff_fn> (std::move(val.e)); break;
49+ case Type::Thunk: new (&t) shared<thunk> (std::move(val.t)); break;
50+ case Type::Pointer: new (&p) shared<void> (std::move(val.p)); break;
5151
5252 default: assert(false && "Unsupported type in move ctor");
5353 }
@@ -60,13 +60,13 @@ any::~any() {
6060 case Type::Double: ; break;
6161 case Type::Character: ; break;
6262 case Type::Boolean: ; break;
63− case Type::String: s.~shared_string(); break;
64− case Type::Map: m.~shared_map(); break;
65− case Type::Vector: v.~shared_vector(); break;
66− case Type::Function: f.~shared_fn(); break;
67− case Type::EffFunction: e.~shared_eff_fn(); break;
68− case Type::Thunk: t.~shared_thunk(); break;
69− case Type::Pointer: p.~shared_void_ptr(); break;
63+ case Type::String: s.~shared<string>(); break;
64+ case Type::Map: m.~shared<map>(); break;
65+ case Type::Vector: v.~shared<vector>(); break;
66+ case Type::Function: f.~shared<fn>(); break;
67+ case Type::EffFunction: e.~shared<eff_fn>(); break;
68+ case Type::Thunk: t.~shared<thunk>(); break;
69+ case Type::Pointer: p.~shared<void>(); break;
7070
7171 default: assert(false && "Unsupported type in destructor");
7272 }
@@ -229,21 +229,21 @@ any::~any() {
229229
230230#define DEFINE_OPERATOR_LHS(K, T, OP, V, R, P) \
231231auto operator OP(const T lhs, const any& rhs_) -> R { \
232− auto& rhs = any::extract_value(rhs_); \
232+ const any& rhs = any::extract_value(rhs_); \
233233 assert(rhs.type == any::Type::K); \
234234 return lhs OP P(rhs.V); \
235235}
236236
237237#define DEFINE_OPERATOR_RHS(K, T, OP, V, R, P) \
238238auto any::operator OP(const T rhs) const -> R { \
239− auto& lhs = any::extract_value(*this); \
239+ const any& lhs = any::extract_value(*this); \
240240 assert(lhs.type == Type::K); \
241241 return P(lhs.V) OP rhs; \
242242}
243243
244244auto any::operator==(const any& rhs_) const -> bool {
245− auto& lhs = extract_value(*this);
246− auto& rhs = extract_value(rhs_);
245+ const any& lhs = extract_value(*this);
246+ const any& rhs = extract_value(rhs_);
247247 assert(lhs.type == rhs.type);
248248 switch (lhs.type) {
249249 case Type::Integer: return lhs.i == rhs.i;
@@ -265,8 +265,8 @@ DEFINE_OPERATOR_RHS(String, string&, ==, s, bool, *)
265265DEFINE_OPERATOR_RHS(String, char* const, ==, s, bool, *)
266266
267267auto any::operator!=(const any& rhs_) const -> bool {
268− auto& lhs = extract_value(*this);
269− auto& rhs = extract_value(rhs_);
268+ const any& lhs = extract_value(*this);
269+ const any& rhs = extract_value(rhs_);
270270 assert(lhs.type == rhs.type);
271271 switch (lhs.type) {
272272 case Type::Integer: return lhs.i != rhs.i;
@@ -288,8 +288,8 @@ DEFINE_OPERATOR_RHS(String, string&, !=, s, bool, *)
288288DEFINE_OPERATOR_RHS(String, char* const, !=, s, bool, *)
289289
290290auto any::operator<(const any& rhs_) const -> bool {
291− auto& lhs = extract_value(*this);
292− auto& rhs = extract_value(rhs_);
291+ const any& lhs = extract_value(*this);
292+ const any& rhs = extract_value(rhs_);
293293 assert(lhs.type == rhs.type);
294294 switch (lhs.type) {
295295 case Type::Integer: return lhs.i < rhs.i;
@@ -310,8 +310,8 @@ DEFINE_OPERATOR_RHS(String, string&, <, s, bool, *)
310310DEFINE_OPERATOR_RHS(String, char* const, <, s, bool, *)
311311
312312auto any::operator<=(const any& rhs_) const -> bool {
313− auto& lhs = extract_value(*this);
314− auto& rhs = extract_value(rhs_);
313+ const any& lhs = extract_value(*this);
314+ const any& rhs = extract_value(rhs_);
315315 assert(lhs.type == rhs.type);
316316 switch (lhs.type) {
317317 case Type::Integer: return lhs.i <= rhs.i;
@@ -332,8 +332,8 @@ DEFINE_OPERATOR_RHS(String, string&, <=, s, bool, *)
332332DEFINE_OPERATOR_RHS(String, char* const, <=, s, bool, *)
333333
334334auto any::operator>(const any& rhs_) const -> bool {
335− auto& lhs = extract_value(*this);
336− auto& rhs = extract_value(rhs_);
335+ const any& lhs = extract_value(*this);
336+ const any& rhs = extract_value(rhs_);
337337 assert(lhs.type == rhs.type);
338338 switch (lhs.type) {
339339 case Type::Integer: return lhs.i > rhs.i;
@@ -354,8 +354,8 @@ DEFINE_OPERATOR_RHS(String, string&, >, s, bool, *)
354354DEFINE_OPERATOR_RHS(String, char* const, >, s, bool, *)
355355
356356auto any::operator>=(const any& rhs_) const -> bool {
357− auto& lhs = extract_value(*this);
358− auto& rhs = extract_value(rhs_);
357+ const any& lhs = extract_value(*this);
358+ const any& rhs = extract_value(rhs_);
359359 assert(lhs.type == rhs.type);
360360 switch (lhs.type) {
361361 case Type::Integer: return lhs.i >= rhs.i;
@@ -376,8 +376,8 @@ DEFINE_OPERATOR_RHS(String, string&, >=, s, bool, *)
376376DEFINE_OPERATOR_RHS(String, char* const, >=, s, bool, *)
377377
378378auto any::operator+(const any& rhs_) const -> any {
379− auto& lhs = extract_value(*this);
380− auto& rhs = extract_value(rhs_);
379+ const any& lhs = extract_value(*this);
380+ const any& rhs = extract_value(rhs_);
381381 assert(lhs.type == rhs.type);
382382 switch (lhs.type) {
383383 case Type::Integer: return lhs.i + rhs.i;
@@ -396,8 +396,8 @@ DEFINE_OPERATOR_RHS(String, string&, +, s, string, *)
396396DEFINE_OPERATOR_RHS(String, char* const, +, s, string, *)
397397
398398auto any::operator-(const any& rhs_) const -> any {
399− auto& lhs = extract_value(*this);
400− auto& rhs = extract_value(rhs_);
399+ const any& lhs = extract_value(*this);
400+ const any& rhs = extract_value(rhs_);
401401 assert(lhs.type == rhs.type);
402402 switch (lhs.type) {
403403 case Type::Integer: return lhs.i - rhs.i;
@@ -413,8 +413,8 @@ DEFINE_OPERATOR_RHS(Double, double, -, d, double,)
413413DEFINE_OPERATOR_RHS(Character, char, -, c, char,)
414414
415415auto any::operator*(const any& rhs_) const -> any {
416− auto& lhs = extract_value(*this);
417− auto& rhs = extract_value(rhs_);
416+ const any& lhs = extract_value(*this);
417+ const any& rhs = extract_value(rhs_);
418418 assert(lhs.type == rhs.type);
419419 switch (lhs.type) {
420420 case Type::Integer: return lhs.i * rhs.i;
@@ -428,8 +428,8 @@ DEFINE_OPERATOR_RHS(Integer, long, *, i, long,)
428428DEFINE_OPERATOR_RHS(Double, double, *, d, double,)
429429
430430auto any::operator/(const any& rhs_) const -> any {
431− auto& lhs = extract_value(*this);
432− auto& rhs = extract_value(rhs_);
431+ const any& lhs = extract_value(*this);
432+ const any& rhs = extract_value(rhs_);
433433 assert(lhs.type == rhs.type);
434434 switch (lhs.type) {
435435 case Type::Integer: return lhs.i / rhs.i;
@@ -443,8 +443,8 @@ DEFINE_OPERATOR_RHS(Integer, long, /, i, long,)
443443DEFINE_OPERATOR_RHS(Double, double, /, d, double,)
444444
445445auto any::operator%(const any& rhs_) const -> any {
446− auto& lhs = extract_value(*this);
447− auto& rhs = extract_value(rhs_);
446+ const any& lhs = extract_value(*this);
447+ const any& rhs = extract_value(rhs_);
448448 assert(lhs.type == rhs.type);
449449 switch (lhs.type) {
450450 case Type::Integer: return lhs.i % rhs.i;
@@ -456,7 +456,7 @@ auto any::operator%(const any& rhs_) const -> any {
456456DEFINE_OPERATOR_RHS(Integer, long, %, i, long,)
457457
458458auto any::operator-() const -> any {
459− auto& lhs = any::extract_value(*this);
459+ const any& lhs = any::extract_value(*this);
460460 switch (lhs.type) {
461461 case Type::Integer: return (- lhs.i);
462462 case Type::Double: return (- lhs.d);