diff options
| author | Zuhaitz <zuhaitz.zechhub@gmail.com> | 2026-01-26 00:39:31 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-26 00:39:31 +0000 |
| commit | ca08979910e5a234a2423e4448ad0e284bf4f508 (patch) | |
| tree | e09702f7b0850feb00a6af7f315bff7448c2ed26 /examples | |
| parent | 6bef876bf900458a36260ca3fe96e23b06749d74 (diff) | |
| parent | 97d0583c92c733aa8497a99f5267d50151f6e965 (diff) | |
Merge pull request #132 from Burnett01/fix/var-const-remains-in-examples
Housekeeping: Fix var/const remains in examples and docs
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/algorithms/sieve.zc | 2 | ||||
| -rw-r--r-- | examples/gpu/cuda-benchmark.zc | 8 | ||||
| -rw-r--r-- | examples/gpu/cuda_vector_add.zc | 4 | ||||
| -rw-r--r-- | examples/process/env.zc | 8 | ||||
| -rw-r--r-- | examples/scripting/lua/lua.zc | 10 |
5 files changed, 16 insertions, 16 deletions
diff --git a/examples/algorithms/sieve.zc b/examples/algorithms/sieve.zc index 2f5680e..147d71f 100644 --- a/examples/algorithms/sieve.zc +++ b/examples/algorithms/sieve.zc @@ -2,7 +2,7 @@ import "std.zc" fn main() { - const LIMIT = 50; + def LIMIT = 50; let is_prime: bool[LIMIT]; for i in 0..LIMIT { is_prime[i] = true; } diff --git a/examples/gpu/cuda-benchmark.zc b/examples/gpu/cuda-benchmark.zc index cea326e..8f4a85d 100644 --- a/examples/gpu/cuda-benchmark.zc +++ b/examples/gpu/cuda-benchmark.zc @@ -194,7 +194,7 @@ fn benchmark_matrix_multiply(N: int) { cuda_copy_to_device(d_B, h_B, size * sizeof(float)); // Configure grid - const BLOCK_SIZE = 16; + def BLOCK_SIZE = 16; let blocks_per_grid = (N + BLOCK_SIZE - 1) / BLOCK_SIZE; "-> Launching kernel: {blocks_per_grid}x{blocks_per_grid} blocks, {BLOCK_SIZE}x{BLOCK_SIZE} threads each"; @@ -232,8 +232,8 @@ fn benchmark_monte_carlo_pi(num_samples: u64) { "-> Estimating Pi with {num_samples} samples"; - const BLOCK_SIZE = 256; - const NUM_BLOCKS = 1024; + def BLOCK_SIZE = 256; + def NUM_BLOCKS = 1024; let total_threads = BLOCK_SIZE * NUM_BLOCKS; // Allocate memory @@ -342,7 +342,7 @@ fn benchmark_nbody(num_bodies: int, num_steps: int) { cuda_copy_to_device(d_vy, h_vy, num_bodies * sizeof(float)); cuda_copy_to_device(d_vz, h_vz, num_bodies * sizeof(float)); - const BLOCK_SIZE = 256; + def BLOCK_SIZE = 256; let num_blocks = (num_bodies + BLOCK_SIZE - 1) / BLOCK_SIZE; let dt = 0.01f; diff --git a/examples/gpu/cuda_vector_add.zc b/examples/gpu/cuda_vector_add.zc index d1f896a..534950d 100644 --- a/examples/gpu/cuda_vector_add.zc +++ b/examples/gpu/cuda_vector_add.zc @@ -15,7 +15,7 @@ fn add_kernel(a: float*, b: float*, c: float*, n: int) { } fn main() { - const N = 1024; + def N = 1024; "=> Zen C CUDA Vector Addition"; "-> Vector size: {N} elements"; @@ -43,7 +43,7 @@ fn main() { cuda_copy_to_device(d_a, h_a, N * sizeof(float)); cuda_copy_to_device(d_b, h_b, N * sizeof(float)); - const BLOCK_SIZE = 256; + def BLOCK_SIZE = 256; let num_blocks = (N + BLOCK_SIZE - 1) / BLOCK_SIZE; "-> Launching: {num_blocks} blocks x {BLOCK_SIZE} threads"; diff --git a/examples/process/env.zc b/examples/process/env.zc index 0ea7437..d202ef2 100644 --- a/examples/process/env.zc +++ b/examples/process/env.zc @@ -4,7 +4,7 @@ import "std/env.zc" fn main() -> int { // ---- - // get: Retrieves the env-let as borrowed string (char *) (no alloc) + // get: Retrieves the env-variable as borrowed string (char *) (no alloc) // --- // @Example usage: On Linux (and some variants) PATH is already defined. // --- @@ -17,8 +17,8 @@ fn main() -> int { } // ---- - // set: Sets an env-let variable - // get_dup: Retrieves the env-let as caller-owned String() (heap alloc) + // set: Sets an env-variable + // get_dup: Retrieves the env-variable as caller-owned String() (heap alloc) // --- // @Example usage: In your terminal type "export HELLO=world" or use Env::set() // --- @@ -37,7 +37,7 @@ fn main() -> int { } // ---- - // unset: Unsets an existing env-let + // unset: Unsets an existing env-variable // --- Env::unset("HELLO"); diff --git a/examples/scripting/lua/lua.zc b/examples/scripting/lua/lua.zc index a8463fa..ebd3ae6 100644 --- a/examples/scripting/lua/lua.zc +++ b/examples/scripting/lua/lua.zc @@ -8,7 +8,7 @@ import "lauxlib.h"; import "lualib.h"; fn l_zenc_hello(L: lua_State*) -> int { - const name: string = (string)luaL_optstring(L, 1, "world"); + let name: string = (string)luaL_optstring(L, 1, "world"); println "hello from Zen-C, {name}" return 0; } @@ -27,21 +27,21 @@ fn main() { lua_setglobal(L, "zenc_hello"); // Run some Lua from a Zen-C variable - const script = "print('hello from lua')\nzenc_hello('test')\n"; + let script = "print('hello from lua')\nzenc_hello('test')\n"; if (luaL_dostring(L, script) != LUA_OK) { - const err: string = (string)lua_tostring(L, -1); + let err: string = (string)lua_tostring(L, -1); !"lua error: {err}" lua_pop(L, 1); } // Run some Lua from a script file if (luaL_loadfile(L, "script.lua") != LUA_OK) { - const err: string = (string)lua_tostring(L, -1); + let err: string = (string)lua_tostring(L, -1); !"lua load-error: {err}" lua_pop(L, 1); } else if (lua_pcall(L, 0, 0, 0) != LUA_OK) { - const err: string = (string)lua_tostring(L, -1); + let err: string = (string)lua_tostring(L, -1); !"lua error: {err}" lua_pop(L, 1); } |
