first version now that reader is in place
This commit is contained in:
parent
46504f94d8
commit
72d1c9d58b
109
remix/README
109
remix/README
|
@ -1,10 +1,16 @@
|
||||||
- @ everywhere
|
TODO @ everywhere
|
||||||
|
|
||||||
- {} infix
|
DONE {} particular => (#%braces)
|
||||||
|
|
||||||
- [] particular => (#%brackets )
|
TODO {} infix
|
||||||
|
|
||||||
- . in ids => x.y => (%#dot x y)
|
DONE [] particular => (#%brackets)
|
||||||
|
|
||||||
|
DONE default #%brackets is (let () ....)
|
||||||
|
|
||||||
|
DONE . in ids => x.y => (%#dot x y)
|
||||||
|
|
||||||
|
TODO #%dot is extensible transformer
|
||||||
|
|
||||||
(struct posn ((complex x) y))
|
(struct posn ((complex x) y))
|
||||||
|
|
||||||
|
@ -37,23 +43,28 @@ obj.(move 5 6)
|
||||||
(define (f (box x))
|
(define (f (box x))
|
||||||
stuff)
|
stuff)
|
||||||
|
|
||||||
- robby's request
|
TODO robby's request
|
||||||
|
|
||||||
(haskell-style
|
(haskell-style
|
||||||
(f '()) = 0
|
(f '()) = 0
|
||||||
(f (cons x l)) = {1+ (f l)})
|
(f (cons x l)) = {1+ (f l)})
|
||||||
|
|
||||||
|
TODO (define+ (f case) body)
|
||||||
|
|
||||||
|
TODO No set! (use data-structure mutation and :=)
|
||||||
- No set! (use data-structure mutation and :=)
|
|
||||||
|
|
||||||
(def (var x) 5)
|
(def (var x) 5)
|
||||||
{x := 6}
|
{x := 6}
|
||||||
|
|
||||||
- No effects or expressions at top-level (controversial, mf says wrong) [set-once!]
|
TODO No effects or expressions at top-level (controversial, mf says wrong) [set-once!]
|
||||||
- "Versioned" libraries
|
|
||||||
- Make macros less weird and more like programs, by...
|
TODO "Versioned" libraries
|
||||||
- Unified matching (syntax-parse/match/etc)
|
|
||||||
- Unified templates (syntax, quasiquote, etc)
|
TODO Make macros less weird and more like programs, by...
|
||||||
|
|
||||||
|
TODO Unified matching (syntax-parse/match/etc)
|
||||||
|
|
||||||
|
TODO Unified templates (syntax, quasiquote, etc)
|
||||||
|
|
||||||
If x is a list, then...
|
If x is a list, then...
|
||||||
|
|
||||||
|
@ -69,10 +80,13 @@ obj.(move 5 6)
|
||||||
=>
|
=>
|
||||||
(apply + (map f x))
|
(apply + (map f x))
|
||||||
|
|
||||||
- Pattern matching everywhere
|
TODO Pattern matching everywhere
|
||||||
- New structs (more reflective information, representation control, sealing)
|
|
||||||
- Implicit units and interfaces (with properties)
|
TODO New structs (more reflective information, representation control, sealing)
|
||||||
- Bare-bones /base
|
|
||||||
|
TODO Implicit units and interfaces (with properties)
|
||||||
|
|
||||||
|
DONE Bare-bones /base
|
||||||
|
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
(define BASE-NAMES (namespace-mapped-symbols (make-base-namespace)))
|
(define BASE-NAMES (namespace-mapped-symbols (make-base-namespace)))
|
||||||
|
@ -82,9 +96,10 @@ obj.(move 5 6)
|
||||||
|
|
||||||
returns 1433
|
returns 1433
|
||||||
|
|
||||||
- Generics everywhere
|
TODO Generics everywhere
|
||||||
https://github.com/stamourv/generic-collections
|
https://github.com/stamourv/generic-collections
|
||||||
- Non-() syntax "mode"
|
|
||||||
|
TODO Non-() syntax "mode"
|
||||||
|
|
||||||
array.[{1 + 1}].(foo)
|
array.[{1 + 1}].(foo)
|
||||||
->
|
->
|
||||||
|
@ -94,44 +109,56 @@ array.[{1 + 1}].(foo)
|
||||||
{x := z + 13}
|
{x := z + 13}
|
||||||
{p.x + p.y})
|
{p.x + p.y})
|
||||||
|
|
||||||
- Implicit nesting in blocks
|
DONE Implicit nesting in blocks
|
||||||
|
|
||||||
(def (f x)
|
(def (f x)
|
||||||
(def y 17)
|
(def y 17)
|
||||||
(+ x y))
|
(+ x y))
|
||||||
|
|
||||||
- Immutable strings only
|
TODO Immutable strings only
|
||||||
- Remove letrec weirdness of define?
|
|
||||||
|
TODO Remove letrec weirdness of define?
|
||||||
|
|
||||||
(def (f x)
|
(def (f x)
|
||||||
(def [even (λ (x) (odd x))]
|
(def [even (λ (x) (odd x))]
|
||||||
[odd (λ (x) (even x))])
|
[odd (λ (x) (even x))])
|
||||||
(even x))
|
(even x))
|
||||||
|
|
||||||
- "define"-transformers for attaching meta-information to definitions, like documentation, tests, contracts, types, etc
|
TODO "define"-transformers for attaching meta-information to definitions, like documentation, tests, contracts, types, etc
|
||||||
- Bindings & keywords everywhere
|
|
||||||
- Less representation contraints
|
TODO Bindings & keywords everywhere
|
||||||
- Meaningless eq? semantics
|
---- DONE cond
|
||||||
- Literate programming and inline docs easily
|
|
||||||
- No case-lambda
|
TODO Less representation contraints
|
||||||
- Optional traditional numbers (num/generic => +)
|
|
||||||
- Optional non-coercing number tower (num/{fl,fx,i32,i64,f32,f64,nat,int,rational,real})
|
TODO Meaningless eq? semantics
|
||||||
-- with maybe impl (num/*/maybe)
|
|
||||||
-- with overflow errors impl (num/*/exn)
|
TODO Literate programming and inline docs easily
|
||||||
-- with modulo-X impl (num/*/modulo)
|
|
||||||
-- with modulo-X & carry impl (num/*/carry)
|
DONE No case-lambda
|
||||||
- More unicode!
|
|
||||||
- Unboxed, raw data
|
TODO Optional traditional numbers (num/generic => +)
|
||||||
- Remove multiple values?
|
|
||||||
- Rocket-strength super cut:
|
TODO Optional non-coercing number tower (num/{fl,fx,i32,i64,f32,f64,nat,int,rational,real})
|
||||||
|
---- TODO with maybe impl (num/*/maybe)
|
||||||
|
---- TODO with overflow errors impl (num/*/exn)
|
||||||
|
---- TODO with modulo-X impl (num/*/modulo)
|
||||||
|
---- TODO with modulo-X & carry impl (num/*/carry)
|
||||||
|
|
||||||
|
TODO More unicode!
|
||||||
|
|
||||||
|
TODO Unboxed, raw data
|
||||||
|
|
||||||
|
TODO Remove multiple values?
|
||||||
|
|
||||||
|
TODO Rocket-strength super cut:
|
||||||
|
|
||||||
λ.(+ $0 $1)
|
λ.(+ $0 $1)
|
||||||
|
|
||||||
- Don't use English in exceptions and have more structured exns [demo on raco/pkg]
|
TODO Don't use English in exceptions and have more structured exns [demo on raco/pkg]
|
||||||
|
|
||||||
- (Define-default-type Number x y z)
|
TODO (Define-default-type Number x y z)
|
||||||
[for define things too]
|
[for define things too]
|
||||||
|
|
||||||
- zos don't appear to users (switch to interp if no write access)
|
TODO zos don't appear to users (switch to interp if no write access)
|
||||||
|
|
||||||
- (define+ (f case) body)
|
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
(provide #%module-begin)
|
(provide #%module-begin
|
||||||
|
require
|
||||||
|
provide)
|
||||||
|
|
|
@ -50,4 +50,6 @@
|
||||||
["(a b).c" (#%dot (a b) c)]
|
["(a b).c" (#%dot (a b) c)]
|
||||||
["(a b).(c d)" (#%dot (a b) (c d))]
|
["(a b).(c d)" (#%dot (a b) (c d))]
|
||||||
["(a b).[3]" (#%dot (a b) (#%brackets 3))]
|
["(a b).[3]" (#%dot (a b) (#%brackets 3))]
|
||||||
["({1})" ((#%braces 1))]))
|
["({1})" ((#%braces 1))]
|
||||||
|
["remix/stx.0" (#%dot remix/stx 0)]
|
||||||
|
["(require remix/stx.0)" (require (#%dot remix/stx 0))]))
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
(module reader syntax/module-reader
|
(module reader syntax/module-reader
|
||||||
remix/core
|
remix/core
|
||||||
#:read remix:read
|
#:read at:read
|
||||||
#:read-syntax remix:read-syntax
|
#:read-syntax at:read-syntax
|
||||||
(require (prefix-in remix: remix/stx/read)))
|
#:wrapper1
|
||||||
|
(λ (t)
|
||||||
|
(parameterize ([read-square-bracket-as-paren #f]
|
||||||
|
[read-curly-brace-as-paren #f]
|
||||||
|
[read-square-bracket-with-tag #t]
|
||||||
|
[read-curly-brace-with-tag #t]
|
||||||
|
[read-accept-dot #f]
|
||||||
|
[read-accept-infix-dot #f]
|
||||||
|
[read-cdot #t])
|
||||||
|
(t)))
|
||||||
|
(require (prefix-in at: scribble/reader)))
|
||||||
|
|
3
remix/num/gen0.rkt
Normal file
3
remix/num/gen0.rkt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#lang racket/base
|
||||||
|
;; xxx fill out
|
||||||
|
(provide + < /)
|
|
@ -1,10 +0,0 @@
|
||||||
#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]))
|
|
67
remix/stx0.rkt
Normal file
67
remix/stx0.rkt
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#lang racket/base
|
||||||
|
(require (for-syntax racket/base
|
||||||
|
syntax/parse))
|
||||||
|
|
||||||
|
(define-syntax (def stx)
|
||||||
|
(syntax-parse stx
|
||||||
|
[(_ x:id . body:expr)
|
||||||
|
(syntax/loc stx
|
||||||
|
(define x (remix-block . body)))]
|
||||||
|
[(_ (x:id . args:expr) . body:expr)
|
||||||
|
(syntax/loc stx
|
||||||
|
(def x (remix-λ args . body)))]))
|
||||||
|
|
||||||
|
(define-syntax (remix-block stx)
|
||||||
|
;; xxx gather up defs and turn into bind
|
||||||
|
(syntax-parse stx
|
||||||
|
[(_ . body:expr)
|
||||||
|
(syntax/loc stx
|
||||||
|
(let () . body))]))
|
||||||
|
|
||||||
|
;; xxx also make it a #%dot transformer that is cut.
|
||||||
|
(define-syntax (remix-λ stx)
|
||||||
|
(syntax-parse stx
|
||||||
|
;; xxx transform args into bind plus what racket λ needs
|
||||||
|
[(_ (arg:id ...) . body:expr)
|
||||||
|
(syntax/loc stx
|
||||||
|
(λ (arg ...) (remix-block . body)))]))
|
||||||
|
|
||||||
|
(define-syntax (#%brackets stx)
|
||||||
|
(syntax-parse stx
|
||||||
|
[(_ . body:expr)
|
||||||
|
(syntax/loc stx
|
||||||
|
(remix-block . body))]))
|
||||||
|
|
||||||
|
(define-syntax (#%braces stx)
|
||||||
|
(syntax-parse stx))
|
||||||
|
|
||||||
|
(define-syntax (#%dot stx)
|
||||||
|
(syntax-parse stx))
|
||||||
|
|
||||||
|
(define-syntax (remix-cond stx)
|
||||||
|
(syntax-parse stx
|
||||||
|
#:literals (#%brackets)
|
||||||
|
[(_ (~and before:expr (~not (#%brackets . any:expr))) ...
|
||||||
|
(#%brackets #:else . answer-body:expr))
|
||||||
|
(syntax/loc stx
|
||||||
|
(remix-block before ... . answer-body))]
|
||||||
|
[(_ (~and before:expr (~not (#%brackets . any:expr))) ...
|
||||||
|
(#%brackets question:expr . answer-body:expr)
|
||||||
|
. more:expr)
|
||||||
|
(syntax/loc stx
|
||||||
|
(remix-block before ...
|
||||||
|
(if question
|
||||||
|
(remix-block . answer-body)
|
||||||
|
(remix-cond . more))))]))
|
||||||
|
|
||||||
|
(provide def
|
||||||
|
(rename-out [remix-λ λ]
|
||||||
|
[remix-cond cond])
|
||||||
|
#%brackets
|
||||||
|
#%braces
|
||||||
|
#%dot
|
||||||
|
#%app
|
||||||
|
#%datum
|
||||||
|
module
|
||||||
|
module*
|
||||||
|
module+)
|
25
remix/tests/simple.rkt
Normal file
25
remix/tests/simple.rkt
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#lang remix
|
||||||
|
(require remix/stx0
|
||||||
|
remix/num/gen0)
|
||||||
|
|
||||||
|
(def x
|
||||||
|
(def a 40)
|
||||||
|
(def b 2)
|
||||||
|
(+ a b))
|
||||||
|
|
||||||
|
(def (f x y)
|
||||||
|
(+ [(def z (+ x x)) z] y))
|
||||||
|
|
||||||
|
(def (g x)
|
||||||
|
(cond
|
||||||
|
[(< x 100) "100"]
|
||||||
|
(def z (/ x 2))
|
||||||
|
[(< z 100) "div 100"]
|
||||||
|
[#:else "other"]))
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
x
|
||||||
|
(f x x)
|
||||||
|
(g 50)
|
||||||
|
(g 199)
|
||||||
|
(g 200))
|
Loading…
Reference in New Issue
Block a user