Coder Social home page Coder Social logo

spydr06 / cspydr Goto Github PK

View Code? Open in Web Editor NEW
83.0 5.0 2.0 4.6 MB

A static typed low-level compiled programming language inspired by Rust and C

License: MIT License

C 98.59% Shell 0.67% C++ 0.03% Lua 0.02% Vim Script 0.26% Makefile 0.42%
low-level cspydr compiler static-typed programming-language c rust language csp compilation

cspydr's Introduction

CSpydr is a low-level, static typed, free and open-source, compiled programming language inspired by Rust and C. This repository contains cspc (the CSpydr Programming Language Compiler), as well as CSpydr's Standard Library, a code-linting utility, some code examples and unit tests.

Code Examples

Hello World

Fibonacci

Lambda Functions

Read File

Random Number Generator

Time & Timer API

More examples can be found in the examples directory

Current State

A list of all the features, that are already implemented or planned.

cspc Compiler features:
  • Assembly code generator for x86_64 linux
  • LLVM codegen target (maybe even WASM?)
  • move to an intermediate bytecode compiler
  • AST to JSON converter (in progress)
  • C transpiler
  • lexing tokens
  • macro and import preprocessor
  • parsing an AST, validation of syntax and semantics
  • type evaluator & checking
  • implicit type casts
  • "projects" - prebuild libraries such as the stdlib
  • CLI and error handling
  • memory management
CSpydr Language features:
  • primitive data types i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 f80 bool char void
  • pointers, arrays and c-like arrays & [] 'c[]
  • custom data types struct union enum {} (tuples)
  • control statements if match for while loop ret break continue noop with do-while do-unless defer
  • different loop types: for, while, do-while and loop
  • expressions
  • extern functions and globals
  • type-related keywords sizeof typeof alignof len
  • file imports
  • macros and macro-overloading
  • default macros __version__ __system__ __architecture__ __time__ __compile_type__ __main_file__ __file__ __line__ __func__
  • namespaces, functions, globals, typedefs
  • inline asm code blocks
  • lambda expressions
  • templates in fuctions and structs
  • va lists
  • functions as struct members
CSpydr Standard library features
  • basic c17 libc-header implementation
  • glfw and OpenGL/GLU header files
  • cURL header implementation
  • from-the-ground custom written stdlib based on linux syscalls (in progress)

Installation

Please refer to INSTALL.md for installation instructions and information about compatability

Hello, World!

A simple hello-world program:

import "io.csp";

fn main(): i32
{
    std::io::puts("Hello, World!");
    <- 0;
}

Running this program is as easy as entering the following command:

$ cspc run hello-world.csp

Examples

For more examples, please refer to the examples/ directory in this repository.

Usage

To compile a CSpydr program use the following command:

$ cspc build <your file>

To directly run a program use this command:

$ cspc run <your file>

To launch a special debug shell, start your program using the debug action:
(not finished yet!)

$ cspc debug <your file>

Get help using this command:

$ cspc --help

(I will write a proper documentation in the future!)

Editor support

Editor support is found in the editors/ subdirectory.

Supported editors include:

Note For quick installation, use the install.sh script in the respective subdirectory.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update the unit tests as appropriate.

View CONTRIBUTING.md for more information

License

CSpydr is licensed under the MIT License.

Resources | Reference | Inspiration

cspydr's People

Contributors

hexaredecimal avatar its-kenta avatar spydr06 avatar stunxfs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

hexaredecimal ego

cspydr's Issues

Error on build - json-c/json_object.h: No such file or directory

Error when building, looks like paths are wrong?

    8 | #include <json-c/json_object.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [src/compiler/CMakeFiles/libcspc.dir/build.make:104: src/compiler/CMakeFiles/libcspc.dir/ast/ast_json.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1293: src/compiler/CMakeFiles/libcspc.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

Reimplement arrays

Currently, Arrays in CSpydr get treated exactly like their C counterparts. Meaning only the data gets stored in memory.

Changes:

  • Arrays will be laid out in memory like this:
+-----------------+---------+---------+---------+---------+-------...
| length (8 byte) | indices (variable size determined by the data type)
+-----------------+---------+---------+---------+---------+-------...
  • Change to the index operator x[]
    Add a simple offset of 8 bytes when an array type is detected. Interaction with pointers will not be changed to keep compatibility with C.

  • Change of the len keyword:
    The len keyword will now be able to get the first 8 bytes - the length of the array directly and is no longer bound to constant arrays


