f97c260b0b
The environment object is a "smart-pointer". Before this commit, the use of "const &" for environment objects was broken. For example, suppose we have a function f that should not modify the input environment. Before this commit, its signature would be void f(environment const & env) This is broken, f's implementation can easilty convert it to a read-write pointer by using the copy constructor. environment rw_env(env); Now, f can use rw_env to update env. To fix this issue, we now have ro_environment. It is a shared *const* pointer. We can convert an environment into a ro_environment, but not the other way around. ro_environment can also be seen as a form of documentation. For example, now it is clear that type_inferer is not updating the environment, since its constructor takes a ro_environment. Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
25 lines
871 B
C++
25 lines
871 B
C++
/*
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Author: Leonardo de Moura
|
|
*/
|
|
#pragma once
|
|
#include <iostream>
|
|
#include <utility>
|
|
#include "kernel/expr.h"
|
|
#include "kernel/context.h"
|
|
|
|
namespace lean {
|
|
class ro_environment;
|
|
std::ostream & operator<<(std::ostream & out, context const & ctx);
|
|
std::ostream & operator<<(std::ostream & out, expr const & e);
|
|
std::ostream & operator<<(std::ostream & out, std::pair<expr const &, context const &> const & p);
|
|
class object;
|
|
std::ostream & operator<<(std::ostream & out, object const & obj);
|
|
std::ostream & operator<<(std::ostream & out, ro_environment const & env);
|
|
}
|
|
void print(lean::expr const & a);
|
|
void print(lean::expr const & a, lean::context const & c);
|
|
void print(lean::context const & c);
|
|
void print(lean::ro_environment const & e);
|