GithubHelp home page GithubHelp logo

mys-lang / mys Goto Github PK

View Code? Open in Web Editor NEW
132.0 10.0 5.0 8.32 MB

The Mys programming language - an attempt to create a statically typed Python-like language that produces fast binaries. See https://mys-lang.org for more information.

License: Other

Makefile 0.09% Python 45.51% C++ 10.74% C 42.89% Shell 0.01% JavaScript 0.24% HTML 0.08% CSS 0.30% SCSS 0.15%
programming-language python mys rust

mys's Introduction

discord test

WARNING

Mys is still in the very early stages of development. API:s will change, so now is the time to make suggestions! Join the Mys Discord server to get in touch with the developers!

Mys

The Mys programming language - an attempt to create a statically typed compiled Python-like language that produces fast binaries.

Mys is heavily inspired by Python's syntax and Rust's packaging.

Source code:

from random.pseudo import random

func main():
    print(random())

Package configuration:

[package]
name = "robot"
version = "0.1.0"
authors = ["Mys Lang <[email protected]>"]

[dependencies]
random = "latest"

Mys is mainly targeting resource constrained single core embedded systems, but is just as useful in desktop environments.

Documentation

Community

  • Discord: Mys' official Discord server.

Contributing

There are many ways in which you can participate in the project, for example:

  • Submit bugs and feature requests.
  • Fix bugs and implement new features.
  • Review the documentation and make pull requests for anything from typos to new content.

There is more information available in the Mys Developer Guide.

mys's People

Contributors

eerimoq avatar megahallon avatar pmp-p 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mys's Issues

Generic as member does not work

class Echo(Fiber):
    to_echo: Queue[i64]
    to_main: Queue[string]

    def run(self):
        self.to_main.put(str(self.to_echo.get() + 1))

@test
def test_two_fibers():
    to_echo = Queue[i64]()
    to_main = Queue[string]()
    spwan(Echo(to_echo, to_main))
    to_echo.put(9)
    assert to_main.get() == "10"

cannot execute tutorial

mys is a nice idea !

  1. I followed the tutorial and created foo package: build, Package.toml, and src are created
  2. cd foo
  3. $ mys run gives:
    Traceback (most recent call last):
    File "/home/mp/anaconda3/bin/mys", line 8, in
    sys.exit(main())
    File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 733, in main
    args.func(args)
    File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 667, in _do_transpile
    source = transpile(fin.read())
    File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 660, in transpile
    return ModuleVisitor().visit(ast.parse(source))
    File "/home/mp/anaconda3/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
    File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 488, in visit_Module
    for item in node.body
    File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 488, in
    for item in node.body
    File "/home/mp/anaconda3/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
    File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 519, in visit_FunctionDef
    body.append(indent(BodyVisitor().visit(item)))
    File "/home/mp/anaconda3/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
    File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 258, in visit_Expr
    return self.visit(node.value) + ';'
    File "/home/mp/anaconda3/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
    File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 231, in visit_Call
    for arg in node.args
    File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 231, in
    for arg in node.args
    File "/home/mp/anaconda3/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
    File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 480, in generic_visit
    raise Exception(node)
    Exception: <_ast.Str object at 0x7f83d12d8750>
    make: *** [Makefile:23 : transpiled/main.mys.cpp] Erreur 1
    error: Command '['make', '-C', 'build', '-s']' returned non-zero exit status 2.

I am under ubuntu 20.04 ; Python 3.7.6 ; g++ 9.3.0 ; GNU Make 4.2.1

mys-config nor pkg-config found

What did you do?

I followed the Getting started section, installed mys, created a new package (the default hello-world template), and ran mys run (I did not even touch any files in the package), and got a mys-config nor pkg-config found message instead of the print output. By the way, the mys installation did create a ~/.config/mys/config.toml, and it is empty.

What did you expect to see?

$ mys run
 ✔ Reading package configuration (... seconds)
 ✔ Downloading dependencies (... seconds)
 ✔ Building (... seconds)
Hello, world!

What did you see instead?

$ mys run
 ✔ Reading package configuration (... seconds)
 ✔ Downloading dependencies (... seconds)
mys-config nor pkg-config found

Mys version

0.342.0

ToDo list

Just to remember what is left to do. The list is by no means complete.

