YUART
YUART
TSPThe Spawn Programming Language
Created by YUART on 6/17/2024 in #❓・help
YUART - How to implement this code in Spawn?...
going to be very similar to Go
23 replies
TSPThe Spawn Programming Language
Created by YUART on 6/17/2024 in #❓・help
YUART - How to implement this code in Spawn?...
23 replies
TSPThe Spawn Programming Language
Created by YUART on 6/17/2024 in #❓・help
YUART - How to implement this code in Spawn?...
Yeah, I removed that 😅
23 replies
TSPThe Spawn Programming Language
Created by YUART on 6/17/2024 in #❓・help
YUART - How to implement this code in Spawn?...
Ok
23 replies
TSPThe Spawn Programming Language
Created by YUART on 6/17/2024 in #❓・help
YUART - How to implement this code in Spawn?...
Correct Spawn code is
// Spawn's model of concurrency is going to be very similar to Go's.
// Learn more about concurrency in the documentation:
// https://docs.spawnlang.dev/concepts/concurrency.html
module main

import time
import runtime

fn task(id i32, duration u64) {
println('task ${id} begin')
time.sleep(duration * time.MILLISECOND)
println('task ${id} end')
}

fn main() {
// []runtime.Handle[unit] is a special type that represents an array of threads
mut threads := []&runtime.Handle[unit]{}

// `spawn` starts a new thread and returns a `runtime.Handle[unit]` object
// that can be added in thread array.
threads.push(spawn task(1, 500))
threads.push(spawn task(2, 900))
threads.push(spawn task(3, 100))

for thread in threads {
thread.join()
}

println('done')
}
// Spawn's model of concurrency is going to be very similar to Go's.
// Learn more about concurrency in the documentation:
// https://docs.spawnlang.dev/concepts/concurrency.html
module main

import time
import runtime

fn task(id i32, duration u64) {
println('task ${id} begin')
time.sleep(duration * time.MILLISECOND)
println('task ${id} end')
}

fn main() {
// []runtime.Handle[unit] is a special type that represents an array of threads
mut threads := []&runtime.Handle[unit]{}

// `spawn` starts a new thread and returns a `runtime.Handle[unit]` object
// that can be added in thread array.
threads.push(spawn task(1, 500))
threads.push(spawn task(2, 900))
threads.push(spawn task(3, 100))

for thread in threads {
thread.join()
}

println('done')
}
23 replies
TSPThe Spawn Programming Language
Created by YUART on 6/17/2024 in #❓・help
YUART - How to implement this code in Spawn?...
Works
23 replies
TSPThe Spawn Programming Language
Created by YUART on 6/17/2024 in #❓・help
YUART - How to implement this code in Spawn?...
// V's model of concurrency is going to be very similar to Go's.
// Learn more about concurrency in the documentation:
// https://docs.spawnlang.dev/concepts/concurrency.html
module main

import time
import runtime

fn task(id i32, duration i32) {
println('task ${id} begin')
time.sleep(duration * time.MILLISECOND)
println('task ${id} end')
}

fn main() {
// []thread is a special type that represents an array of threads
mut threads := []runtime.Handle{}

// `spawn` starts a new thread and returns a `thread` object
// that can be added in thread array.
threads << spawn task(1, 500)
threads << spawn task(2, 900)
threads << spawn task(3, 100)

for thread in threads {
thread.join()
}

println('done')
}
// V's model of concurrency is going to be very similar to Go's.
// Learn more about concurrency in the documentation:
// https://docs.spawnlang.dev/concepts/concurrency.html
module main

import time
import runtime

fn task(id i32, duration i32) {
println('task ${id} begin')
time.sleep(duration * time.MILLISECOND)
println('task ${id} end')
}

fn main() {
// []thread is a special type that represents an array of threads
mut threads := []runtime.Handle{}

// `spawn` starts a new thread and returns a `thread` object
// that can be added in thread array.
threads << spawn task(1, 500)
threads << spawn task(2, 900)
threads << spawn task(3, 100)

for thread in threads {
thread.join()
}

println('done')
}
Outputs
[🔴] × spawnc --cc clang --run x.sp
error(E0128): cannot infer type of the type parameter(s) declared on the function `join`
--> x.sp:26:9:20
|
26 | thread.join()
| ^^^^^^^^^^^

help: specify generic type(s) explicitly, for example, `foo[i32]()`
--> x.sp:26:20:20
|
26 | thread.join[]()
| ++


error: aborting due to previous error
[🔴] × spawnc --cc clang --run x.sp
error(E0128): cannot infer type of the type parameter(s) declared on the function `join`
--> x.sp:26:9:20
|
26 | thread.join()
| ^^^^^^^^^^^

help: specify generic type(s) explicitly, for example, `foo[i32]()`
--> x.sp:26:20:20
|
26 | thread.join[]()
| ++


error: aborting due to previous error
23 replies
TSPThe Spawn Programming Language
Created by YUART on 6/17/2024 in #❓・help
YUART - How to implement this code in Spawn?...
Ok, trying
23 replies
TSPThe Spawn Programming Language
Created by YUART on 6/17/2024 in #❓・help
YUART - How to implement this code in Spawn?...
I updated the code I want to implement in Spawn
23 replies
TSPThe Spawn Programming Language
Created by YUART on 6/17/2024 in #❓・help
YUART - How to implement this code in Spawn?...
Not tha code 😅
23 replies
TSPThe Spawn Programming Language
Created by YUART on 6/17/2024 in #❓・help
YUART - How to implement this code in Spawn?...
Oh sorry I'm stupid
23 replies
TSPThe Spawn Programming Language
Created by B1Z0N on 3/24/2024 in #❓・help
B1Z0N - Compiled V, then Spawn from main [repo]...
You also need to setup SPAWN_ROOT environment variable to be able to compile from another directory. This variable must point to the root of spawn repo
8 replies
TSPThe Spawn Programming Language
Created by B1Z0N on 3/24/2024 in #❓・help
B1Z0N - Compiled V, then Spawn from main [repo]...
I also have these errors, compiling a file that are located in different directory works
8 replies