whistle-lang / whistle Goto Github PK
View Code? Open in Web Editor NEW๐ด One hella programming language
Home Page: https://whistle.deno.dev
License: MIT License
๐ด One hella programming language
Home Page: https://whistle.deno.dev
License: MIT License
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.
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.
Optionally integrating wasm-opt would allow us to create even smaller and faster code, without having to write our own optimizer.
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)
}
Probably using toml, or perhaps as a part of the entry file of a Whistle program?
It's in the title, should be part of the spec
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:
snake_case
for everything but types which should be PascalCase
///
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.
Will require some standardized syntax for imports and also #18.
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.
https://whistle.deno.com/ doesn't exist. Should it be https://whistle.deno.dev/ instead?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.