0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

コードを生成しないコレクションと例外処理が期待通り動くようになりました

Last updated at Posted at 2025-02-24

まあ、どうでもいいですかね。
とりあえずやってます。
一応成果宣伝しておきます。
mapでもコードを生成しないコレクションできました。
30万行くらいの規模だったのが25万行くらいまでになりました。
マイコンでは重要かと思います。
あとは例外が割と普通のインタプリタみたいに期待通り動く感じです。
まあ、いいじゃないでしょうか。

Exception

#include <comelang.h>

exception int fun(int a)
{
    printf("%d\n", a);
    
    return none(s"ERR");
}

int main(int argc, char** argv)
{
    int b = fun(a:111).rescue {
        puts("RESCUE");
        111
    }
    
    printf("b %d\n", b);
    
    return 0;
}
111
RESCUE
b 111
#include <comelang.h>

exception int fun(int a)
{
    printf("%d\n", a);
    
    return none(s"ERR");
}

int main(int argc, char** argv)
{
    int b = fun(a:111);
    
    printf("b %d\n", b);
    
    return 0;
}
111
ERR
#include <comelang.h>

exception int fun(int a)
{
    printf("in fun %d\n", a);
    
    return none(s"Err");
}

exception int fun2(int a)
{
    printf("in fun2 a %d\n", a);
    
    fun(a);
    
    return 1;
}

int main(int argc, char** argv)
{
    int b = fun2(a:111);
    
    printf("b %d\n", b);
    
    return 0;
}
#include <comelang.h>

dynamic struct sData
{
    int a;
    string b;
};

int main(int argc, char** argv)
{
    list<sData~>*% li = new list<sData~>();
    
    li.add(new sData { b:s"ABC" });
    
    puts(li[0].b);
    
    return 0;
}

listはvoid*としてコード生成される。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?