Definition of virtual, const and vararg function classifications in the docs

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wyattb

In the API docs, e.g. Node — Godot Engine (3.0) documentation in English you see functions classified as virtual, const and Variant rpc ( String method ) vararg. I am trying to understand what that means in terms maybe of other languages

So I am guessing virtual classification is similar to abstract, and must be defined in your code (E.g. callbacks). But const or vararg classification I am not so sure. Any ideas?

Examples.

void	_ready ( ) virtual
Node	get_child ( int idx ) const
Variant	rpc ( String method ) vararg
:bust_in_silhouette: Reply From: Oen44

virtual - used mostly to override class methods like _ready, _process or _input_event.

const - constant variable, set value that can’t be changed.
Example:

const GAME_NAME = "My Game"; # define constant string GAME_NAME
GAME_NAME = "My New Game"; # error, can't change constant value

vararg - multiple arguments passed to function
Example:

func foobar(args):
    for i in args:
        print(i);

foobar(1, 2, 3, 4); # prints 1, 2, 3, 4

That still doesn’t explain why the methods below are documented as follows.

Node    get_child ( int idx ) const
Variant rpc ( String method ) vararg

wyattb | 2018-09-20 21:12

How is that? It explains a lot.
You can’t modify Node per se, that’s why it’s const.
rpc(“function_name”, <optional_args>) - that’s why it’s vararg. Unlimited arguments, first must be function, and then every other is arguments to that function.

Oen44 | 2018-09-23 10:21

Thanks for the clarification. I submitted it as an issue requiring clarification.

Definition of virtual, const and vararg function classifications in the docs · Issue #1753 · godotengine/godot-docs · GitHub

wyattb | 2018-09-23 13:15