Skip to content

Commit ed2124a

Browse files
committed
constness
1 parent 002542a commit ed2124a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

arc.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ namespace arc {
4040
return a.as<arc::cons>().cdr;
4141
}
4242

43-
bool no(atom & a) {
43+
bool no(const atom & a) {
4444
return a.type == arc::T_NIL;
4545
}
4646

47-
bool sym_is(atom & a, atom & b) {
47+
bool sym_is(const atom & a, const atom & b) {
4848
return a.as<std::string *>() == b.as<std::string *>();
4949
}
5050

5151
bool operator ==(const atom &a, const atom &b) {
5252
return iso(a, b);
5353
}
5454

55-
atom make_cons(atom car_val, atom cdr_val)
55+
atom make_cons(const atom &car_val, const atom &cdr_val)
5656
{
5757
atom a;
5858
a.type = T_CONS;
@@ -989,7 +989,7 @@ Addition. This operator also performs string and list concatenation.
989989
return apply(fn, v, result);
990990
}
991991

992-
bool is(atom a, atom b) {
992+
bool is(const atom &a, const atom &b) {
993993
if (a.type == b.type) {
994994
switch (a.type) {
995995
case T_NIL:
@@ -1021,7 +1021,7 @@ Addition. This operator also performs string and list concatenation.
10211021
return false;
10221022
}
10231023

1024-
bool iso(atom a, atom b) {
1024+
bool iso(const atom &a, const atom &b) {
10251025
if (a.type == b.type) {
10261026
switch (a.type) {
10271027
case T_CONS:

arc.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#endif
3535

3636
namespace arc {
37-
constexpr auto VERSION = "0.21";
37+
constexpr auto VERSION = "0.21.1";
3838

3939
enum type {
4040
T_NIL,
@@ -65,7 +65,7 @@ namespace arc {
6565
std::shared_ptr<void> p; // reference-counted pointer
6666

6767
template <typename T>
68-
T &as() {
68+
T& as() const {
6969
return *std::static_pointer_cast<T>(p);
7070
}
7171

@@ -111,15 +111,15 @@ namespace arc {
111111
error read_expr(const char *input, const char **end, atom *result);
112112
void print_expr(atom a);
113113
void print_error(error e);
114-
bool is(atom a, atom b);
115-
bool iso(atom a, atom b);
114+
bool is(const atom &a, const atom &b);
115+
bool iso(const atom& a, const atom& b);
116116
atom make_table();
117117
void repl();
118-
atom make_cons(atom car_val, atom cdr_val);
118+
atom make_cons(const atom &car_val, const atom &cdr_val);
119119
atom & car(atom & a);
120120
atom & cdr(atom & a);
121-
bool no(atom & a);
122-
bool sym_is(atom & a, atom & b);
121+
bool no(const atom & a);
122+
bool sym_is(const atom & a, const atom & b);
123123
/* end forward */
124124
}
125125

0 commit comments

Comments
 (0)