diff --git a/tutorials/scripting/gdscript/static_typing.rst b/tutorials/scripting/gdscript/static_typing.rst index a31ad9d3c9b..d76ca4eb05e 100644 --- a/tutorials/scripting/gdscript/static_typing.rst +++ b/tutorials/scripting/gdscript/static_typing.rst @@ -479,6 +479,86 @@ Currently, ``UNSAFE_*`` warnings do not cover all cases that unsafe lines cover. Common unsafe operations and their safe counterparts ---------------------------------------------------- +Global scope methods +~~~~~~~~~~~~~~~~~~~~ + +The following global scope methods are not statically typed, but they have +typed counterparts available. These methods return statically typed values: + ++------------------------------------------------------+-------------------------------------------------------------------------------------+ +| Method | Statically typed equivalents | ++======================================================+=====================================================================================+ +| :ref:`abs()` | | :ref:`absf() `, | +| | :ref:`absi() ` | +| | | :ref:`Vector2.abs() `, | +| | :ref:`Vector2i.abs() ` | +| | | :ref:`Vector3.abs() `, | +| | :ref:`Vector3i.abs() ` | +| | | :ref:`Vector4.abs() `, | +| | :ref:`Vector4i.abs() ` | ++------------------------------------------------------+-------------------------------------------------------------------------------------+ +| :ref:`ceil() ` | | :ref:`ceilf() `, | +| | :ref:`ceili() ` | +| | | :ref:`Vector2.ceil() ` | +| | | :ref:`Vector3.ceil() ` | +| | | :ref:`Vector4.ceil() ` | ++------------------------------------------------------+-------------------------------------------------------------------------------------+ +| :ref:`clamp() ` | | :ref:`clampf() `, | +| | :ref:`clampi() ` | +| | | :ref:`Vector2.clamp() `, | +| | :ref:`Vector2i.clamp() ` | +| | | :ref:`Vector3.clamp() `, | +| | :ref:`Vector3i.clamp() ` | +| | | :ref:`Vector4.clamp() `, | +| | :ref:`Vector4i.clamp() ` | +| | | :ref:`Color.clamp() ` | +| | | (untyped ``clamp()`` does not work on Color) | ++------------------------------------------------------+-------------------------------------------------------------------------------------+ +| :ref:`floor() ` | | :ref:`floorf() `, | +| | :ref:`floori() ` | +| | | :ref:`Vector2.floor() ` | +| | | :ref:`Vector3.floor() ` | +| | | :ref:`Vector4.floor() ` | ++------------------------------------------------------+-------------------------------------------------------------------------------------+ +| :ref:`lerp() ` | | :ref:`lerpf() ` | +| | | :ref:`Vector2.lerp() ` | +| | | :ref:`Vector3.lerp() ` | +| | | :ref:`Vector4.lerp() ` | +| | | :ref:`Color.lerp() ` | +| | | :ref:`Quaternion.slerp() ` | +| | | :ref:`Basis.slerp() ` | +| | | :ref:`Transform2D.interpolate_with() ` | +| | | :ref:`Transform3D.interpolate_with() ` | ++------------------------------------------------------+-------------------------------------------------------------------------------------+ +| :ref:`round() ` | | :ref:`roundf() `, | +| | :ref:`roundi() ` | +| | | :ref:`Vector2.round() ` | +| | | :ref:`Vector3.round() ` | +| | | :ref:`Vector4.round() ` | ++------------------------------------------------------+-------------------------------------------------------------------------------------+ +| :ref:`sign() ` | | :ref:`signf() ` | +| | | :ref:`signi() ` | +| | | :ref:`Vector2.sign() `, | +| | :ref:`Vector2i.sign() ` | +| | | :ref:`Vector3.sign() `, | +| | :ref:`Vector3i.sign() ` | +| | | :ref:`Vector4.sign() `, | +| | :ref:`Vector4i.sign() ` | ++------------------------------------------------------+-------------------------------------------------------------------------------------+ +| :ref:`snapped() ` | | :ref:`snappedf() ` | +| | | :ref:`snappedi() ` | +| | | :ref:`Vector2.snapped() `, | +| | :ref:`Vector2i.snapped() ` | +| | | :ref:`Vector3.snapped() `, | +| | :ref:`Vector3i.snapped() ` | +| | | :ref:`Vector4.snapped() `, | +| | :ref:`Vector4i.snapped() ` | ++------------------------------------------------------+-------------------------------------------------------------------------------------+ + +When using static typing, use the typed global scope methods whenever possible. +This ensures you have safe lines and benefit from typed instructions for +better performance. + ``UNSAFE_PROPERTY_ACCESS`` and ``UNSAFE_METHOD_ACCESS`` warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~