isCallable

This commit is contained in:
dzaima 2021-05-09 20:05:34 +03:00
parent 64e716af6f
commit 9893a8bd97
4 changed files with 8 additions and 6 deletions

View File

@ -289,6 +289,7 @@ bool isF64(B x) { return (x.u<<1) - ((0xFFEull<<52) + 2) >= (1ull<<52) - 2; }
bool isNum(B x) { return isF64(x)|isI32(x); }
bool isAtm(B x) { return !isArr(x); }
bool isCallable(B x) { return isMd(x) | isFun(x); }
bool noFill(B x);
// shape mess

View File

@ -60,14 +60,13 @@ int main() {
// uncomment to self-compile and use that for the REPL
// expects a copy of mlochbaum/BQN/src/c.bqn to be at the execution directory (with •args replaced with the array in glyphs.bqn)
// char* c_src = NULL;
// u64 c_len;
// FILE* f = fopen("c.bqn", "rb");
// if (f) {
// fseek(f, 0, SEEK_END);
// c_len = ftell(f);
// fseek(f, 0, SEEK_SET);
// c_src = malloc(c_len);
// fseek(f, 0, SEEK_END); c_len = ftell(f);
// fseek(f, 0, SEEK_SET); c_src = malloc(c_len);
// if (c_src) fread(c_src, 1, c_len, f);
// fclose(f);
// } else {
@ -75,11 +74,13 @@ int main() {
// }
// if (c_src) {
// bqn_setComp(bqn_exec(fromUTF8(c_src, c_len)));
// // for (i32 i = 0; i < 100; i++) { dec(bqn_exec(fromUTF8(c_src, c_len))); gc_maybeGC(); }
// } else {
// printf("couldn't read c.bqn\n");
// exit(1);
// }
while (CATCH) {
printf("caught: ");
print(catchMessage);

View File

@ -2,7 +2,7 @@
bool isPureFn(B x) { // doesn't consume
if (!isFun(x) && !isMd(x)) return true;
if (!isCallable(x)) return true;
if (v(x)->flags) return true;
B2B dcf = TI(x).decompose;
B xd = dcf(inc(x));

View File

@ -95,7 +95,7 @@ void printRaw(B x) {
}
}
B def_decompose(B x) { return m_v2(m_i32((isFun(x)|isMd(x))? 0 : -1),x); }
B def_decompose(B x) { return m_v2(m_i32(isCallable(x)? 0 : -1),x); }
bool atomEqual(B w, B x) { // doesn't consume (not that that matters really currently)
if(isF64(w)&isF64(x)) return w.f==x.f;
if (w.u==x.u) return true;