ddonche/goblin-lang
0.47.39
1
0
docs reference
[[action]]

Action


Action declares an action. This is similar to how other languages use fn or def.

/// rust
fn main() {
    println!("Hello, world!");
}

/// ruby
def hello_world
  puts "Hello, World!"
end

/// goblin
action hello_world
  :say "Hellow, World!"
xx
/// rust
fn main() {
    println!("Hello, world!");
}

/// ruby
def hello_world
  puts "Hello, World!"
end

/// goblin
action hello_world
  :say "Hellow, World!"
xx

Try it in the REPL:


Overview

action is an alias for act.

It creates callable logic exactly the same way.

action greet(name)
    :say("Hello, {name}!")
xx
action greet(name)
    :say("Hello, {name}!")
xx

Calling the action:

greet("Goblin")
greet("Goblin")

Output:

Hello, Goblin!
Hello, Goblin!

And you can do it on a single line, too:

action greet(name) => :say("Hello, {name}!")
action greet(name) => :say("Hello, {name}!")


Equivalent to act

The following examples are identical:

act greet(name)
    :say("Hello!")
xx
act greet(name)
    :say("Hello!")
xx

action greet(name)
    :say("Hello!")
xx
action greet(name)
    :say("Hello!")
xx

Goblin documentation generally uses act because it is shorter.