General

  • More on function overloading.
  • More on operator overloading.
  • Slices/sublist/substring, [begin:end:step]. Should make a copy, right? It's an error to use [] instead of slice() on lists in a loop.
  • Implement a language server. See https://microsoft.github.io/language-server-protocol/.
  • Bugs, bugs, bugs...
  • Refactor generics? Find all calls and type annotations early and replace.

Memory

Postponed

  • Iterators?
  • Context managers?
  • Macro or comptime? Needed for logging and varargs like tricks.

linker error on MacOS

Hi just trying out mys, when I try to run the foo example on MacOS High Sierra I get a linker error

ld: library not found for -lcrt0.o

Trait in tuple does not work.

What did you do?

Return a tuple (i64, None), where None is a trait. Cannot give node as a class that implements it.

What did you expect to see?

What did you see instead?

Mys version

Nice!

Currently building my own language in Python here. How did you implement functions and flow-control. I am awed at what you have achieved with MYS.

Globals in default trait method does not work

Imported trait with default method using global variable does not work. Must change transpiler to generate default trait methods when generating containing module, not adding to class and generate in class context.

There are some ideas as a todo in tests/files/traits.mys.

Also, default trait methods may only use methods defined in the trait, and not class members and methods.

Overloaded generic function does not work.

What did you do?

@generic(T)
def foo(a: T):
    pass

@generic(T)
def foo(a: T, b: T):
    pass

def main():
    foo[u8](1, 2)

What did you expect to see?

Successful compilation.

What did you see instead?

  File "./src/main.mys", line 10
        foo[u8](1, 2)
        ^
CompileError: expected 1 parameter, got 2

Mys version

a172b23

Using imported enum does not work

What did you do?

Imported an enum as used it.

What did you expect to see?

Ok.

What did you see instead?

C++ compilation error.

Mys version

0.170.0

String class given C++ error.

What did you do?

class String:
    pass

What did you expect to see?

Ok!

What did you see instead?

C++ error since String is already used by the mys lib.

Mys version

List comprehension in match does not work.

What did you do?

def code_generator(node: Node) -> string:
    match node:
        case ProgramNode() as program_node:
            return "\n".join([code_generator(item) for item in program_node.body])

    return "todo"
build/default/cpp/src/the_super_tiny_compiler/main.mys.cpp:38:149: error: no member named 'ProgramNode' in namespace 'mys'
static SharedList<String> __list_comprehension_29(const std::shared_ptr<mys::the_super_tiny_compiler::main::Node>& node, const std::shared_ptr<mys::ProgramNode>& program_node)

What did you expect to see?

What did you see instead?

Mys version

List comprehension in method does not work

What did you do?

class Foo:
    def bar(self):
        print([0 for i in range(10)])

What did you expect to see?

Ok.

What did you see instead?

C++ error, self not defined.

Mys version

Missing return runtime error.

What did you do?

def foo() -> string:
    pass

def main():
    assert foo() == ""

What did you expect to see?

Compile error. Missing return.

What did you see instead?

Runtime error.

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

Mys version

main

Suggestion for monorepo approach

Hi!

I saw this project, and one thing I noticed the many mys-json, mys-math etc. libraries all have their own repository. I understand that each of these projects should be optional, and also that they should depend upon each other in a non circular way. One way to reach this goal, is to create a seperate git repository for each of such a standard library component. I understand the motivation to do this, and there are benefits, but there are also some clear drawbacks from this git repository fragmentation:

  • configuration management: how do you know which version of mys-statistics is compatible with which version of mys-math? This results in a compatibility matrix, which will grow rapidly as packages grow in number.
  • When applying a change to more than one component, you need to commit to two repositories. Ideally, the components should be loosely coupled, and the interfaces clearly defined. Reality is often not like this.
  • Packaging. If mys will become a success (no doubt about it ;)), then you will make package maintainers happy by having a single release bundled with libraries. For example the yocto recipe for python is a bit of a mess in that the standard library components are split out manually, so that one can choose which parts of the standard library to install.

My proposal would be, to create a libraries subfolder in this repository, and structure is at such:

  • libraries
    • json (contents of the mys-json repository are copied here)
    • math
    • sqlite

Benefits with this approach:

  • All libraries are versioned with the same version number, incrementing when a new version of mys is released.
  • Cross component changes are easier to make
  • Components can be tested in combination, and are guaranteed to work together well
  • Package creators can loop over the subfolders of the libraries folder, and create a seperate installable package, or they can choose to install all libraries at once in a single package. But the separation into subfolders helps.

