From 4bfbaeff15a1947bb5c80fbf648a51eb681d68c7 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Sun, 21 Sep 2014 20:20:25 -0400 Subject: [PATCH] Remix notes --- remix/README | 74 +++++++++++++++++++++++++++++++++++++++ remix/core.rkt | 2 ++ remix/examples/rocket.rkt | 22 ++++++++++++ remix/lang/reader.rkt | 5 +++ remix/seq/list.rkt | 25 +++++++++++++ remix/stx/read.rkt | 10 ++++++ 6 files changed, 138 insertions(+) create mode 100644 remix/README create mode 100644 remix/core.rkt create mode 100644 remix/examples/rocket.rkt create mode 100644 remix/lang/reader.rkt create mode 100644 remix/seq/list.rkt create mode 100644 remix/stx/read.rkt diff --git a/remix/README b/remix/README new file mode 100644 index 0000000..fe4ca6d --- /dev/null +++ b/remix/README @@ -0,0 +1,74 @@ +- No effects or expressions at top-level +- "Versioned" libraries +- No set! (use data-structure mutation and :=) +- Make macros less weird and more like programs, by... +- Unified matching (syntax-parse/match/etc) +- Unified templates (syntax, quasiquote, etc) + + If x is a list, then... + + (template (list (~seq 1 ,x) ...)) + => + (append-map (lambda (x) (list 1 x)) x) + + (template (syntax a ,x ... c)) + => + (syntax-cons a (syntax-append x (syntax c))) + + (template (+ (f ,x) ...)) + => + (apply + (map f x)) + +- @ everywhere +- Pattern matching everywhere +- New structs (more reflective information, representation control, sealing) +- Implicit units and interfaces (with properties) +- Bare-bones /base + +#lang racket/base +(define BASE-NAMES (namespace-mapped-symbols (make-base-namespace))) +(for ([i (in-list BASE-NAMES)]) + (displayln i)) +(displayln (length BASE-NAMES)) + +returns 1433 + +- Generics everywhere +- Non-() syntax "mode" + +array.[{1 + 1}].(foo) +-> +(#%dot array (#%brackets (+ 1 1)) (foo)) + +(define (foo (var x) (~opt y 17) (posn p)) + {x := z + 13} + {p.x + p.y}) + +- Implicit nesting in blocks + + (def (f x) + (def y 17) + (+ x y)) + +- Immutable strings only +- Remove letrec weirdness of define? +- "define"-transformers for attaching meta-information to definitions, like documentation, tests, contracts, types, etc +- Bindings & keywords everywhere +- Less representation contraints +- Meaningless eq? semantics +- Literate programming and inline docs easily +- No case-lambda +- Optional traditional numbers (num/generic => +) +- Optional non-coercing number tower (num/{fl,fx,i32,i64,f32,f64,nat,int,rational,real}) +-- with maybe impl (num/*/maybe) +-- with overflow errors impl (num/*/exn) +-- with modulo-X impl (num/*/modulo) +-- with modulo-X & carry impl (num/*/carry) +- More unicode! +- Unboxed, raw data +- Remove multiple values? +- Rocket-strength super cut: + + λ.(+ $0 $1) + +- Don't use English in exceptions and have more structured exns diff --git a/remix/core.rkt b/remix/core.rkt new file mode 100644 index 0000000..777481f --- /dev/null +++ b/remix/core.rkt @@ -0,0 +1,2 @@ +#lang racket/base +(provide #%module-begin) diff --git a/remix/examples/rocket.rkt b/remix/examples/rocket.rkt new file mode 100644 index 0000000..0e318ec --- /dev/null +++ b/remix/examples/rocket.rkt @@ -0,0 +1,22 @@ +#lang remix +(require remix/struct.0 + remix/match.0 + num/int.0 + gfx/2d.0 + big-bang.0) + +(struct #rocket + ([int h] + [int dh])) + +(data rocket + #:this [#rocket r] + (def (rocket [int (~opt h 0)] [int (~opt dh 1)]) + (#rocket.alloc [h h] [dh dh])) + #:implements world/anim^ + (def (tick) + (r.= [h {r.h + r.dh}])) + (def (draw) + (circle 'yellow 5))) + +(big-bang (new rocket)) diff --git a/remix/lang/reader.rkt b/remix/lang/reader.rkt new file mode 100644 index 0000000..0d8b65d --- /dev/null +++ b/remix/lang/reader.rkt @@ -0,0 +1,5 @@ +(module reader syntax/module-reader + remix/core + #:read remix:read + #:read-syntax remix:read-syntax + (require (prefix-in remix: remix/stx/read))) diff --git a/remix/seq/list.rkt b/remix/seq/list.rkt new file mode 100644 index 0000000..8f02537 --- /dev/null +++ b/remix/seq/list.rkt @@ -0,0 +1,25 @@ +#lang remix + +(data seq + (struct empty) + (def (first t) + (error)) + (def (rest t) + (error)) + (def (empty? t) + #t) + (def (cons x t) + ((outer cons) x t)) + (def (snoc t x) + ((outer cons) x t))) + +(data seq + (struct cons + [racket car] + [racket cdr]) + (def (first t) + t.car) + (def (rest t) + t.cdr) + (def (empty? t) + #f)) diff --git a/remix/stx/read.rkt b/remix/stx/read.rkt new file mode 100644 index 0000000..97d2f8b --- /dev/null +++ b/remix/stx/read.rkt @@ -0,0 +1,10 @@ +#lang racket/base + +(define (:read ip) (:read-syntax #f ip)) + +(define (:read-syntax name ip) + eof) + +(provide + (rename-out [:read read] + [:read-syntax read-syntax]))