samth
2019-9-20 13:11:52

@krismicinski I believe that it uses a bunch of pretty advanced PL ideas


lexi.lambda
2019-9-20 14:29:50

Two of its authors were at at least the past two ICFPs fwiw


keenencates
2019-9-20 17:16:25

I have a noob question — I am trying to recursively expand some syntax such that it generates a sequence of s-exps not enclosed in an expression itself i.e.

what I want to do is

(define -syntax (mylang/my-top-level-syntax stx)
...
#' (quasiquote ( (mylang/my-syntax (first ...) ...))]))
...

(define-syntax (mylang/my-syntax stx)
...
  [(_ (first ...) (rest ...) ...)
    #`(mylang/my-syntax (first ...))(mylang/my-syntax (rest ...) ...)]))

eventually I want to generate something like this

`( (first-thing) (second-thing) (third-thing))

What I ended up doing is pushing the parenthesis down into the recursive part, but I don’t think I quite set up an append / list structure correct. Really I think what I want to do is output two pieces of sequential syntax?


sorawee
2019-9-20 18:07:07

Sorry, I’m a little bit lost. Can you show a concrete example you had in your mind? E.g.,

I want:

(or a b)

to expand to:

(if a #t b)

keenencates
2019-9-20 18:15:51

Yes, one moment


keenencates
2019-9-20 18:19:40
(start-graph
 (CashRegister ((- currentCashier String)
                (- availableCoupons Coupon\[0...*\])
                (- till float))
               ((+ startup void)
                (+ useCoupon\(Coupon\) boolean)
                (+ payTotal float)))
 (Coupon ((- barcode integer)
          (- productName String)
          (- value float))
         ())
  (Test ()
        ()))
  (make-digraph
   `(("CashRegister" #:label "{CashRegister\|\\l-\\ currentCashier:\\ String\\l\\l-\\ availableCoupons:\\ Coupon[0...*]\\l\\l-\\ till:\\ float\\l\\l\|\\l+\\ startup():\\ void\\l\\l+ useCoupon(Coupon):\\ boolean\\l\\l+\\ payTotal(float):\\ float\\l\\l}"
               #:shape "record"
               #:style "filled"
               #:fillcolor "white"
               #:width "4")
     ("Coupon" #:label "{Coupon\|\\l-\\ barcode:\\ integer\\l\\l-\\ productName:\\ String\\l\\l-\\ value:\\ float\\l\\l\|\\l\\l}"
               #:shape "record"
               #:style "filled"
               #:fillcolor "white"
               #:width "4")
     ("Test" #:label "{Test\|\\l\\l\|\\l\\l}"
               #:shape "record"
               #:style "filled"
               #:fillcolor "white"
               #:width "4")) #:ortho #t))

keenencates
2019-9-20 18:31:46
(define-syntax (uml/#%app stx)
  (syntax-parse stx
    [(_ start-graph (term ...) ...)
     #`(digraph->pict
        (make-digraph
         (uml/build-graph (term ...) ...)))]))

(define-syntax (uml/build-graph stx)
  (syntax-parse stx
    [(_ (class_name ...) ...)
     #`(quasiquote (,(uml/build-class (class_name ...) ...)))]
    [(_ (class_name ...) ... ((~datum ->) (edge ...) ...))
     #'(quasiquote ((uml/build-class (class_name ...) ...) (uml/build-edge (edge ...) ...)))]))

(define-syntax (uml/build-class stx)
  (syntax-parse stx
    [(_ (class_name ( (priv_attr ...) ... ) ( (pub_attr ...) ...)))
     #``(class_name #:label ,(format "{~a\|\\n~a\\l\\l\|\\n~a\\l\\l}" class_name (uml/build-attr (priv_attr ...) ...) (uml/build-attr (pub_attr ...) ...))
                     #:shape "record"
                     #:style "filled"
                     #:fillcolor "white"
                     #:width "4")]
    [(_ (first ...) (rest ...) ...)
     #``,(string->symbol (string-append (~a (uml/build-class (first ...)))(~a (uml/build-class (rest ...) ...))))]))

(define-syntax (uml/build-attr stx)
  (syntax-parse stx
    [(_)
     #'""]
    [(_ (mark name type))
     #'(format "~a ~a: ~a" mark name type)]
    [(_ (mark name type) (next ...) ...)
     #'(format "~a ~a: ~a\\l\\l~a" mark name type (uml/build-attr (next ...) ...))]))

sorawee
2019-9-20 18:47:18

Do you really need the expansion to happen at compile-time? One very simple way is to quote the entire thing, and then perform the transformation at runtime, which should be easier


sorawee
2019-9-20 18:47:20

E.g.:


sorawee
2019-9-20 18:47:51
(define-syntax-rule (start-graph whatever ...)
  (do-make-graph (quote whatever) ...))

(define (do-make-graph . xs)
  ;; transform xs as you desire and call make-graph on it
  (println xs))

keenencates
2019-9-20 18:48:30

It’s possible, I’ll try that


sorawee
2019-9-20 18:48:54
(start-graph
 (CashRegister ((- currentCashier String)
                (- availableCoupons Coupon\[0...*\])
                (- till float))
               ((+ startup void)
                (+ useCoupon\(Coupon\) boolean)
                (+ payTotal float)))
 (Coupon ((- barcode integer)
          (- productName String)
          (- value float))
         ())
 (Test ()
       ()))

This outputs:

'((CashRegister ((- currentCashier String) (- availableCoupons \|Coupon[0...*]\|) (- till float)) ((+ startup void) (+ \|useCoupon(Coupon)\| boolean) (+ payTotal float))) (Coupon ((- barcode integer) (- productName String) (- value float)) ()) (Test () ()))

which is just a tree of symbols, and you can do whatever you want with it


btauro
2019-9-20 21:15:02

a question to the racket community what do you think about the idea of one sided messaging in racket such as rdma is there any advantage or not?


keenencates
2019-9-20 22:10:11

I think I am somehow overthinking this one, gonna come back to it. Was writing a UML lang for my SDP class to make the our UML assignment more interesting but running out of time


keenencates
2019-9-20 22:11:43

The racket-graphviz library is pretty sweet though but needs more documentation — although most of it can be inferred from the graphviz documentation. The only thing I couldn’t figure out was how to use the html tag system.


krismicinski
2019-9-20 22:28:23

Oh geez, this is so sad, this is what the class should be teaching you rather than UML…


keenencates
2019-9-20 22:55:17

Well, it’s the assignment for one week, and there’s a group project that follows so ehh…. I guess it’s ok but it’s really really boring


keenencates
2019-9-20 22:57:00

I mistakenly took advanced operating systems and compiler theory and practice last semester (at the same time) — I tried to take SDP to balance the difficult better, but yeah it is a little sad lol