From dcadd54d64d13dba04784df68570475e389187b7 Mon Sep 17 00:00:00 2001 From: glenda Date: Fri, 9 Sep 2022 21:28:52 +0000 Subject: Add thread names --- operators.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'operators.c') diff --git a/operators.c b/operators.c index 5359a54..20c8611 100644 --- a/operators.c +++ b/operators.c @@ -4,15 +4,14 @@ #include "apl9.h" -Rune primmonopnames[] = L"¨⍨⌸⌶&⌾∆⍇"; -Rune primdyadopnames[] = L"⍣.∘⍤⍥@⍠⌺⍢⍫⍙"; +Rune primmonopnames[] = L"¨⍨⌸⌶⌾∆⍇"; +Rune primdyadopnames[] = L"⍣.∘⍤⍥@⍠⌺⍢⍫⍙&"; opmonad monadoperatordefs[] = { opEach, /* ¨ */ opSwitch, /* ⍨ */ opKey, /* ⌸ */ 0, /* ⌶ */ - opSpawn, /* & */ opOuterProduct, /* ⌾ */ opSelfReference1, /* ∆ */ opReceive, /* ⍇ */ @@ -30,6 +29,7 @@ opdyad dyadoperatordefs[] = { opUnder, /* ⍢ */ opObverse, /* ⍫ */ opSelfReference2, /* ⍙ */ + opSpawn, /* & */ }; /* Monadic operators */ @@ -93,15 +93,6 @@ opKey(Datum *lefto, Array *left, Array *right) return rundfn(L"⍵⍶⌸⍳≢⍵", lefto, nil, left, right); } -Array * -opSpawn(Datum *lefto, Array *left, Array *right) -{ - if(lefto->tag != FunctionTag) - throwerror(L"Can only spawn functions", ESyntax); - int id = spawnthread(lefto->func, left, right); - return mkscalarint(id); -} - Array * opOuterProduct(Datum *lefto, Array *left, Array *right) { @@ -370,4 +361,17 @@ opSelfReference2(Datum *lefto, Datum *righto, Array *left, Array *right) throwerror(nil, ESyntax); return nil; } +} + +Array * +opSpawn(Datum *lefto, Datum *righto, Array *left, Array *right) +{ + if(lefto->tag != FunctionTag) + throwerror(L"Can only spawn functions", ESyntax); + if(righto->tag != ArrayTag + || GetType(righto->array) != AtypeRune + || GetRank(righto->array) != 1) + throwerror(L"Thread name must be a character vector", EDomain); + int id = spawnthread(lefto->func, righto->array, left, right); + return mkscalarint(id); } \ No newline at end of file -- cgit v1.2.3