defmacro added, doc improvements

This commit is contained in:
vaclavt
2022-01-29 15:35:42 +01:00
parent 249af03f60
commit f1d102130f
9 changed files with 155 additions and 97 deletions

32
ml.h
View File

@@ -102,7 +102,21 @@ typedef MlValue (*Builtin)(std::vector<MlValue>, MlEnvironment &);
class MlPerfMon;
class MlValue {
public:
enum Type {
QUOTE,
ATOM,
INT,
FLOAT,
LIST,
STRING,
LAMBDA,
MACRO,
BUILTIN,
NIL,
TRUE
} type;
public:
MlValue(); // Constructs a nil value
MlValue(long i);
@@ -116,7 +130,7 @@ public:
static MlValue string(const std::string &s);
static MlValue nil();
MlValue(const std::vector<MlValue> &params, MlValue ret, MlEnvironment const &env); // Construct a lambda function
MlValue(const std::vector<MlValue> &params, MlValue ret, MlEnvironment const &env, const Type ftype); // Construct a lambda or macro function
MlValue(const std::string &name, Builtin b); // Construct a builtin function
std::vector<std::string> get_used_atoms();
@@ -128,6 +142,7 @@ public:
MlValue eval(MlEnvironment &env);
bool is_builtin() const;
bool is_macro() const;
bool is_number() const;
bool is_string() const;
bool is_list() const;
@@ -175,19 +190,6 @@ public:
friend std::ostream &operator<<(std::ostream &os, MlValue const &v);
private:
enum {
QUOTE,
ATOM,
INT,
FLOAT,
LIST,
STRING,
LAMBDA,
BUILTIN,
NIL,
TRUE
} type;
union {
long i;
double f;