Skip to content

runtime lib - modules #120

@Hels15

Description

@Hels15

When building against Donsus we have the possibility of using pre-defined functions, however, a few important decisions will need to be made:
- silent typechecker error

void test();

a:int[] = [1, 2]; # dynamic array initialisation is constant
a[1] = 5;
printf(a[1]);

test();
terminate called after throwing an instance of 'ReDefinitionException'
  what():  test has not been defined!
Aborted (core dumped)

Donsus will only add a new symbol to the symbol table if it acknowledges the DEFINITION of the symbol. In this case, there is no definition thus it'll throw an error.

Here test is supposed to represent a built-in function - because it's built-in it can be implicitly declared under the hood before use so the user wouldn't have to do such a thing.

It is hard to think about how modules would affect this if we don't have an exact idea of how they tend to work - we currently assume that we will adopt a similar design to c++, thus communication between multiple translation units is essential and our typeckecer should be smarter about this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions