Skip to content

Latest commit

 

History

History
executable file
·
173 lines (169 loc) · 10.3 KB

wishlist.md

File metadata and controls

executable file
·
173 lines (169 loc) · 10.3 KB

Bugs

  • [line 2] Error at "x": Local variable is not used.
x()
fun x() { print "hej" }

Wish list

  • Immutable-by-default (e.g. introduce a mut keyword)
  • Compile-time error to redefine variable/function
  • No semi-colons
  • Change assignment to be a statement instead of an expression?
  • Change more statements into expressions
  • No variable shadowing
  • Avoid local function variables overwriting function arguments (e.g. let a = "local")
  • Static analysis for
    • Simple dead code
    • Using uninitialized variables (let)
    • Using uninitialized variables (mut)
    • if with constant conditional expression
    • Useless expressions, e.g. 'hello world'
    • Function and variable names uses snake_case
    • Struct names uses PascalCase (??)
    • All paths not returning a value if the function has a return value
    • Ensure correct number of arguments at compile time instead of at runtime
    • Checking that if a function returns a value, the invoking code uses (or discards) that value
  • Optimizer
    • Optimize usages of literals in let's. They're constants in pratice.
    • Optimize e.g. x + 2 + 3 + 4 + 5 + 6 to x + 20
  • for-loop without sugaring (makes output code ugly)
  • Strong types by requiring variables to be initialized (later this may be handle by static analysis)
  • Replace classes with structs
  • Modules
  • Experiment with bytecode
  • Support for arrays
    • Support for array literal
    • Support for array length
    • Support for push
    • Support for getting value at index
    • Support for array indexing
    • Support for map function
    • Support for filter function
  • Support for maps
  • String interpolation
  • +=, -=, *=, /= operators
  • Typing phase
  • Optimization phase
  • Improve readme/documentation
  • Compile-time error if a variable is marked as mut but is not reassigned
  • break keyword
  • continue keyword
  • A more convient way to handle a standard library
  • Replace return _ with return. Look at how semicolons are handling in the original implementation.
  • Simplify code now that...
    • Variable shadowing is gone (scopes may be simplified)
    • nil is gone
    • for-loops can be made without an identifer (underscores are not required on unused loop counters anymore)
    • Classes are gone
  • Cosy playground
    • Compile for JavaScript
    • Make simple Cosy playground website
    • Make playground available through github pages
    • Scan + parse + resolve the code on keypress or after a timeout
    • [-] Syntax highlighting for codemirror
  • Make "Undefined variable" a compile-time error instead of a runtime error, e.g. print "hej"\nasdf
  • Disable some static analysis for REPL, e.g. checking for unused variables
  • Perserve empty lines and comments when pretty-printing and outputting to javascript
  • Time a "real" project and do performance optimizations
  • Algebraic data types
  • Switch/match functionality
  • Pure functions as default (cannot modify variables outside scope, must be deterministic, can only call other pure functions)
  • "Transform" functions that promote data-oriented design; must be pure, must not include if + called functions must satify the same constraints. Could be done with annotations, e.g. [transform] fn trans() { ... }
  • Better error position reporting with character from-to indexes [check the "Better error messages" stash]
  • A target that outputs code + documentation as markdown
  • for 0..10 syntax, instead of for _i in 0..10
  • Make a strict mode that requires specifying type information for function parameters and return values. It also requires functions to only access argument variables and local variables and non-mutable variables of outer scopes. I.e. it is not allowed to access mutable outer variables.
  • Rename files from .lox to .cosy
  • Change fun to fn
  • Change " to '
  • Consider integrations
  • Merge Mut into Let
  • Need to take line breaks into account to avoid cases where parsing fails because it "continues" on the next line, e.g. mut b\nb = '2'
  • Remove unused testing code (Cosy.hx + tests/)
  • Make array concat be simply + (or ++ like in Haskell?)
  • Perserve ordering of members when printing a struct
  • Remove Mutable as a type in Typer and try an alternative implemention (e.g. metadata)
  • Make a new and improved Hangman example with properly typed code, structs and arrays
  • Update Cosy basics example with structs, functions taking mut struct, string functions
  • Submit Cosy example to "99 bottles" site (http://www.99-bottles-of-beer.net/submitnewlanguage.html)
  • Cosy documentation using Dox (https://github.com/HaxeFoundation/dox)
  • Make Cosy FFI work for more targets (see https://community.haxe.org/t/is-there-a-way-to-expose-a-haxe-library-as-a-library-for-another-target/508)
  • Make a phases sub-package
  • Change array type annotation from e.g. Array Num to num[]
  • Maybe: Change type annotation from e.g. Str to string and Num to number
  • Maybe: Change type annotation from e.g. fn F(blah Fun(string) number) number[] to fn F(blah: ((xyz: string) => number)): number[]
  • Compile errors ordered by line number, regardless of compilation phase (how?)
  • Introduce an Any type that is only allowed for foreign functions
  • Add --benchmark option
  • Ensure that global variables are defined before used (i.e. not late bound, like local variables). In short, make global variables work just like local variables. No late binding. No redefinition. Using a slot index in the VM.
  • Find a way to be able to parse mutually recursive functions that are not "late bound"
  • Just for fun: Make a version of "generative grammar" that can spit out Cosy code and format that code using --prettyprint
  • Drop the REPL?
  • Suggest variables/functions when misspelling variables/functions
  • Use more final variables and inline functions (https://haxe.org/manual/class-field-inline.html)
  • Make built-in functions snake-case, e.g. stringToNumber to string_to_number
  • Being able to concatinate strings and booleans
  • Remove brackets and use indentation checking instead?
  • Make a 'docs' command that outputs the following to the 'docs' directory (docsify): index.html, readme.md, _sidebar.md and a markdown file for each cosy file.
  • Make a CLI --help command
  • Make the CLI write out Cosy version and/or git commit
  • Detect invalid concatinations (+) in the Typer (and show a hint about string interpolation if one of the types is a string)
  • Make --times show how many lines/second was processed (scanner + parser)
  • Replace var with let (because they're constants, not variables)
  • Replace print with log (shorter, more concise)
  • Improve error messages
  • Split Cosy.hx into Cosy.hx and Compiler.hx
  • Make embedded execution be two-part: scanning, parsing, typing, optimizing + interpreting. The first part should return an AST that can be handed to the interpreter. See https://github.com/HaxeFoundation/hscript/#example
  • Show a stack trace on exceptions
  • Rename Resolver to StaticAnalyzer
  • Make Typer return a typed AST (otherwise rename to TypeChecker)
  • Typer: Variables multiplied, divided or subtracted must be numbers
  • Add a colored dot (●) in the error output to indicate which phases reported the error?
  • MAYBE serialize function arguments coming from other languages and deserialize on the Cosy-side? It could be a way to avoid dealing with complex function arguments but it probably won't work.
  • Make more of the standard library be implemented in Cosy (see https://oaklang.org/lib/std)
  • Use ??, ?. and local static variables from Haxe nightly
  • Make an annotation for pure functions
  • Make an annotation for memorizing a function (i.e. cache inputs => output)
  • A way to initialize a list with a size (like in C++; vector<int>(height, vector<int>(width, 0))))
  • Find a more elegant way of handling variable/parameter/return type/loop variable/named struct mutability. I may have to replace some enums with structures.
  • Replace nominal typing with structural typing?

Project wishlist

Long shots