lean2/src/library/hidden_defs.h
Leonardo de Moura f97c260b0b refactor(kernel/environment): add ro_environment
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>
2013-12-12 16:48:34 -08:00

37 lines
1 KiB
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 "util/lua.h"
namespace lean {
class environment;
class ro_environment;
class name;
/**
\brief Return true iff the definition named \c d is hidden in
the given environment.
This information is just a hint used by tactics and solvers. For
example, unfold_tactic uses it to decide whether a definition
should be unfolded or not.
*/
bool is_hidden(ro_environment const & env, name const & d);
/**
\brief Mark the definition named \c d as hidden in the given environment.
\see is_hidden
\remark It throws an exception if \c d is not a definition in \c env.
*/
void set_hidden_flag(environment const & env, name const & d, bool flag = true);
/**
\brief Hide definitions at builtin.cpp. We hide them here because
the hidden_defs module is not part of the kernel.
*/
void hide_builtin(environment const & env);
void open_hidden_defs(lua_State * L);
}