Twitter Updates (13.08.2019)

This is a short announcement about CMakeSL updates. I know that from outside it looks like there is nothing happening. But, actually, CMakeSL is evolving a lot. That's why I decided to give even small updates. They are going to be to big for creating an article on the site (including RSS). I'll post them on twitter. I think it's accessible enough for everyone, so everyone who is interested should be able to track CMakeSL development updates.

So, to summarize: biggest updates are going to be announced on this site (so add the feed if you want), r/cpp and twitter. Smaller but still significant updates are going to be posted on the site and twitter. Small updates (like implementation of a new language feature, or simply something that I'm proud of and want to share) are going to be on the twitter only.

So, let's quickly recap what has been done in CMakeSL since the last update.

Implemented variable type deduction

Yep, the well-known auto:

auto foo = 42;
auto bar = baz();

Introduced function return type deduction

Same auto, but for return type of a function:

auto foo()
{
    return 42;
}

auto bar(bool flag)
{
    if(flag)
    {
        return 444;
    }
    else
    {
        return foo();
    }
}

Implemented if else blocks execution

I didn't realize it, but if-elses ast and sema nodes have been there, but they have not been added to the execution (it'd probably crash). Now they are handled properly.

Implemented while loop execution

Same as if-else. Execution of the while loop has been implemented.

Implemented for loop

A simple for loop has been added. Range-based for loop is not there, though.

Introduced sema tree dumper

An utility similar to clang's -ast-dump. There is no command line argument yet, so, for now, it's only helpful while developing.

auto foo()
{
    return 42;
}

auto bar(bool flag)
{
    if(flag)
    {
        return 42;
    }
    else
    {
        return foo();
    }
}

int main()
{
    int val = bar(true);
    return val;
}

Produces:

-translation unit
 -function
  -return type: 0x2454890 int
  -name: foo
  -parameters
  -body
   -block
    -nodes
     -return
      -expression
       -int value: value: 42
 -function
  -return type: 0x2454890 int
  -name: bar
  -parameters
   -param 0; type: 0x24545b0 bool; name: flag
  -body
   -block
    -nodes
     -if else
      -if
       -conditional
        -condition
         -identifier
          -qualified name: flag
          -index: 5
        -body
         -block
          -nodes
           -return
            -expression
             -int value: value: 42
      -else
       -block
        -nodes
         -return
          -expression
           -function call
            -type: 0x2454890 int
            -function: 0x2456aa0
            -name: foo
            -parameters
     -implicit return
      -type: 0x244ae10 void
 -function
  -return type: 0x2454890 int
  -name: main
  -parameters
  -body
   -block
    -nodes
     -variable declaration
      -type: 0x2454890 int
      -name: val
      -index: 6
      -initialization
       -function call
        -type: 0x2454890 int
        -function: 0x24575d0
        -name: bar
        -parameters
         -param 0
          -bool value: value: true
     -return
      -expression
       -identifier
        -qualified name: val
        -index: 6

Implemented namespaces and identifiers handling

Another big feature - namespaces. In this merge, there is namespaces and global variables handling. No types and functions yet. It was already big (67 files, +2,559 -696), so I decided to implement types and functions handling in another merge.

int bar;
namespace foo
{
    int bar = 42;
    namespace baz::qux
    {
        int kek = bar;
    }
}

int main()
{
    return ::foo::baz::qux::kek;
}

Implemented ternary operator

Last but not least: the ternary operator.

auto foo = is_stahursky_in_da_room() ? 444 : 42;