Development is going to happen in the new-arrays

Error while loading shared libs

I wanted to mess about creating a CSpydr binding to Raylib which seems to work when using [link("raylib")] as recommended.
When building the executable it seems to work and linker finds the shared lib, however. When trying to run the binary we're met with error:

./main: error while loading shared libraries: libraylib.so.450: cannot open shared object file: No such file or directory
While the shared libs are also present in the same dir as the executable.

Am I missing something here?

Odd behaviour with floats & printf

I've encountered an odd behaviour with floats and printf where the output returned is not the value you've provided:
We have the following code:

import "std.csp";

fn main(): i32 {
    using std::io;

    macro PI { 3.14159265358979323846 }
    let pi: f32 = 1.2;
    let num: i32 = 55;

    printf("%i\n", num);
    printf("%f\n", PI!);
    printf("%f\n", pi);
    <- 0;
}

The output is:

55
3.0000000000
1.0000000000

Does CSpydr not use the same formatting rule as C? Is there something done wrong in this example or there is a deeper underlying problem causing this? As you can see, the integer is printed out fine.

Macros in namespaces & calling them with namespace

Is there any reason behind this? I think it might be conflicting if we have two different imports where the macros share the same name (low possibility, but still worth thinking over it.)

What would happen if library A & library B both have a macro named PI and not under a namespace? Which macro would be called?

Is there any possibility to allow adding macros in namespaces and allowing them to be called e.g.

namespace my_namespace {
    macro PI { 3.14159265358979323846 }
}

....
fn main(): i32 {
    using std::io;
    printf("%f\n", my_namespace::PI!);
    <- 0;
}

Interface implementation

Draft on how interfaces will be implemented:

import "std.csp";

type Foo: interface {
    fn foo(self: &Foo): i32
};

type Bar: struct {
    x: i32
};

# how to implement Foo for Bar?

fn main(): i32 {
    let bar = Bar::{0};
    (&bar: &Foo).foo();

    <- 0;
}

The main question is: how should the syntax for implementing Foo for Bar look like?

Types not found when importing from a namespace in a different file

cURL implementation broken because of that.

-> Types defined in namespace curl in curl.csp are not getting detected in the same namespace curl in easy.csp

Compiler error:

easy.csp:42:35 => [type]: undefined data type `CURL`
   42 |     fn curl_easy_setopt(curl: &CURL, option: curl::CURLoption, args: ...): CURLcode;
      | 

Fails to build - Ubuntu

Unsure why, but CSpydr is failing to build on Ubuntu while all dependencies are met:

./configure 
checking host system type... linux-gnu
checking for C compiler... /usr/bin/gcc
checking whether the C compiler works... yes
checking for linker... /usr/bin/gcc
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config directory... /usr/share/pkgconfig
checking for bear... found.
checking for git... found.
checking for install... found.
checking for find... found.
checking for mkdir... found.
checking for rm... found.
checking for sed... found.
checking for libpkgconf... found.
checking for json-c... found.
checking for acutest... found.
removing existing /home/ishimachi/Repositories/cspydr/config.mk file... done.
generating /home/ishimachi/Repositories/cspydr/config.mk file... done.

generated configuration:
# Auto-generated by `configure`

CC := /usr/bin/gcc
LD := /usr/bin/gcc
CFLAGS :=  -fPIC -flto -Wall -Wextra -Wno-unused-parameter -DDEFAULT_STD_PATH="\"/usr/local/share/cspydr/std\"" -I/usr/include/pkgconf  -I/usr/include/json-c 
LDFLAGS :=  -lm -lpkgconf  -ljson-c 

INSTALL := /usr/bin/install
FIND := /usr/bin/find
MKDIR := /usr/bin/mkdir
RM := /usr/bin/rm
SED := /usr/bin/sed
BEAR := /usr/bin/bear

PREFIX := /usr/local
EXEC_PREFIX := /usr/local
BUILD_PREFIX := /home/ishimachi/Repositories/cspydr/build
BIN_PREFIX := /home/ishimachi/Repositories/cspydr/build/bin

PKG_CONFIG_DIR := /usr/share/pkgconfig
SRC_DIR := /home/ishimachi/Repositories/cspydr/src

CSPC_DEFAULT_STD_PATH := /usr/local/share/cspydr/std

VERSION := 0.1.1
VERSION_X := 0
VERSION_Y := 1
VERSION_Z := 1

GIT_HASH := cad5936

done.

