misc notes

This commit is contained in:
Jay McCarthy 2015-11-30 14:06:54 -05:00
parent 10f096b923
commit 550f2749a1
2 changed files with 22 additions and 10 deletions

View File

@ -172,7 +172,7 @@
static-interface-members))
(begin-for-syntax
;; XXX fill this in
;; XXX fill this in for parents, etc
(define-generics layout))
(define-syntax phase0:layout
@ -186,6 +186,7 @@
#:literals (remix:#%brackets)
[(def (remix:#%brackets me:id name:id)
f:id ...)
;; xxx check for duplicates in f
(with-syntax* ([name-alloc (format-id #f "~a-alloc" #'name)]
[name-set (format-id #f "~a-set" #'name)]
[(f-idx ...)
@ -199,6 +200,7 @@
(begin
(begin-for-syntax
(define f->idx*acc
;; xxx base on parent's
(make-immutable-hasheq
(list (cons 'f (cons f-idx #'name-f))
...)))
@ -235,9 +237,11 @@
(λ ()
(raise-syntax-error
'name-alloc
"missing initializer for ~a"
this-f))))])
(format "missing initializer for ~a"
this-f)
stx))))])
(syntax/loc stx
;; xxx push this in representation planner
(vector-immutable f-val (... ...))))]))
(define-syntax (name-set stx)
(syntax-parse stx
@ -253,8 +257,10 @@
(#,this-name-f base-id)))))])
(syntax/loc stx
(let ([base-id base])
;; xxx push this in representation planner
(vector-immutable f-val (... ...)))))]))
(begin-encourage-inline
;; xxx push this in representation planner
(define (name-f v) (unsafe-vector*-ref v f-idx))
...)
(define-syntax name
@ -262,6 +268,7 @@
(remix:#%brackets #:alloc name-alloc)
(remix:#%brackets #:set name-set)
(remix:#%brackets #:= name-set)
;; xxx add set! if planner says so
(remix:#%brackets f name-f)
...
#:extensions

View File

@ -333,19 +333,22 @@
{p1.y 7}
;; You will also get a copying function (XXX: Should it be named
;; `copy`? `update`? My analogy here is with hash-set)
(def [posn p2] (p1.#:set [x 8] [y {p1.y + 2}]))
(def [posn p2] (p1.#:set [y {p1.y + 2}]))
;; Notice that these built-in functions are keywords, so that they
;; can't conflict with the fields you've defined.
{p2.x 8}
{p2.x 5}
{p2.y 9}
;; This is aliased to =, which I expect is nicer to use.
(def [posn p3] (p1.#:= [x 8] [y {p1.y + 2}]))
(def [posn p3] (p1.#:= [x 8]))
{p3.x 8}
{p3.y 9})
{p3.y 7})
;; XXX This is where I am
;; A layout can have a parent, which provides the guarantee that the
;; parent's functions will work on the child. A layout has one or zero
;; parents.
;; parent's functions will work on the child---meaning that whatever
;; the layout ends up being (and you can't decide that), the two will
;; overlap in this specific way. A layout has one or zero parents.
#;
(def [layout quat]
#:parent posn
@ -353,7 +356,9 @@
;; A layout's fields may be specified as other layouts. When the first
;; field is a layout, this is not necessarily the same thing as a
;; parent (like C structs) but it may be.
;; parent (like C structs) but it may be. (No matter what, you'd never
;; be able to tell, since layout doesn't make representation promises
;; as a rule.)
#;
(def [layout circle]
[posn cx] r)