Skip to content

Commit

Permalink
Remove free function is_truthy
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Oct 24, 2023
1 parent 8742f50 commit a1244ab
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 27 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/version.cpp ${CMAKE_CURRENT

add_library(kernel SHARED)

add_library(${PROJECT_NAME}::kernel ALIAS kernel)

file(GLOB_RECURSE ${PROJECT_NAME}_KERNEL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*/*.cpp)

target_sources(kernel PRIVATE ${${PROJECT_NAME}_KERNEL_SOURCES})
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Procedures for each standard are provided by the following R7RS-style libraries:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cd build
make package
sudo apt install build/meevax_0.5.60_amd64.deb
sudo apt install build/meevax_0.5.61_amd64.deb
```

or
Expand Down Expand Up @@ -123,9 +123,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.60.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.61.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.60_amd64.deb`
| `package` | Generate debian package `meevax_0.5.61_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.60
0.5.61
3 changes: 1 addition & 2 deletions include/meevax/kernel/boolean.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ namespace meevax
inline namespace kernel
{
let extern const t;
let extern const f;

auto is_truthy(object const&) -> bool;
let extern const f;
} // namespace kernel
} // namespace meevax

Expand Down
2 changes: 1 addition & 1 deletion include/meevax/kernel/dynamic_environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ inline namespace kernel
* where c' = (if <boolean> c1 c2)
*
* ----------------------------------------------------------------- */
c = is_truthy(car(s)) ? cadr(c) : caddr(c);
c = car(s) != f ? cadr(c) : caddr(c);
s = cdr(s);
goto fetch;

Expand Down
14 changes: 7 additions & 7 deletions include/meevax/kernel/syntactic_environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,17 @@ inline namespace kernel
* call to one of their arguments. Exceptions are noted in the individual
* descriptions.
*
* Note: In contrast to other dialects of Lisp, the order of evaluation
* NOTE: In contrast to other dialects of Lisp, the order of evaluation
* is unspecified, and the operator expression and the operand
* expressions are always evaluated with the same evaluation rules.
*
* Note: Although the order of evaluation is otherwise unspecified, the
* NOTE: Although the order of evaluation is otherwise unspecified, the
* effect of any concurrent evaluation of the operator and operand
* expressions is constrained to be consistent with some sequential order
* of evaluation. The order of evaluation may be chosen differently for
* each procedure call.
*
* Note: In many dialects of Lisp, the empty list, (), is a legitimate
* NOTE: In many dialects of Lisp, the empty list, (), is a legitimate
* expression evaluating to itself. In Scheme, it is an error.
*
* ------------------------------------------------------------------ */
Expand Down Expand Up @@ -519,7 +519,7 @@ inline namespace kernel
* difference between the two is that include-ci reads each file as if it
* began with the #!fold-case directive, while include does not.
*
* Note: Implementations are encouraged to search for files in the
* NOTE: Implementations are encouraged to search for files in the
* directory which contains the including file, and to provide a way for
* users to specify other directories to search.
*
Expand Down Expand Up @@ -997,7 +997,7 @@ inline namespace kernel
}
else if (expression.is<syntactic_closure>())
{
if (let const& identity = std::as_const(*this).identify(expression, bound_variables, free_variables); is_truthy(identity)) // The syntactic-closure is an alias
if (let const& identity = std::as_const(*this).identify(expression, bound_variables, free_variables); identity != f) // The syntactic-closure is an alias
{
return syntax::reference(*this, expression, bound_variables, free_variables, continuation, tail);
}
Expand Down Expand Up @@ -1115,7 +1115,7 @@ inline namespace kernel
{
return f;
}
else if (let const& x = assq(variable, free_variables); is_truthy(x))
else if (let const& x = assq(variable, free_variables); x != f)
{
return cdr(x).as<injector>()(bound_variables);
}
Expand Down Expand Up @@ -1169,7 +1169,7 @@ inline namespace kernel
{
return f;
}
else if (let const& identity = std::as_const(*this).identify(variable, bound_variables, free_variables); is_truthy(identity))
else if (let const& identity = std::as_const(*this).identify(variable, bound_variables, free_variables); identity != f)
{
return identity;
}
Expand Down
6 changes: 1 addition & 5 deletions src/kernel/boolean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ namespace meevax
inline namespace kernel
{
let const t = make<bool>(true);
let const f = make<bool>(false);

auto is_truthy(object const& x) -> bool
{
return not eq(x, f);
}
let const f = make<bool>(false);
} // namespace kernel
} // namespace meevax
4 changes: 2 additions & 2 deletions src/kernel/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ inline namespace kernel

library.define<procedure>("not", [](let const& xs)
{
return not is_truthy(xs[0]);
return xs[0] == f;
});
});

Expand Down Expand Up @@ -283,7 +283,7 @@ inline namespace kernel
}
else if (let const& status = car(xs); status.is<bool>())
{
throw is_truthy(status) ? EXIT_SUCCESS : EXIT_FAILURE;
throw status != f ? EXIT_SUCCESS : EXIT_FAILURE;
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/kernel/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ inline namespace kernel
return filter([&](let const& identity)
{
assert(identity.is<absolute>());
return is_truthy(memq(car(identity), identities));
return memq(car(identity), identities) != f;
},
resolve(import_set));
};
Expand All @@ -141,7 +141,7 @@ inline namespace kernel
return filter([&](let const& identity)
{
assert(identity.is<absolute>());
return not is_truthy(memq(car(identity), identities));
return memq(car(identity), identities) == f;
},
resolve(import_set));
};
Expand Down Expand Up @@ -189,7 +189,7 @@ inline namespace kernel
assert(identity.is<absolute>());
assert(car(identity).is_also<identifier>());

if (let const& renaming = assq(car(identity), renamings); is_truthy(renaming))
if (let const& renaming = assq(car(identity), renamings); renaming != f)
{
assert(cadr(renaming).is<symbol>());
return make<absolute>(cadr(renaming), cdr(identity));
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/implementation_dependent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ inline namespace kernel
}
else
{
return eq(requirement, make_symbol("else")) or is_truthy(memq(requirement, features()));
return requirement == make_symbol("else") or memq(requirement, features()) != f;
}
}

Expand Down

0 comments on commit a1244ab

Please sign in to comment.