Giter Site home page Giter Site logo

whistle-lang / whistle Goto Github PK

View Code? Open in Web Editor NEW
44.0 5.0 3.0 2.31 MB

๐Ÿ•ด One hella programming language

Home Page: https://whistle.deno.dev

License: MIT License

Rust 100.00%
whistle programming-language parser compiler wasm hacktoberfest

whistle's People

Contributors

carrotzrule123 avatar eliassjogreen avatar load1n9 avatar mierenmanz avatar notfilippo 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

Watchers

 avatar  avatar  avatar  avatar  avatar

whistle's Issues

Better errors and error handling

Related to #16. Our errors should be a standardized, numbered and give a tip to how to fix the error along with a nice message like that of rust. We should also have different error ranges depending on if the error is a lexer, parser, compiler, type or other error.

Proposal to add a fun currying syntax for nested function calls

This is an quite old idea but it would essentially allow for a function to be called in multiple different stages before finally executing:

fn bake_a_cake(first: str)(second: i32)(third: bool): str {
  // function body goes here
}

It could then be called like:

val first: fn((second: i32)(third: bool): str) = bake_a_cake("add something")
val final: str = first(123)(false)

This would probably require an auto or automatically inferred type along with a fn type for function references.

Integrate wasm-opt

Optionally integrating wasm-opt would allow us to create even smaller and faster code, without having to write our own optimizer.

Proposal to add conditional parameters to functions

Conditional parameters, while only syntax sugar would be a cool way of doing different things when the input of the function is different. I am undecided on wheter this is a good idea as it is just syntax sugur and would complicate things like compilation and type checking but its a cool idea at least:

// recursively calculate the factorial of n
fn fac(n: u64): u64 {
  return n * fac(n - 1)
}

// when parameter n is 1 call this function instead
fn fac(n: u64 == 1): u64 {
  return 1
}

The above code would be equivalent to, and while not in this case shorter it is in some ways more readable (and in some ways not):

fn fac(n: u64): u64 {
  if n == 1 {
    return 1
  }

  return n * fac(n - 1)
}

A formatter/linter and style guide

A simple formatter and linter, like clippy using the whistle lexer, parser and AST would be nice to have. In my opinion it should be opinionated, and be able to also only check for formatting errors instead of always fixing them. Along with the formatter we should also provide a standard style guide.

Here's my proposal for a minimal style guide we can start with:

  • 2 spaces instead of tabs
  • snake_case for everything but types which should be PascalCase
  • docs should always start with ///

Inline functions

Proposal to add inline functions using the inline keyword:

export inline fn test_inline(a: i32): u32 {
  return a as u32
}

This would most likely be implement by adding another field to the Compiler struct which contains the instructions for each registered inline function. This is useful for things like std/math, and other high performance, or small tasks where a function call is not desired.

Tips and inline wasm

The language should be extendable using "compiler tips" which are essentially macros, or simply put: compiler tips. These tips would be modularly implemented using an rust interface of some sort, keyed by the tip type as specified by identifier between the parenthesis of the tip: #(wasm). Tips are specified to be able to be single or multi-line depending if the body is surrounded by squiggly parenthesis.

These tips are implemented in rust as taking the body of the tip as raw text and could for example take wasm text format and convert its body to instructions. This would allow for unsafe, but greatly more powerful code much like the rust asm macro.

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.