Skip to content

Add in constant variants for invalid refs. #16293

Description

@tabularelf

What is the problem this request aims to solve?

Currently in order to mark an asset or data structure as "invalid", one must assign a different value to a variable that contains that data structure. Which does work fine, mostly. However GameMaker has a rather awful history of mixing different variable types together.

  • -1
  • noone
  • undefined
  • pointer_null

The problem is further increased when most *_exists functions do allow undefined, but vertex_buffer_exists() and vertex_format_exists() don't. So people end up forced to mix n matching types.

Image Image

Likewise, it would be nice if refs had a proper invalid handle to reference from. Alrea
dy this is possible to do in GameMaker via a macro, but it is not a compile-time constant.

#macro handle_surface_null (handle_parse("ref surface -1"))

How do you suggest we solve this problem?

Adding native constants that directly store a "ref surface -1" and similar would allow quick easy assignments without making the game do extra work for it.

This means it is possible to do

surface_free(surf);
surf = handle_surface_null;

ds_grid_destroy(grid);
grid = handle_grid_null;

buffer_delete(buffer);
buffer = handle_buffer_null;

Are there any alternative ways to solve this problem you want to suggest?

The macro above already works "as is", it's just not compile-time.

Activity

  1. added
    documentationImprovements or additions to documentation are also required by this issue
    on Oct 25, 2026
  2. changed the title [-]Add in constant variants for `-1` ref.[/-] [+]Add in constant variants for invalid refs.[/+] on Oct 25, 2026
  3. moved this from Triage to Backlog in Team Workloadon Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation are also required by this issue

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions