Coder Social home page Coder Social logo

adamsol / pyxell Goto Github PK

View Code? Open in Web Editor NEW
54.0 3.0 6.0 3.32 MB

Multi-paradigm programming language compiled to C++, written in Python.

License: MIT License

Makefile 0.14% Python 51.15% C++ 48.72%
python cpp indentation syntax rational-numbers generators parser programming-language compiler

pyxell's People

Contributors

adamsol avatar thatxliner 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

Watchers

 avatar  avatar  avatar

pyxell's Issues

break and continue

C break and continue have limited utility because in a double loop, you cannot break out of the outer loop. I had these in my language too originally, but replaced them with labelled break and continue. In my language, the label is mandatory if you want to break or continue (or redo) but for compatibility you might allow the default to be the current loop. I think this is not a good idea though, because the absence of a label ensures the loop can only be either normally exited, or exited by a premature function return (which is a problem, it would be better if the assurance was absolute but I don't know how to do that in an imperative language with a return statement).

Support for decorators

I love the language design so far, especially with type annotations fixed to be in name: Type form.

But one thing, that I could not find in the docs nor in todo list, is the decorators. Do you have plans to add support for decorators?

Super

"Inside the method body, you can call the corresponding method of the parent class using super keyword."

What happens if your base and derived class have methods f and g, and in the definition of f in the derived class you want to call the base class method g? AFAIKS there is no way to do this. In fact i would suggest outlawing calling base class methods which have been overridden altogether. The only case where you might need to do this are in constructors.

C/C++ FFI?

Hello, I've skimmed Pyxell's documentation but didn't notice anything about an ffi, can Pyxell call C or C++? I assume that it has an easy cpp ffi since it compiles to c++.

Tuples are mutable

The docs say "Tuples are mutable, but they have value semantics, so they are hashable and can be passed around as if they were immutable."

No. Variables may be mutable, including variables of a tuple type. Modifying a component of a variable of a tuple type is equivalent to constructing a new tuple of the same type from the old one with a different value for that component, and assigning it. I think this is what you meant, it just reads wrong.

Lambda functions

I think, in Python lambda functions looks ugly, by design, in order to discourage use of lambdas if possible (I might be wrong).

Consider lambdas similar to ones used by Julia, for example, this Pyxel code:

double = lambda x: x * 2

Could look like this:

double(x) = x * 2

Or:

double(x: Rat): Rat = x * 2

Multi statement lambdas, could look like this:

count(n) def
    for i in n..0 by -1 do
        print i

strange cpp generation

Hi,

I tried the closure example:
// closure.px
func f() def
x = 0

func g() def
    x += 1
    print x

g()
print x

f()

func f() def
x = 0

func g() def
    x += 1
    print x

g()
print x

python pyxell.py closure.px
then gives non-expected cpp file contents below (with exe result correct!)
What goes wrong?

Exe compile works on company laptop after Python install via Windows app.
Not working at home with pre-existing Python if that can make a difference.
Error message is dll entry point for xxx_throw_bad_array_new_lengthv not found in dll xxx\closure.exe

File sizes:
closure.px 109
closure.cpp: 588
closure.exe: 549864

`/*
Generated by Pyxell 0.14.0.
https://github.com/adamsol/Pyxell
*/

Float v1;
Float v2;
const String v3 = make_string("inf"s);
Float v5;
const String v9 = make_string("\n"s);
Void f6();

Void f6() {
Int v10;
v10 = 0LL;
std::function<Void()> f11 = =, &f11 mutable -> Void {
v10 = (v10 + 1LL);
write(toString(v10));
write(v9);
};
f11();
write(toString(v10));
write(v9);
}

int main() {
v1 = 3.141592653589793;
v2 = 2.718281828459045;
Float v4 = [&](auto&& ...args) {
return toFloat(v3, args...);
}();
v5 = v4;
f6();
return 0;
}`

Types first?

I thought you were against this:

Float x

Why not use he universally accepted correct way to do this, namely

var x : Float

You can leave out the var if you want, but you HAVE to write the separator. You could use the reverse order too, but the separator is mandatory. There's a good example of why your syntax is untenable in your own examples:

A -> B f

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.