# Asynchronous Functions

{% hint style="info" %}
Asynchronous is a difficult word, but it just means "not in sync".
{% endhint %}

It can be easy to visualise a function as sort of splicing or inserting the function's code into the main code, however that's not accurate, a function, once called, runs independently of the calling code.

{% hint style="warning" %}
This means any delays (such as `wait` effects) in the main code or the function code will not affect the other block of code.\
-> A `wait` inside a function does not delay the code it is called from, only the function.

Recall functions with returns cannot have waits, meaning they must not be asynchronous. This is because the returned value needs to be immediately useable in the main code, and an asynchronous function won't return quickly enough.
{% endhint %}

Imagine the main code is a minecart travelling along a track. When it calls a function, it spawns a new minecart in on a parallel track. The new minecart may slow down or even stop while the original keeps going.

<figure><img src="/files/hronaxBKE0tEVEn8ALOw" alt="" width="375"><figcaption></figcaption></figure>

After the function is called, any delays along the green line do not affect the blue line, and vice versa.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://x8ight.gitbook.io/syntask/fundamentals/structures/functions/asynchronous-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
