Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,43 @@

More of a wish-list than a hard and fast plan.

* Types
* Types.
* Consider type classes as a general solution to `EQ <type>` etc.
* Records should create accessor functions for each tag.
* Parser
* if there is only one type variant.
* Parser.
* re-elist the now-available `macro` keyword for proper syntactic extensibility:
* if/then/else => `(fn { (true) {then} (false) {else} }(if))` (we already do this but hard-coded in the parser).
* `do` notation for monads.
* Memory Management
* Replace mark and sweep GC with a generational stop and copy
* Target LLVM
* `syntax` construct that allows large-scale syntactic structures to be defined by the user.
* Generate
* Memory Management.
* Replace mark and sweep GC with a generational stop and copy.
* Pipeline.
* Port/Implement prototype closure conversion from fn/rewrite.
* Target LLVM.
* Generate.
* Move all signatures into `signature_helper.py`, not just the shared ones.
* More numbers:
* More numbers.
* Vectors.
* Matrices.
* Quaternions.
* Vectors.
* Improve arithmetic.
* ceil, floor and round operations.
* move to [libgmp](https://gmplib.org/)?
* trig and log functions.
* allow numeric (not symbolic) arithmetic expressions in patterns.
* allow unpacking of numerator and denominator variables in patterns.
* special case: `a / b` because there is a canonical form (via gcd).
* but does `a / 6` match `2 / 3` and bind `a` to `4`?
* does `a / 6` match `2 / 3` and bind `a` to `4`.
* match would fail if the actual argument is not integer or rational.
* `b` would be bound to `1` if the argument was an integer.
* can't allow arbitrary ops and combinations because i.e. `a * b`
can't uniquely determine `a` and `b`, and `a ** 2` would require `a`
to be bound to the square root of the actual argument.
* can't allow arbitrary ops and combinations because i.e. `a * b` can't uniquely determine `a` and `b`, and `a ** 2` would require `a` to be bound to the square root of the actual argument.
* allow unpacking of the real and imaginary parts of a complex number in patterns.
* another special case: `a + b`, `b` would be bound to `0i` if the actual argument is not complex.
* another special case: `a + b`, `b` would be bound to `0i` if the actual argument is not complex.
* Curried binary operators `(2+)` etc.
* (internal) have a NEWZ variant of NEW that bzero's its result.
* Builtins
* Builtins.
* `now()` builtin returns current time in milliseconds.
* I/O.
* Make i/o pleasant to use.
* Any ideas welcome, currently it's a mess.
* Specifically think about ways to support parsing.
2 changes: 2 additions & 0 deletions fn/rewrite/closure-convert.fn
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ link "freevars.fn" as FV;
link "gensym.fn" as GS;
link "subst.fn" as SUBST;

// https://matt.might.net/articles/closure-conversion/

fn closure_convert {
(exp=M.lambda(params, body)) {
let
Expand Down
4 changes: 2 additions & 2 deletions fn/rewrite/minexpr.fn
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ namespace
x;
}
(x=make_closure(func, env)) {
puts("(CLO ");
puts("[CLO ");
print_expr(func);
puts(" ");
print_expr(env);
puts(")");
puts("]");
x;
}
(x=make_env(bindings)) {
Expand Down
7 changes: 3 additions & 4 deletions fn/rewrite/test_harness.fn
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ in
// M.print_expr(f);
// puts("\n==> operator folding");
// puts(nltab);
puts("\n ");
M.print_expr(g);
// M.print_expr(g);
// puts("\n==> shared closure convert");
// puts(nltab);
// M.print_expr(h);
// puts("\n\n\n")
puts("\n ");
M.print_expr(h);
puts("\n\n")
}
}, Samples.data());
2 changes: 1 addition & 1 deletion src/lambda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ config:
- bigint.h
- tc.h
- tc_debug.h
- lambda_functions.h
- minlam_functions.h

structs:
LamLam:
Expand Down
30 changes: 0 additions & 30 deletions src/lambda_functions.h

This file was deleted.

4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
#include "hash.h"
#include "init.h"
#include "inline.h"
#include "lambda_alphaconvert.h"
#include "lambda_conversion.h"
#include "lambda_debug.h"
#include "lambda_desugar.h"
#include "lambda_pp.h"
#include "lambda_simplification.h"
#include "memory.h"
#include "minlam_alphaconvert.h"
#include "minlam_beta.h"
#include "minlam_eta.h"
#include "minlam_fold.h"
Expand All @@ -64,7 +64,7 @@
// #define TEST_CPS

#ifdef TEST_CPS
#include "lambda_cps.h"
#include "minlam_cps.h"
#endif

// temporary test
Expand Down
2 changes: 1 addition & 1 deletion src/lambda_alphaconvert.c → src/minlam_alphaconvert.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "symbol.h"
#include "utils.h"

#include "lambda_alphaconvert.h"
#include "minlam_alphaconvert.h"

// Forward declarations
static MinLam *visitMinLam(MinLam *node, MinAlphaEnv *context);
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/lambda_cpsTc.c → src/minlam_cpsTc.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

#include "cps_kont.h"
#include "cps_kont_impl.h"
#include "lambda_cps.h"
#include "lambda_functions.h"
#include "minlam_cps.h"
#include "minlam_functions.h"

#ifdef DEBUG_LAMBDA_CPSTC
#include "debugging_on.h"
Expand Down
4 changes: 2 additions & 2 deletions src/lambda_cpsTk.c → src/minlam_cpsTk.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

#include "cps_kont.h"
#include "cps_kont_impl.h"
#include "lambda_cps.h"
#include "lambda_functions.h"
#include "minlam_cps.h"
#include "minlam_functions.h"

#ifdef DEBUG_LAMBDA_CPSTK
#include "debugging_on.h"
Expand Down
7 changes: 6 additions & 1 deletion src/minlam_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
*/

struct MinExp;
struct AnfKontEnv;
struct CpsKontEnv;

#include "lambda_functions.h"
typedef struct MinExp *(*AnfKontProcWrapper)(struct MinExp *,
struct AnfKontEnv *);
typedef struct MinExp *(*CpsKontProcWrapper)(struct MinExp *,
struct CpsKontEnv *);

#endif