Error logs:

make
make -C /home/ishimachi/Repositories/cspydr/src/compiler LIBCSPC=/home/ishimachi/Repositories/cspydr/build/bin/libcspc.o CSPC=/home/ishimachi/Repositories/cspydr/build/bin/cspc /home/ishimachi/Repositories/cspydr/build/bin/libcspc.o
make[1]: Entering directory '/home/ishimachi/Repositories/cspydr/src/compiler'
make[1]: '/home/ishimachi/Repositories/cspydr/build/bin/libcspc.o' is up to date.
make[1]: Leaving directory '/home/ishimachi/Repositories/cspydr/src/compiler'
make -C /home/ishimachi/Repositories/cspydr/src/compiler LIBCSPC=/home/ishimachi/Repositories/cspydr/build/bin/libcspc.o CSPC=/home/ishimachi/Repositories/cspydr/build/bin/cspc /home/ishimachi/Repositories/cspydr/build/bin/cspc
make[1]: Entering directory '/home/ishimachi/Repositories/cspydr/src/compiler'
/usr/bin/gcc -lm -lpkgconf  -ljson-c  /home/ishimachi/Repositories/cspydr/build/compiler/./context.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./version.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/typechecker.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/directives.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/utils.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/queue.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/parser.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/validator.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./debugger/breakpoint.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./debugger/register.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./debugger/debugger.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./main.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./c_parser/c_lexer.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./c_parser/c_parser.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./preprocessor/preprocessor.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./preprocessor/stdmacros.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./ast/ast_iterator.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./ast/ast_json.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./ast/types.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./ast/ast.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./memory/allocator.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./toolchain.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./timer/timer.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./interpreter/stack.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./interpreter/interpreter.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./interpreter/value.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./platform/win32/win32_platform.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./platform/pkg_config.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./platform/linux/linux_platform.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./error/error.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./error/panic.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./error/default.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/asm/asm_codegen.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/asm/relocation.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/asm/linker.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/codegen_utils.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/transpiler/keywords.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/transpiler/c_codegen.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./hashmap.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./optimizer/constexpr.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./optimizer/optimizer.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./lexer/token.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./lexer/lexer.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./config.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./list.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./io/io.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./io/file.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./util.c.o -o /home/ishimachi/Repositories/cspydr/build/bin/cspc
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `align_type':
<artificial>:(.text+0x14b41): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x14b66): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x14b81): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x14bbb): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x14be0): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x14bfb): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x14c22): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x14c47): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x14c62): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x14c95): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x14cba): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x14cd5): undefined reference to `pow'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `get_type_align':
<artificial>:(.text+0x15364): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x15389): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x153a4): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x153de): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x15403): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x1541e): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x15445): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x1546a): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x15485): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x154b8): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x154dd): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x154f8): undefined reference to `pow'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `ast_to_json':
<artificial>:(.text+0x1d779): undefined reference to `json_object_to_json_string_ext'
/usr/bin/ld: <artificial>:(.text+0x1d7ae): undefined reference to `json_object_put'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_str':
<artificial>:(.text+0x1d7d4): undefined reference to `json_object_new_string'
/usr/bin/ld: <artificial>:(.text+0x1d7db): undefined reference to `json_object_new_null'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_i32':
<artificial>:(.text+0x1d7f6): undefined reference to `json_object_new_int'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_i64':
<artificial>:(.text+0x1d814): undefined reference to `json_object_new_int64'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_bool':
<artificial>:(.text+0x1d832): undefined reference to `json_object_new_boolean'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_list':
<artificial>:(.text+0x1d854): undefined reference to `json_object_new_null'
/usr/bin/ld: <artificial>:(.text+0x1d85b): undefined reference to `json_object_new_array'
/usr/bin/ld: <artificial>:(.text+0x1d89a): undefined reference to `json_object_array_add'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_tok':
<artificial>:(.text+0x1d8ce): undefined reference to `json_object_new_null'
/usr/bin/ld: <artificial>:(.text+0x1d8d8): undefined reference to `json_object_new_object'
/usr/bin/ld: <artificial>:(.text+0x1d914): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1d947): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1d97c): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1d9a6): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1d9de): undefined reference to `json_object_object_add'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_srcfile':
<artificial>:(.text+0x1da00): undefined reference to `json_object_new_null'
/usr/bin/ld: <artificial>:(.text+0x1da07): undefined reference to `json_object_new_object'
/usr/bin/ld: <artificial>:(.text+0x1da35): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1da5c): undefined reference to `json_object_object_add'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_ast_identifier':
<artificial>:(.text+0x1da7e): undefined reference to `json_object_new_null'
/usr/bin/ld: <artificial>:(.text+0x1da88): undefined reference to `json_object_new_object'
/usr/bin/ld: <artificial>:(.text+0x1dac0): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1daf8): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1db2e): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1db65): undefined reference to `json_object_object_add'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_namespace_start':
<artificial>:(.text+0x1dbce): undefined reference to `json_object_new_object'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_ast_prog':
<artificial>:(.text+0x1dc2c): undefined reference to `json_object_new_object'
/usr/bin/ld: <artificial>:(.text+0x1dc61): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1dc90): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1dcc9): undefined reference to `json_object_object_add'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `pkg_config':
<artificial>:(.text+0x293d7): undefined reference to `pkgconf_cross_personality_default'
/usr/bin/ld: <artificial>:(.text+0x29421): undefined reference to `pkgconf_client_new'
/usr/bin/ld: <artificial>:(.text+0x2942a): undefined reference to `pkgconf_cross_personality_default'
/usr/bin/ld: <artificial>:(.text+0x2943c): undefined reference to `pkgconf_client_dir_list_build'
/usr/bin/ld: <artificial>:(.text+0x29452): undefined reference to `pkgconf_pkg_find'
/usr/bin/ld: <artificial>:(.text+0x294b3): undefined reference to `pkgconf_pkg_libs'
/usr/bin/ld: <artificial>:(.text+0x294e8): undefined reference to `pkgconf_error'
/usr/bin/ld: <artificial>:(.text+0x295d9): undefined reference to `pkgconf_fragment_free'
/usr/bin/ld: <artificial>:(.text+0x295ec): undefined reference to `pkgconf_pkg_free'
/usr/bin/ld: <artificial>:(.text+0x295f8): undefined reference to `pkgconf_client_free'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:10: /home/ishimachi/Repositories/cspydr/build/bin/cspc] Error 1
make[1]: Leaving directory '/home/ishimachi/Repositories/cspydr/src/compiler'
make: *** [Makefile:25: cspc] Error 2

