Giter VIP home page Giter VIP logo

fusionscript's Introduction

RyanSquared // Ryan Heywood

Cypherpunk chat protocol nerd

Contact Me

  • E-Mail
  • IRC at ircs://irc.hashbang.sh/#! (look for "ryan")
  • Matrix at #!:hashbang.sh (look for @ryansquared:beeper.com)
  • Mastodon at @[email protected]

PGP Stuff

This page is signed using one of the keys here. You can use those keys to detect whether further changes to this document were made by me.

fusionscript's People

Contributors

chickennuggers avatar erinzm avatar ryansquared avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

daurnimator

fusionscript's Issues

`const` and `enum` statements

enum

enum would help with speed at runtime when checking between multiple values:

enum ConnectionType {
    INET;
    INET6;
    UNIX;
};

print(INET == ConnectionType.INET);

INET and ConnectionType.INET both compile to 1, so the resulting code would be similar to:

print(1 == 1)

enum values may be assigned with an "initial" value; values assigned afterwards take the value of the former, adding one:

enum Numbers {
    ZERO = 48;
    ONE;
    TWO;
    THREE;
    FOUR;
    FIVE;
    SIX;
    SEVEN;
    EIGHT;
    NINE;
    TEN;
};

Enumeration values could also be assigned after an initial
assignment, and to any integer, negative or positive:

enum Numbers {
    NFIVE = -5;
    NFOUR;
    NTHREE;
    ZERO = 0;
    ONE;
    TWO;
    TEN = 10;
};

Enumeration values can't go backwards:

enum BadEnum {
    ONE;
    ZERO = 0; -- errors during compilation
};

const

const values are like enumerations, but only one value is assigned per statement:

--- FusionScript
const max_char = 255;
print(string.char(max_char));
--- Lua
print(255);

Unlike enumerations, const values can also be true, false, nil, or a string:

--- FusionScript
const format_pattern = "%s: %s";
print(format_pattern:format(name, message));
--- Lua
print(("%s: %s"):format(name, message))

CONSIDERATION: "%s: %s":format() is not valid Lua. Instead, the
value - if not used only as a value, for instance, as a callable or indexable
object - should be wrapped in parenthesis first.

Cache parsed ASTs

This will be useful for:

  • const and enum scanning (this issue is a prerequisite
  • Speed up compilation times for files that don't need to be recompiled

Chaining function calls does not work

This should work:

File("test.txt"):with(\file-> print(file:read("*a")));

It does not. The lexer needs to change the actual call (i.e. the .x.y:z<a>() into an array of these calls

`import` statement and `-- @module` directive

  • @module directive
  • import

import

To help with using #4 across multiple files, the compiler should be aware of enums that are used cross-process. The import statement can be used to direct the compiler to both scan the module for enumerations, as well as load values from the module:

--- FusionScript
import stdlib.error {
    BaseError;
};
--- Lua
local _des_0 = require("stdlib.error")
local BaseError = _des_0.BaseError

All values can be extracted from a module, but many linters would not be aware of this. The syntax will also only work if the module has a module directive at the top of the file.

--- FusionScript
import stdlib.error *;
--- Lua
local _des_0 = require("stdlib.error")
local BaseError, Error, assert = _des_0.BaseError, _des_0.Error, _des_0.assert

Enumerations can also be included but will not show up in the compiled output:

--- FusionScript - example.fuse
import connections {
    ConnectionType;
};
print(ConnectionType.INET);
--- FusionScript - connections.fuse
-- @module connections
enum ConnectionType {
    INET;
    INET6;
    UNIX;
};
--- Lua - example.lua
print(1);
--- Lua - connections.lua
_ENV = setmetatable({}, {__index = _G})
return _ENV

An entire module can be loaded into a table, instead of having values destructured into the local scope:

--- FusionScript
import stdlib.error => error;
--- Lua
local error = require("stdlib.error");

-- @module directive

A comment that matches the pattern -- @<directive> [parameter] is considered a directive. When parsing a file, the compiler will take advantage of these comments to produce output that better matches the type of file. The -- @module directive (with a single required parameter, the name of the module) instructs the compiler that the following file should be treated as a module, which will set the environment to a contained table (to prevent leaking of values assigned globally) and return the table at the end of the file:

--- FusionScript - example.fuse
-- @module example

printf(fmt, ...)=>
    print(string.format(fmt, ...));
_ENV = setmetatable({}, {__index = _G})
function printf(fmt, ...)
    print(string.format(fmt, ...))
end
return _ENV

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.