Close

Improved modules and name resolution

A project log for Argentum programming language

It automatically prevents all memory leaks. It doesn't use GC, so no pauses. It's compiled to machine code. It's crazy safe and fast.

andrey-kalmatskiyAndrey Kalmatskiy 04/18/2023 at 20:230 Comments

Today Argentum got small but fundamental improvements:

How it was previously (file `demo.ag`):

using sdl;
using utils;
using gui;

class Scene{
    +gui_Group;
    sdl = sdl_Sdl;
    w = sdl_Window;
    rnd = utils_Random;
    flare = sdl_Texture;
    star = sdl_Texture;
    background = sdl_Texture;
    foreground = sdl_Texture;
...

How it is now:

using sdl { Window, Sdl, Texture }
using gui { Actor, Group }

class Scene{
    +Group;

    sdl = Sdl;
    w = Window;
    rnd = Random;
    flare = Texture;
    star = Texture;
    background = Texture;
    foreground = Texture;

Previously any compound names like `sdl_image_mySurface` were able to be created and used in any package. And they always had to be written in full.

Since now names should follow rule: `packageName_functionOrClassName` (for example: `sdlImage_mySurface` or from example above `demo_Scene`. And since names are bound to a module, no need to write them in that long form.

All names defined in a module `demo` are automatically `demo_*`.

When a module declares some dependency with the `using` directive, it may list all names to import and use in short form: `using gui { Actor; Group; }`

If names from different imports collide, give them aliases: `using gui { Control=Actor; }`
Now `Control` can be used instead of `gui_Actor`.

TL;DR: Argentum names just got better.

More on names: link
New compiler and stdlib version: windows demo

Discussions