From 5eb743a8b5e598bdc8df008f7eee2d251124e6c5 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Wed, 20 Oct 2021 01:18:09 -0700 Subject: [PATCH] Updated TODO file --- TODO.md | 131 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 73 insertions(+), 58 deletions(-) diff --git a/TODO.md b/TODO.md index 87d7c3a..c45ff05 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,12 @@ -# Plan of attack +# Immediate TODOs / General Code Cleanup + +## Symbols + +* the symbol table should probably *only* be for global definitions (maybe rename it to reflect this?) +* dealing with variable lookup w/in functions/closures should probably happen in AST -> ReducedAST + * b/c that's where we go from a string name to a canonical ID (for e.g. 2nd param in 3rd enclosing scope) + +* Old notes on a plan of attack: 1. modify visitor so it can handle scopes -this is needed both to handle import scope correctly @@ -6,66 +14,61 @@ 2. Once FQSNs are aware of function parameters, most of the Rc things in eval.rs can go away -# TODO items +## Parser +* I think I can restructure the parser to get rid of most instances of expect!, at least at the beginning of a rule --use 'let' sigil in patterns for variables : +## Typechecking + +* make a type to represent types rather than relying on string comparisons +* look at https://rickyhan.com/jekyll/update/2018/05/26/hindley-milner-tutorial-rust.html + +## General code cleanup +* standardize on an error type that isn't String +* implement a visitor pattern for the use of scope_resolver + * maybe implement this twice: 1) the value-returning, no-default one in the haoyi blogpost, + * look at + * https://gitlab.haskell.org/ghc/ghc/wikis/pattern-synonyms + * the non-value-returning, default one like in rustc (cf. https://github.com/rust-unofficial/patterns/blob/master/patterns/visitor.md) + + +# Longer-term Ideas + +## Language Syntax + +* the `type` declaration should have some kind of GADT-like syntax +* use `let` sigil to indicate a variable in a pattern explicitly: ``` q is MyStruct(let a, Chrono::Trigga) then { + // a is in scope here } ``` --idea: what if there was something like React jsx syntas built in? i.e. a way to automatically transform some kind of markup -into a function call, cf. `

` -> h1(prop=arg) +* if you have a pattern-match where one variant has a variable and the other + lacks it instead of treating this as a type error, promote the bound variable + to an option type -## General code cleanup -- I think I can restructure the parser to get rid of most instances of expect!, at least at the beginning of a rule -DONE -experiment with storing metadata via ItemIds on AST nodes (cf. https://rust-lang.github.io/rustc-guide/hir.html, https://github.com/rust-lang/rust/blob/master/src/librustc/hir/mod.rs ) --implement and test open/use statements --implement field access -- standardize on an error type that isn't String --implement a visitor pattern for the use of scope_resolver - - maybe implement this twice: 1) the value-returning, no-default one in the haoyi blogpost, - -look at https://gitlab.haskell.org/ghc/ghc/wikis/pattern-synonyms - 2) the non-value-returning, default one like in rustc (cf. https://github.com/rust-unofficial/patterns/blob/master/patterns/visitor.md) +* what if there was something like React jsx syntas built in? i.e. a way to + automatically transform some kind of markup into a function call, cf. `

` -> h1(prop=arg) --parser error - should report subset of AST parsed *so far* - - what if you used python 'def' syntax to define a function? what error message makes sense here? +* implement and test open/use statements -## Reduction - - make a good type for actual language builtins to avoid string comparisons +* Include extensible scala-style `html"string ${var}"` string interpolations -## Typechecking - -- make a type to represent types rather than relying on string comparisons - -- look at https://rickyhan.com/jekyll/update/2018/05/26/hindley-milner-tutorial-rust.html - -- cf. the notation mentioned in the cardelli paper, the debug information for the `typechecking` pass should -print the generated type variable for every subexpression in an expression - -- think about idris-related ideas of multiple implementations of a type for an interface (+ vs * impl for monoids, for preorder/inorder/postorder for Foldable) - --should have an Idris-like `cast To From` function - -## Schala-lang syntax - --idea: the `type` declaration should have some kind of GADT-like syntax - -- Idea: if you have a pattern-match where one variant has a variable and the other lacks it -instead of treating this as a type error, promote the bound variable to an option type - -- Include extensible scala-style html"string ${var}" string interpolations - -- A neat idea for pattern matching optimization would be if you could match on one of several things in a list +* A neat idea for pattern matching optimization would be if you could match on + one of several things in a list ex: -```if x { +``` +if x { is (comp, LHSPat, RHSPat) if comp in ["==, "<"] -> ... -}``` +} +``` -- Schala should have both currying *and* default arguments! -```fn a(b: Int, c:Int, d:Int = 1) -> Int +* Schala should have both currying *and* default arguments! +``` +fn a(b: Int, c:Int, d:Int = 1) -> Int a(1,2) : Int a(1,2,d=2): Int a(_,1,3) : Int -> Int @@ -73,35 +76,47 @@ ex: a(_,_,_) : Int -> Int -> Int -> Int ``` -- scoped types - be able to define a quick enum type scoped to a function or other type for +* scoped types - be able to define a quick enum type scoped to a function or other type for something, that only is meant to be used as a quick bespoke interface between two other things + ex. -```type enum { +``` +type enum { type enum MySubVariant { SubVariant1, SubVariant2, etc. } Variant1(MySubVariant), Variant2(...), - }``` + } +``` + +* inclusive/exclusive range syntax like .. vs ..= + + +## Typechecking + +* cf. the notation mentioned in the cardelli paper, the debug information for the `typechecking` pass should + * print the generated type variable for every subexpression in an expression +* think about idris-related ideas of multiple implementations of a type for an interface (+ vs * impl for monoids, for preorder/inorder/postorder for Foldable) +* should have an Idris-like `cast To From` function + +* something like the swift `Never` type ( https://nshipster.com/never/ ) in the stdlib -- inclusive/exclusive range syntax like .. vs ..= ## Compilation --look into Inkwell for rust LLVM bindings +* look into Inkwell for rust LLVM bindings +* https://cranelift.readthedocs.io/en/latest/?badge=latest --https://cranelift.readthedocs.io/en/latest/?badge=latest +* look at https://gluon-lang.org/doc/nightly/book/embedding-api.html -## Other links of note - -- https://nshipster.com/never/ --consult http://gluon-lang.org/book/embedding-api.html - +# Syntax Playground ## Trying if-syntax again +``` //simple if expr if x == 10 then "a" else "z" @@ -132,7 +147,7 @@ if x { is Person(_, age) if age > 13 then "barmitzvah'd" else "foo" } - +``` ## (OLD) Playing around with conditional syntax ideas