What is the plan for CSpydr.

Hello.
Firstly, congratulations on developing such an appealing language.

My question is rather straightforward, I suppose: What is the plan for CSpydr? What are its goals? What does it aim to achieve and what issues does it seek to mitigate?

As the creator, how far do you intend to take your creation?

Thank you, and best wishes. I certainly look forward to exploring the language further.

VSC Extension as VSIX

Is it possible to package the VSC editor as VSIX please for ease of installation?
I've just tested it and it packaged ok, but does mention that LICENSE.txt is missing.

I've also pushed PR to slightly fix the installation for current version.

Thanks!

Allow for alias naming when utilising extern "C"

Apologies for a vague subject, unsure how to properly form it in words.
What I mean by this suggestion is to provide an ability to create CSpydr internal function names as an alias to what is being linked with a C library.

e.g.

extern "C" fn cFunctionNameA(): int32;
extern "C" fn cFunctionNameB(): int32;

The name matches exactly the same as it does in the C code, but it would be great to give the user an ability to also provide their own internal CSpydr name e.g.:

fn c_function_nameA() @extern "C" cFunctionNameA(): int32;
fn c_function_nameB() @extern "C" cFunctionNameB(): int32;

I'm most certain there would be some ways to make it look pretty, but it would be great if it was possible to do so.
Correct me if I'm wrong and this already exists?

Allow alias export directive with extern scopes

Currently only alias export directive possible is if you call it individually outside a namescope and if not inside an extern "C" {} scope:

[export("MyFunction")]
extern "C" fn my_function(): i32;

I think it would be great if you could include the export directive to be part of a the extern scope like this:

[link("mylib")]
namespace lib {
    extern "C" {
        [export("MyFunction")]
        fn my_function(): i32;
    }
}

Meaning extern in the fn get_screen_width(): i32; is unnecessary and allows for bundling all imports in one scope for cleaner code (imo.)

Currently attempting this would give the following error:

=> [syntax]: expect function or variable declaration
    7 | [export("MyFunction")] 
      | ^-here

What are the plans for the language?

I see you're also working on a different language and few other repo's that would indicate other interests. Are there plans to focus on this language or move onto something else? IMO the language has a potential, but it's difficult to consider interest in it if it's going to be thrown on a shelf of unwanted projects.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.