soegaard2
2019-9-2 11:58:37

Yea or nay? (<= 0 x .and. < x0 .and. <= x1) as short for (and (<= 0 x) (and (< x x0) (<= x0 x1))


soegaard2
2019-9-2 11:59:25

And (<= 0 x .and. < x0 .or. <= x1) as short for (and (<= 0 x) (or (< x x0) (<= x0 x1))


spdegabrielle
2019-9-2 12:16:59

What if the .and. was implied/invisible? The .and. is implied if I use a /high school math/-ish notation:

0 <= x < x0 <= x1

But this doesn’t work with .or. :sob: :

0 <= x ((x < x0) .or. (x0 <= x1))

I just end up with lots of brackets.

I don’t know. Your proposal is very interesting. I wish I could test on students.


alexharsanyi
2019-9-2 12:30:14

@soegaard2 if you asked me what (<= 0 x .and. < x0 .and. <= x1) means without giving me any context, I would have assumed that it means (and (<= 0 x) (< 0 x0) (< 0 x1))


soegaard2
2019-9-2 13:46:03

@alexharsanyi Copy. I want syntax that makes 0<=x<=x0<=x1 easy to enter.


soegaard2
2019-9-2 13:46:28

Here is an implementation if anyone wants to try it out:


soegaard2
2019-9-2 13:46:47
#lang racket/base

(require
 (for-syntax racket/base syntax/parse racket/syntax racket/format racket/match
             (for-syntax racket/base)))

; (&lt;= 0 x .and. &lt; x0)  =&gt; (let ([t x]) (and (&lt;= 0 x) (&lt; x x0)))

(begin-for-syntax
  (define-syntax def (make-rename-transformer #'define)))

(define-syntax (ddapp stx)
  (define (id-&gt;string id)
    (symbol-&gt;string (syntax-e id)))
  (def len string-length)
  (def ref string-ref)
  (define (double-dot-id? id)
    (and (identifier? id)
         (let ([s (id-&gt;string id)])
           (def n (len s))
           (and (&gt;= n 2)
                (eqv? (ref s 0)      #\.)
                (eqv? (ref s (- n 1)) #\.)))))
  (def dd?  double-dot-id?)
  (define (not-dd? x) (not (dd? x)))
  (define (strip-dots id)
    (def s (id-&gt;string id))
    (def n (len s))
    (format-id id "~a" (substring s 1 (- n 1))))

  (syntax-parse stx
    [(app)        (syntax/loc stx (#%app))]
    [(app f1 . args)
     (def out
       (let loop ([f1 #'f1] [args (syntax-&gt;list #'args)])
         (match args
           [(list* (? not-dd? xs) ... x (? dd? .f.) f2 ys)
            (def f (strip-dots .f.))
            (def t (gensym "t"))
            (list #'let (list (list t x)) ; only evaluate x once
                  (list f
                        (list* f1 (append xs (list t)))
                        (loop  f2 (append (list t) ys))))]
           [(list* xs)
            (list* f1 xs)])))
     (datum-&gt;syntax stx out stx)]))

(ddapp + 1 2)                       ; 3
(ddapp * 2 3 .list. + 4 )           ; (6 7)
(ddapp &lt;= 0 2 .and. &lt; 3)            ; #t
(ddapp &lt;= 0 2 .and. &lt; 4)            ; #t
(ddapp &lt;= 0 1 .and. &lt; 2 .and. &lt; 3)  ; #t
(ddapp list 1 .list. list 2)       ; ((1) (1 2))

sorawee
2019-9-2 14:45:52

> I want syntax that makes 0<=x<=x0<=x1 easy to enter

So (&lt;= 0 x x0 x1)?


soegaard2
2019-9-2 14:46:19

some of them could be <


sorawee
2019-9-2 14:47:13

What about (cmp 0 &lt;= x &lt; x0 &lt;= x1)?


soegaard2
2019-9-2 14:47:58

That looks fine.


laurent.orseau
2019-9-2 14:48:04

@sorawee: that’s twice you dump my thoughts faster than I do. Mind if I borrow you for a month? :stuck_out_tongue:


soegaard2
2019-9-2 14:51:20

I suddenly realize that <=/< </< and friends are in srfi 67.


sorawee
2019-9-2 17:23:31

c(a\|d)*r is not cool anymore. We need ((&lt;\|&lt;=)/)*(&lt;\|&lt;=)!


ben
2019-9-2 17:40:36

@samth is it correct to say TR satisfies the gradual guarantees for simply-typed programs? (I want to say why TR is gradual, and be more specific than “TR strives toward the SNAPL’15 criteria”)


samth
2019-9-2 17:44:47

TR satisfies the dynamic gradual guarantee, but not the static one — removing types in one module means you need to add them in another module in some cases


ben
2019-9-2 17:47:19

that’s dynamic for simple types, right? (excluding \forall, and I’m not sure what else)


soegaard2
2019-9-2 18:26:16

@sorawee At least ≤≤ ≤< <≤ and <<.



krismicinski
2019-9-2 21:51:12

Hm.. I know a very huge (much, much larger than Racket) programming community that does “shut up and hack” and also does not use mutability… :confused:


krismicinski
2019-9-2 21:52:13

I really like Racket’s mutability by default. But I don’t think it is at all an implication that you don’t write real code if you don’t like mutability.


pocmatos
2019-9-3 06:22:14

@soegaard2 Thanks for posting


pocmatos
2019-9-3 06:23:45

I hope not too many people have read it, yet. :slightly_smiling_face: I just fixed 2 serious problems: Contributors list was incomplete and the link to the paper was not working.


pocmatos
2019-9-3 06:25:50

Funny fact, yesterday was quite late so I forgot to run the basic test to the contributors script output: is Matthew Flatt in the list of contributors. It was not so this morning I opened an email to read: “Missed Matthew Flatt from contributors.”. Doh! Of course, a few people besides Matthew were missing. Sorry for that, now fixed.