Decorators
@main Decorator
The entry point of the Jackal application. It tells the interpreter where to begin the execution flow.
@main
func main() {
println("hello world")
}
@memoize Decorator
Used for performance optimization. It caches the results of function calls based on the input arguments to avoid redundant calculations.
@memoize
func counter(n) {
let count = 1
for (let i = 1; i < n; i++) {
count = count * 2
}
return count
}
@parallel Decorator
Leverages multi-core processing by running the function on a separate thread using POSIX Threads integration.
@parallel
func counter(n) {
let count = 1
for (let i = 1; i < n; i++) {
count = count + 1
}
return count
}
@async Decorator
Enables non-blocking background execution. The main thread continues running while the async task processes in the background.
@async
func count(n) {
let count = 0
for (let i = 0; i < n; i++) {
count++
}
return count
}
@override Decorator
Ensures structural integrity by explicitly marking methods that implement or redefine members from an interface or parent class.
interface Greetable {
func greet()
}
class Jack implements Greetable {
@override
func greet() {
println("hello jackal")
}
}
let jack = Jack()
jack.greet()