I hope this makes sense! In the past I would have splitted the standard library in many git repositories. Having dealt with many git repositories and git submodules, I believe this was a mistake, I hope I can explain my motivations for this.

See also: https://en.wikipedia.org/wiki/Monorepo

Collaboration / Tantilla

Hi, thanks for the invitation :)

I'd like to keep my focus on the mobile IDE part, but perhaps there are some areas where we can collaborate, e.g. typed examples and test cases, language subset overlap etc.? Did not make the list promised on hacker news yet O:)

Enum value not checked.

What did you do?

Use missing enum member.

What did you expect to see?

Error.

What did you see instead?

C++ error.

Mys version

general question about mys

Just by curiosity: why didn't you choose to transpile PEP 484 'typed' python to Cython ? My point is: python is not just python in the sense that there are many python, cython, C, C++ libraries in the python ecosystem. It will be difficult to deal with this, using your C++ transpilation approach, I think

Validate package name.

What did you do?

Package name a-b.

What did you expect to see?

Invalid name.

What did you see instead?

C++ compile error.

Mys version

cross compilation

Following discord discussion on cross compiling, trying to canvas things to do.

reminder

    build: the machine you are building on
    host: the machine you are building for
    target: the machine that compiler will produce binary for

What is really defining a target ?

it's an ecosystem defined by a combination of a libc+libstdc++ ( API ) , a linker (ABI) and an hardware architecture(CPU/ARCH) to run on.

What currently potential and usefull targets for mys ?

  • emscripten ( works , happens to be the most used platform on this earth (web) !)
  • wasi ( does not work yet but may be soon very interesting ).
  • android ( works too , happens to be the most widespread OS on this earth )

emscripten ( runs on javascript engine or wasm , all to be found in modern browsers eg chromium 81+ )

CPU/ARCH: asm.js or wasm
API : good supports for C/C++ standards and exceptions and with limited threading, no jit no native call ( browser sandboxing )
ABI: better use static linking of PIC objects.
executables are multifile : one .html or .js , a .wasm for bitcode and possibly a .data for a posix filesystem archive ( used to provide files in browsers )

wasi ( wasm / use a runtime interpreter on bytecode )

CPU/ARCH: wasm
API : no support for C setjmp, and not C++ exceptions and limited threading, can do ffi and native calls
ABI: better use static linking of PIC objects.
executables : .wasm that use a specific ABI revision from a key/value mapping ( older key called "wasi_unstable" most recent "wasi_snapshot_preview1" ) usually evolved from "cloudabi" https://github.com/NuxiNL/cloudlibc.

very close to emscripten may merge with it sooner or later.

android ( a linux mobile kernel flavour easily embedded )

CPU/ARCH: mips arm5/arm7 arm64 x86 x86_64
API: numbered from 1 to 30 with C broken locales until api 24 but overall good C++ support, https://en.wikipedia.org/wiki/Android_version_history
ABI: ELF executables using a linux-ish custom linker located at /system/bin/linker that does not respect RPATH and RTLD_ params
must be packaged in a signed ZIP file called APK.

more info https://pythondev.readthedocs.io/android.html
signing zip/apk may require external tools or specific java versions and esoteric knowledge.

how to compile for a target ?

These three arch have usually the common problem that the build cannot run the host binaries ( except maybe (quite) complex linux build + some tweak with binfmt / proot / chroot ) or that native compilation via emulation is very slow and may require admin rights.

so short answer : use cross compilation.

toolchains are provided by vendors for all those targets or usually already supported by recent versions of clang 10+

all toolchains listed here are clang versions customized for target to run on linux x86_64 systems. It may be possible to deploy those on darwin, aosp, win32 systems but it's yet out of scope.

emscripten :
clang based easy to install with

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk && ./emsdk update-tags && ./emsdk install --embedded latest && ./emsdk activate --embedded latest

wasi:
get https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz and unpack.
standard clang cross compilation rules apply and work with all classic posix build tools.

android:
clang toolchains ( a lot of them ) grouped under the acronym NDK ( native developpement kit )
goto https://developer.android.com/ndk/downloads and pick a know-to-work version because ndk new versions break things, have silly layout and exotic build tools and TLDR licensing. cmake may work.

good to know: github actions provide ready to use NDK CI. python-for-android/beeware projects may demonstrate how to setup a ndk headless without too much user stress.

