diff options
author | glenda <glenda@cirno> | 2022-09-09 21:28:52 +0000 |
---|---|---|
committer | glenda <glenda@cirno> | 2022-09-09 21:28:52 +0000 |
commit | dcadd54d64d13dba04784df68570475e389187b7 (patch) | |
tree | 4c57332e119a4129b7701b6a4ed48743c4441771 /operators.c | |
parent | d2b44ec9fc7bf4687dae74edfe708395461b5b6e (diff) |
Add thread names
Diffstat (limited to 'operators.c')
-rw-r--r-- | operators.c | 28 |
1 files changed, 16 insertions, 12 deletions
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 */ @@ -94,15 +94,6 @@ opKey(Datum *lefto, Array *left, Array *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) { if(left == nil) @@ -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 |