summaryrefslogtreecommitdiffhomepage
path: root/misc/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-02-22 18:39:53 +0100
committerTyge Løvset <[email protected]>2023-02-22 18:39:53 +0100
commit95f0b246cedc2d3669575ed2bfb398e6fbcb2b2f (patch)
treeacc1d8e237915baaef4504540eb3d030728f3953 /misc/examples
parentb63df794ee2bda2c33856a646ca6e1386f5ab782 (diff)
downloadSTC-modified-95f0b246cedc2d3669575ed2bfb398e6fbcb2b2f.tar.gz
STC-modified-95f0b246cedc2d3669575ed2bfb398e6fbcb2b2f.zip
Renamed ccontext => cco_handle
Diffstat (limited to 'misc/examples')
-rw-r--r--misc/examples/cofib.c10
-rw-r--r--misc/examples/coread.c6
2 files changed, 8 insertions, 8 deletions
diff --git a/misc/examples/cofib.c b/misc/examples/cofib.c
index d0e4ac2a..2363989a 100644
--- a/misc/examples/cofib.c
+++ b/misc/examples/cofib.c
@@ -6,10 +6,10 @@
typedef long long llong;
-llong fibonacci_sequence(ccontext* ctx, unsigned n) {
+llong fibonacci_sequence(cco_handle* z, unsigned n) {
assert (n < 95);
- cco_context(ctx,
+ cco_context(z,
llong a, b, idx;
);
@@ -17,10 +17,10 @@ llong fibonacci_sequence(ccontext* ctx, unsigned n) {
u->a = 0;
u->b = 1;
for (u->idx = 2; u->idx < n; u->idx++) {
- llong sum = u->a + u->b;
- cco_yield(sum);
+ llong sum = u->a + u->b; // NB! locals only lasts until a cco_yield!
u->a = u->b;
u->b = sum;
+ cco_yield (sum);
}
cco_finish:
);
@@ -29,7 +29,7 @@ llong fibonacci_sequence(ccontext* ctx, unsigned n) {
int main(void) {
- ccontext z = 0;
+ cco_handle z = 0;
printf("Fibonacci numbers:\n");
for (;;) {
llong x = fibonacci_sequence(&z, 30);
diff --git a/misc/examples/coread.c b/misc/examples/coread.c
index 9181401d..55e4bf21 100644
--- a/misc/examples/coread.c
+++ b/misc/examples/coread.c
@@ -4,9 +4,9 @@
// Read file line by line using coroutines:
-cstr file_nextline(ccontext* ccx, const char* name)
+cstr file_nextline(cco_handle* z, const char* name)
{
- cco_context(ccx,
+ cco_context(z,
FILE* fp;
cstr line;
);
@@ -28,7 +28,7 @@ cstr file_nextline(ccontext* ccx, const char* name)
int main(void) {
- ccontext z = 0;
+ cco_handle z = 0;
int n = 0;
do {
c_with (cstr line = file_nextline(&z, __FILE__), z, cstr_drop(&line)) {