Skip to content

Feature - CLEO Containers #204

Closed
Closed

Description

@MiranDMC

Introduce data container feature and opcodes to support it.

Container instance is meant to store single kind of data type.
Available types: int, float, text
As far as it is technically possible types validation is performed in opcode commands at runtime. In case of mismatch error is thrown.

Class name: container

Opcodes:

create_container - container type
remove_container

container_size
container_clear

container_insert - one or multiple values
container_insert_front - one or multiple values
container_insert_at - index and one or multiple values

container_remove - optional count
container_remove_front - optional count
container_remove_at -  index and optional count

container_get - one or multiple return values
container_get_front - one or multiple return values
container_get_at - index and one or multiple return values
container_get_random - one or multiple return values

container_contains - one or more search values
container_count - one search value
container_find - search value
container_find_back - search value

container_sort - sorting order and zero or more synchronized container handles

container_write_to_file
container_read_from_file

Activity

  1. x87 commented on Sep 21, 2024

    @x87

    I think type should be set in the constructor.

    int_container = create_container type 0
    string_container = create_container type 1
    container_add int_container 1 2 3
    container_add int_container "runtime error"
    container_add string_container "ok"
    
  2. MiranDMC commented on Sep 21, 2024

    @MiranDMC
    CollaboratorAuthor

    I think type should be set in the constructor.

    int_container = create_container type 0
    string_container = create_container type 1
    container_add int_container 1 2 3
    container_add int_container "runtime error"
    container_add string_container "ok"
    

    How getters will look then?

  3. x87 commented on Sep 21, 2024

    @x87
    int_container = create_container type 0
    container_add int_container 1 2 3
    int x = get_by_index int_container 0 // x= 1
    int y = get_by_index int_container 1 // y= 2
    int z = get_by_index int_container 2 // z= 3
    
    string_container = create_container type 1
    container_add string_container "ok"
    longstring s = get_by_index string_container 0 // s= "ok"
    

    names are temporary to illustrate the idea

  4. MiranDMC commented on Sep 21, 2024

    @MiranDMC
    CollaboratorAuthor

    Will the getter opcode be able in every case to distinguish return parameter type and validate it? Especially float and int types.

  5. x87 commented on Sep 21, 2024

    @x87

    addition

    int_container = create_container type 0
    container_add int_container 1 2 3
    int x = get_by_index int_container 0 // x= 1
    int y = get_by_index int_container 1 // y= 2
    int z = get_by_index int_container 2 // z= 3
    
    string_container = create_container type 1
    container_add string_container "this is a very long string that couldn't live in a variable"
    int s = get_by_index string_container 0 // s= pointer to "this is a very long string that couldn't live in a variable"
    print_help_formatted s // prints "this is a very long string that couldn't live in a variable"
    

    string containers return a pointer.

  6. x87 commented on Sep 21, 2024

    @x87

    Will the getter opcode be able in every case to distinguish return parameter type and validate it? Especially float and int types.

    I wouldn't care in runtime. you provide a 32-bit variable and runtime either copies the value (if it's int or float) or returns a pointer if it's a string, or other object.

    validation can be done in compiler or linter

  7. x87 commented on Sep 23, 2024

    @x87

    runtime should keep track of created containers and delete them / free memory when the script ends (on game reload)

  8. MiranDMC commented on Dec 11, 2024

    @MiranDMC
    CollaboratorAuthor

    Should container space be continuous, or it could contain empty slots and support setting variables on arbitrary indexes?
    Hmm, probably not as it will cause problems when synchronizing multiple containers.

  9. added
    type:feature
    on Nov 19, 2025
  10. added
    discussion
    on Jan 5, 2026
  11. removed
    type:feature
    on Jan 15, 2026
  12. locked and limited conversation to collaborators on Mar 7, 2026
  13. converted this issue into a discussion #540 on Mar 7, 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

    discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions