2021-10-20 01:18:09 -07:00
# Immediate TODOs / General Code Cleanup
2021-11-01 12:35:25 -07:00
2021-10-25 23:26:03 -07:00
## Testing
2021-10-26 01:53:30 -07:00
* Make an automatic (macro-based?) system for numbering compiler errors, this should be every type of error
2021-10-25 23:26:03 -07:00
2021-10-20 01:18:09 -07:00
## Symbols
2021-10-25 02:46:10 -07:00
* Add some good printf-debugging impls for SymbolTable-related items
2021-10-20 01:18:09 -07:00
* 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)
2021-10-26 01:53:30 -07:00
* In fact to prove this works, the symbol table shoudl _parallelize_ the process of checking subscopes for local items
2021-10-20 01:18:09 -07:00
* Old notes on a plan of attack:
2019-11-08 18:56:15 -08:00
1. modify visitor so it can handle scopes
-this is needed both to handle import scope correctly
-and also to support making FQSNs aware of function parameters
2. Once FQSNs are aware of function parameters, most of the Rc< String > things in eval.rs can go away
2021-10-20 01:18:09 -07:00
## Typechecking
2019-10-24 03:09:17 -07:00
2021-10-20 01:18:09 -07:00
* 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
2019-11-18 03:11:00 -08:00
2019-09-03 02:19:37 -07:00
## General code cleanup
2021-10-20 01:18:09 -07:00
* 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)
2019-08-12 11:40:31 -07:00
2019-03-08 03:57:32 -08:00
2021-10-20 01:18:09 -07:00
# Longer-term Ideas
2019-08-12 11:40:31 -07:00
2021-10-20 01:18:09 -07:00
## Language Syntax
2019-04-29 23:57:59 -07:00
2021-10-20 01:18:09 -07:00
* the `type` declaration should have some kind of GADT-like syntax
* use `let` sigil to indicate a variable in a pattern explicitly:
2019-02-21 19:07:07 -08:00
2021-10-20 01:18:09 -07:00
```
q is MyStruct(let a, Chrono::Trigga) then {
// a is in scope here
2019-01-27 22:38:20 -08:00
2021-10-20 01:18:09 -07:00
}
```
2019-01-27 22:38:20 -08:00
2021-10-20 01:18:09 -07:00
* 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
2019-01-27 22:38:20 -08:00
2021-10-20 01:18:09 -07:00
* 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">` -> h1(prop=arg)
2019-05-26 00:23:54 -07:00
2021-10-20 01:18:09 -07:00
* implement and test open/use statements
2017-12-13 00:52:54 -08:00
2021-10-20 01:18:09 -07:00
* Include extensible scala-style `html"string ${var}"` string interpolations
2017-12-13 00:52:54 -08:00
2021-10-20 01:18:09 -07:00
* A neat idea for pattern matching optimization would be if you could match on
one of several things in a list
2019-03-20 01:15:35 -07:00
ex:
2021-10-20 01:18:09 -07:00
```
if x {
2019-03-20 01:15:35 -07:00
is (comp, LHSPat, RHSPat) if comp in ["==, "< "] -> ...
2021-10-20 01:18:09 -07:00
}
```
2019-03-20 01:15:35 -07:00
2021-10-20 01:18:09 -07:00
* Schala should have both currying *and* default arguments!
```
fn a(b: Int, c:Int, d:Int = 1) -> Int
2019-03-20 01:15:35 -07:00
a(1,2) : Int
a(1,2,d=2): Int
a(_,1,3) : Int -> Int
a(1,2, c=_): Int -> Int
a(_,_,_) : Int -> Int -> Int -> Int
```
2021-10-20 01:18:09 -07:00
* scoped types - be able to define a quick enum type scoped to a function or other type for
2019-03-20 01:15:35 -07:00
something, that only is meant to be used as a quick bespoke interface between
two other things
2021-10-20 01:18:09 -07:00
2019-03-20 01:15:35 -07:00
ex.
2021-10-20 01:18:09 -07:00
```
type enum {
2019-03-20 01:15:35 -07:00
type enum MySubVariant {
SubVariant1, SubVariant2, etc.
}
Variant1(MySubVariant),
Variant2(...),
2021-10-20 01:18:09 -07:00
}
```
2019-01-27 22:38:20 -08:00
2021-10-20 01:18:09 -07:00
* inclusive/exclusive range syntax like .. vs ..=
2018-11-16 15:53:27 -08:00
2021-10-30 23:20:57 -07:00
* Nameable patterns/ pattern synonyms cf. https://gitlab.haskell.org/ghc/ghc/-/wikis/pattern-synonyms
2018-11-16 15:53:27 -08:00
2021-10-20 01:18:09 -07:00
## 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
2018-11-16 15:53:27 -08:00
2021-10-20 01:18:09 -07:00
## Compilation
* look into Inkwell for rust LLVM bindings
* https://cranelift.readthedocs.io/en/latest/?badge=latest< Paste >
2018-07-18 23:00:11 -07:00
2021-10-20 01:18:09 -07:00
* look at https://gluon-lang.org/doc/nightly/book/embedding-api.html
2019-01-07 01:59:12 -08:00
2018-11-16 15:53:27 -08:00
2021-10-20 01:18:09 -07:00
# Syntax Playground
2018-08-19 21:11:43 -07:00
2019-10-09 02:32:41 -07:00
## Trying if-syntax again
2018-08-19 21:11:43 -07:00
2021-10-20 01:18:09 -07:00
```
2019-10-09 02:32:41 -07:00
//simple if expr
if x == 10 then "a" else "z"
//complex if expr
if x == 10 then {
let a = 1
let b = 2
a + b
} else {
55
}
// different comparison ops
if x {
== 1 then "a"
.isPrime() then "b"
else "c"
}
/* for now disallow `if x == { 1 then ... }` , b/c hard to parse
//simple pattern-matching
if x is Person("Ivan", age) then age else 0
//match-block equivalent
if x {
is Person("Ivan", _) then "Ivan"
is Person(_, age) if age > 13 then "barmitzvah'd"
else "foo"
}
2021-10-20 01:18:09 -07:00
```
2019-10-09 02:32:41 -07:00
## (OLD) Playing around with conditional syntax ideas
2018-07-01 00:42:50 -07:00
2019-06-16 16:07:27 -07:00
2018-06-14 00:49:11 -07:00
- if/match playground
simple if
`if x == 1.0 { "a" } else { "b" }`
one comparison multiple targets:
`if x == { 1.0 -> "a", 2.0 -> "b", else -> "c" }`
different comparison operators/ method calls:
`if x { == 1.0 -> "a", eq NaN -> "n", .hella() -> "h", else -> "z" }`
pattern matching/introducing bindings:
`if alice { .age < 18 -> "18", is Person("Alice", age) -> "${age}", else -> "none" }`
pattern matching w/ if-let:
`if person is Person("Alice", age) { "${age}" } else { "nope" }`
2018-06-14 05:42:12 -07:00
-https://soc.github.io/languages/unified-condition-syntax syntax:
`if <cond-expr>" then <then-expr> else <else-expr>`
`if <half-expr> \n <rest-expr1> then <result1-expr> \n <rest-expr2> then <result-expr2> else <result3-expr>`
-and rest-exprs (or "targets") can have 'is' for pattern-matching, actually so can a full cond-expr
2018-06-18 23:26:02 -07:00
UNIFIED IF EXPRESSIONS FINAL WORK:
basic syntax:
`if_expr := if discriminator '{' (guard_expr)* '}'`
`guard_expr := pattern 'then' block_or_expr'`
`pattern := rhs | is_pattern`
`is_pattern := 'is' ???`
`rhs := expression | ???`
if the only two guard patterns are true and false, then the abbreviated syntax:
`'if' discriminator 'then' block_or_expr 'else' block_or_expr`
can replace `'if' discriminator '{' 'true' 'then' block_or_expr; 'false' 'then' block_or_expr '}'`