Mys ?

Mys need to know :
which toolchain is to be used
where it is located ( and how to set it up )
which api/abi/cpu
which custom restrictions/warning to apply when transpiling : maybe use a C preprocessor ? common macro are __EMSCRIPTEN__ __wasi__ __ANDROID__ __ANDROID_API__

That's too much at once and should be decomposed to avoid "black box" effect and too huge/complicated scripts unless you plan to provide some docker/vm image or unsigned prebuilts !

proposal part 1:

three root packages:
mys-cross-emsdk mys-cross-wasi mys-cross-android that can download toolchains, present and accept licenses and set compiler up

i'm strongly in favor of using a custom python sysconfig template because it would help narrow down and maybe solve lots of pip extension building problems on c-python ecosystem ( upstream step 2 )

proposal part 2:

a parent package mys-cross-compile
a generic robust parent package files which by default would target the OLDER and MOST COMPATIBLE target of each ecosystem to ensure large audience.

run real TESTSUITES on real or emulated host and offer support only on those "old stables", and maybe integrate with pip testrunner ( upstream step 3).

proposal part 3:

use small patch files to apply versionning on the parent package from a folder with a specific name scheme.
( and maybe use https://pypi.org/project/patch in case not gnu/linux for applying conversion )

matching each target with a MULTIARCH tag inspired from python/pip and some earlied proposals on bugs.python.org (bpo) for android. https://bugs.python.org/issue?%40search_text=android+multiarch&submit=search

which CPU/ARCH to pass to the underlying C++ compiler ( clang )
which API to select
which ABI to interface

that method also allow extra tag like "-testmynewapi" on simple and small patches folders to test contributors proposals.

draft for naming : pmp-p/pydk#22

eg:

./mys/cli/templates/build/Makefile
./mys/lib/mys.cpp
./mys/transpiler/source_visitor.py

When addressed by mys build/install with a --target parameter.
for eg --target=wasm_1_emscripten you would have those to apply from the matching target folder:

wasm_1_emscripten/cli/templates/build/Makefile.diff
wasm_1_emscripten/lib/mys.cpp.diff
wasm_1_emscripten/transpiler/source_visitor.py.diff

try to do it as much as "pip/MULTIARCH" as possible and eventually ( upstream step 1 )


Sidenotes :

  • All this process as been used for real ( except automated testing) with cpython/panda3d that includes ** a lot ** of third parties that mys can gain access to at least for emscripten and android via https://github.com/pmp-p/pydk

  • As one can see upstreaming to pip steps order is not the same as Mys logical progress that may explain why cross compilation is stalled on Python ecosystem.

Panic instead of raising error?

Make NoneError, UnreachableError and IndexError in some places should panic instead of raising an error. No logic should be based on catching these errors. A panic will terminate the program.

This ensures that --unsafe does not change the program logic.

UnreachableError should be a panic because one don't want to list that in @raises() decorator, and no logic should be based on executing unreachable code.

fail to build

What did you do?

mys build

What did you expect to see?
finish building the program

What did you see instead?

✔ Reading package configuration (0 seconds)
✔ Downloading dependencies (0 seconds)
✘ Building (0.1 seconds)
/an/duyum/etki/ld: build/speed/mys.o: in function std::_Sp_counted_deleter<pcre2_real_code_32*, mys::Regex::Regex(mys::String const&, mys::String const&)::{lambda(pcre2_real_code_32*)#1}, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose()': mys.cpp:(.text._ZNSt19_Sp_counted_deleterIP18pcre2_real_code_32ZN3mys5RegexC4ERKNS2_6StringES6_EUlS1_E_SaIvELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv+0x9): undefined reference to pcre2_code_free_32'
/an/duyum/etki/ld: build/speed/mys.o: in function std::_Sp_counted_deleter<pcre2_real_match_data_32*, mys::Regex::match(mys::String const&) const::{lambda(pcre2_real_match_data_32*)#1}, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose()': mys.cpp:(.text._ZNSt19_Sp_counted_deleterIP24pcre2_real_match_data_32ZNK3mys5Regex5matchERKNS2_6StringEEUlS1_E_SaIvELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv+0x9): undefined reference to pcre2_match_data_free_32'
/an/duyum/etki/ld: build/speed/mys.o: in function mys::Regex::Regex(mys::String const&, mys::String const&) [clone .cold]': mys.cpp:(.text.unlikely._ZN3mys5RegexC2ERKNS_6StringES3_+0x78): undefined reference to pcre2_code_free_32'
/an/duyum/etki/ld: build/speed/mys.o: in function mys::Regex::Regex(mys::String const&, mys::String const&)': mys.cpp:(.text._ZN3mys5RegexC2ERKNS_6StringES3_+0xd0): undefined reference to pcre2_compile_32'
/an/duyum/etki/ld: mys.cpp:(.text.ZN3mys5RegexC2ERKNS_6StringES3+0x195): undefined reference to pcre2_get_error_message_32' /an/duyum/etki/ld: build/speed/mys.o: in function mys::RegexMatch::span(int) const':
mys.cpp:(.text._ZNK3mys10RegexMatch4spanEi+0x26): undefined reference to pcre2_get_ovector_pointer_32' /an/duyum/etki/ld: mys.cpp:(.text._ZNK3mys10RegexMatch4spanEi+0x32): undefined reference to pcre2_get_ovector_count_32'
/an/duyum/etki/ld: build/speed/mys.o: in function mys::RegexMatch::span(int) const [clone .constprop.0]': mys.cpp:(.text._ZNK3mys10RegexMatch4spanEi.constprop.0+0x24): undefined reference to pcre2_get_ovector_pointer_32'
/an/duyum/etki/ld: mys.cpp:(.text._ZNK3mys10RegexMatch4spanEi.constprop.0+0x2f): undefined reference to pcre2_get_ovector_count_32' /an/duyum/etki/ld: build/speed/mys.o: in function mys::Regex::get_error(int)':
mys.cpp:(.text._ZN3mys5Regex9get_errorEi+0x61): undefined reference to pcre2_get_error_message_32' /an/duyum/etki/ld: build/speed/mys.o: in function mys::RegexMatch::group(int) const':
mys.cpp:(.text._ZNK3mys10RegexMatch5groupEi+0x30): undefined reference to pcre2_substring_get_bynumber_32' /an/duyum/etki/ld: mys.cpp:(.text._ZNK3mys10RegexMatch5groupEi+0x1b3): undefined reference to pcre2_substring_free_32'
/an/duyum/etki/ld: build/speed/mys.o: in function mys::Regex::match(mys::String const&) const [clone .cold]': mys.cpp:(.text.unlikely._ZNK3mys5Regex5matchERKNS_6StringE+0x39): undefined reference to pcre2_match_data_free_32'
/an/duyum/etki/ld: build/speed/mys.o: in function mys::Regex::match(mys::String const&) const': mys.cpp:(.text._ZNK3mys5Regex5matchERKNS_6StringE+0x5b): undefined reference to pcre2_match_data_create_from_pattern_32'
/an/duyum/etki/ld: mys.cpp:(.text._ZNK3mys5Regex5matchERKNS_6StringE+0xad): undefined reference to pcre2_match_32' /an/duyum/etki/ld: build/speed/mys.o: in function mys::RegexMatch::group_index(mys::String const&) const':
mys.cpp:(.text._ZNK3mys10RegexMatch11group_indexERKNS_6StringE+0x104): undefined reference to pcre2_substring_number_from_name_32' /an/duyum/etki/ld: build/speed/mys.o: in function mys::Regex::replace(mys::String const&, mys::String const&, int) const':
mys.cpp:(.text._ZNK3mys5Regex7replaceERKNS_6StringES3_i+0x131): undefined reference to pcre2_substitute_32' /an/duyum/etki/ld: build/speed/mys.o: in function mys::Regex::split(mys::String const&) const':
mys.cpp:(.text._ZNK3mys5Regex5splitERKNS_6StringE+0x82): undefined reference to pcre2_get_ovector_count_32' /an/duyum/etki/ld: build/speed/mys.o: in function mys::RegexMatch::groups() const':
mys.cpp:(.text._ZNK3mys10RegexMatch6groupsEv+0x56): undefined reference to pcre2_get_ovector_count_32' /an/duyum/etki/ld: build/speed/mys.o: in function mys::RegexMatch::group_dict() const':
mys.cpp:(.text._ZNK3mys10RegexMatch10group_dictEv+0x7b): undefined reference to pcre2_get_ovector_count_32' /an/duyum/etki/ld: mys.cpp:(.text._ZNK3mys10RegexMatch10group_dictEv+0x93): undefined reference to pcre2_pattern_info_32'
/an/duyum/etki/ld: mys.cpp:(.text._ZNK3mys10RegexMatch10group_dictEv+0xa6): undefined reference to pcre2_pattern_info_32' /an/duyum/etki/ld: mys.cpp:(.text._ZNK3mys10RegexMatch10group_dictEv+0xb9): undefined reference to pcre2_pattern_info_32'
collect2: error: ld returned 1 exit status
make[1]: *** [build/speed/Makefile:88: build/speed/app] Error 1

Mys version
0.341.0
latest git(1df7f7a)

OS
musl libc based custom x86_64 linux distribution

Inferred type from (v == 1) does not work

What did you do?

def main():
    v = (1 == 2)
    print(v)

What did you expect to see?

False

What did you see instead?

  File "./src/main.mys", line 157
        v = (1 == 2)
        ^
CompileError: cannot infer type from None

Mys version

0.170.0

debugger entry points

all compiler or runtime errors that could happen at various stage of using "mys" command, if able to get a source filename, maybe a line number and optionnal colummns + an error message should adress a call to a function (eg builtins.mys_debug ) loaded from a module that could be overridden from command line eg :

--debug=mymodule

try:
    __import__(mymodule)
except:
    def mys_debug(*argv,**kw):
        pass # or the default fancy display with colors as an example.
    import builtins
    builtins.mys_debug

this is mainly for interacting with IDE and/or when compiling remotely to give a translated filename.

Communication channels and general orientation

Hi, thanks for the invitation.

May i suggest freenode irc #msys for getting around various subjects at a slow pace ?

My goal is to get a slow, interpreted, async, easy language that can be optimized to the max but in simple ways.

I'm not interested in a fully compiled language, cython, a toy or a JIT : i'm mostly interested in turning functions bodies of dynamic languages like Python into C and wast/wasm when it's usefull.

=> I actually write the body in C so here's my interest for msys or transpilation.

I'm actually very interested in annotated (micro)python like syntax -> C transpilation and especially asynchronous aspect of things and also rapid prototyping of C ( maybe C++) functions compiled on-the-fly from inside python code like one can already do with dragonffi https://github.com/aguinet/dragonffi or maybe ppci https://github.com/windelbouwman/ppci.

pro: it just work already.
con: mys or a 1:1 annotated python transpiler would be way better.

general idea for hosting compiled code in a bytecode vm :
eg https://github.com/pmp-p/wapy/blob/wapy-wasi/ports/wapy/cmod/common/_zipfile.pym => https://github.com/pmp-p/wapy/blob/wapy-wasi/ports/wapy/cmod/common/_zipfile/mod_zipfile.c

or with dragon ffi :
https://gist.github.com/pmp-p/d5902fb79f6ad4415cc24ac9b612948f

Similarities to Nim?

This is a great project, with a similar feel to Nim - do steal as much from Nim as you can!
How does the "rust-like" packaging compare to Nimble?

Hello from Shedskin

In the vein of #1.

README:

All variables must have a known type at compile time. The same applies to function parameters and return value.

With limitations like that, and AOT nature, the closest no-NIH project doing that is Shedskin. Except that of course it's not as primitive as Mys [currently], but performs type inference. (But yes, it requires each variable to resolve to a single type, which is a usual limitation of a simple AOT approach, and why most projects use JIT.)

C++ compiler flags and contributions

Hello,

Is there currently a way to pass flags to the C++ compiler from the Mys command rather than manually linking the transpiled cpp files? Since we can embed arbitrary c++ it should of course be trivial to use c and c++ libraries, but I'm wondering if there is a shortcut to passing flags to the compiler right now.

Also whats the stance on contributions? This project seems actually very useful and I'd like to get involved somehow. Could I maybe port a Python or C++ library to Mys? Or maybe there is a language feature that I could work on?

Regards

Access imported class' member with unknown type.

What did you do?

main.mys:

from . import Foo

def main():
    print(Foo().a.b)

lib.mys:

class Foo:
    a: Bar

    def __init__(self):
        self.a = Bar("hi")

class Bar:
    b: string

What did you expect to see?

Successful build. The idea is that all public members shall be possible to access (obviously). They must also be a public type.

What did you see instead?

  File "./src/main.mys", line 4
        print(Foo().a.b)
              ^
CompileError: 'foo.lib.Bar' has no member 'b'

Mys version

0356d92

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.