From 16c782e319d785cd5976970b4045198e7ca6a68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Tue, 8 Dec 2015 14:42:12 +0100 Subject: [PATCH] Changed define-graph so that it defines the constructor, instead of directly accepting the constructor's arguments. --- graph/graph/__DEBUG_graph__.rkt | 2 +- graph/graph/graph3.lp2.rkt | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/graph/graph/__DEBUG_graph__.rkt b/graph/graph/__DEBUG_graph__.rkt index fb08c0e2..bc275db8 100644 --- a/graph/graph/__DEBUG_graph__.rkt +++ b/graph/graph/__DEBUG_graph__.rkt @@ -22,9 +22,9 @@ #R(force (car (second g))) #R(force (cadr (force (car (caddr (force (car (second g)))))))) -;|# (newline) +;|# (define (forceall [fuel : Integer] [x : Any]) : Any (if (> fuel 0) diff --git a/graph/graph/graph3.lp2.rkt b/graph/graph/graph3.lp2.rkt index f9ad9b8e..9e42d7b6 100644 --- a/graph/graph/graph3.lp2.rkt +++ b/graph/graph/graph3.lp2.rkt @@ -111,7 +111,8 @@ that it first takes the node types and mappings, and produces a lambda taking the root arguments as parameters. @chunk[ - (define-graph g () )] + (define-graph make-g ) + (define g (make-g ))] @subsection{More details on the semantics} @@ -153,9 +154,9 @@ We use a simple syntax for @tc[define-graph], and make it more flexible through wrapper macros. @chunk[ - (define-graph name ([node ] - …) - root-expr:expr …)] + (define-graph name + [node ] + …)] Where @tc[] is: @@ -199,6 +200,9 @@ We derive identifiers for these based on the @tc[node] name: @;;;; @chunk[ + (define/with-syntax ((root-param …) . _) #'((param …) …)) + (define/with-syntax ((root-param-type …) . _) #'((param-type …) …)) + (define-temp-ids "~a/make-placeholder" (node …) #:first-base root) (define-temp-ids "~a/placeholder-type" (node …)) (define-temp-ids "~a/placeholder-tag" (node …)) @@ -306,7 +310,7 @@ two values: the result of processing the element, and the latest version of We start creating the root placeholder which we provide to @tc[fold-queues]. @chunk[ - (root/make-placeholder root-expr …)] + (root/make-placeholder root-param …)] To make the placeholder, we will need a @tc[node/make-placeholder] function for each @tc[node]. We first define the type of each placeholder (a list of @@ -587,15 +591,10 @@ are replaced by tagged indices: (begin ) … (begin ) … (begin ) … - (define name : root/with-promises-type + + (: name (→ root-param-type … root/with-promises-type)) + (define (name root-param …) (match-let ([(list node/database …) ]) - #|(let*-values ([(rs) ] - [(node/database rs) - (values (ann (car rs) - (Vectorof node/with-indices-type)) - (cdr rs))] - … - [(_) (ann rs Null)])|# (begin ) … ;(list node/with-indices→with-promises …) (root/with-indices→with-promises