[racket-dev] Implementation question

2014-04-19 Thread nicolas carraggi
Hello,
I am actually using Racket/tcp for a project in Racket.I'm creating a 
peer-to-peer network but now I encountered a small problem.For a multicast I 
want to connect with each server on the same network. For this I use 
tcp-connect, but when i try to connect to an ip address which is not hosting 
a server, throwing the error only happens after more than 1 minute. So I would 
like to use a modified tcp-connect with a smaller time-out.
Where can I find the implementation of tcp-connect?
I already found tcp.rkt but there it gets the tcp-connect method from 
'#%network but I can't find this one...
Greetings!Nicolas _
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Implementation question

2014-04-19 Thread Laurent
One simpler possibility is to use `tcp-connect/enable-break` and run a
timer in parallel to break it after a shorter delay.
For example:

(define-values (in out) (values #f #f))

(define connect-thread
  (thread
   (λ()(set!-values (in out)
(tcp-connect www.google.com 80)

(sleep 3)
(unless in
  (displayln Connection not established. Breaking thread.)
  (break-thread connect-thread))

The timer can also be place into its own thread if you need to set up
several connections in parallel.

Hope this helps,
Laurent


On Thu, Apr 17, 2014 at 6:48 PM, nicolas carraggi
nicocarra...@hotmail.comwrote:

 Hello,

 I am actually using Racket/tcp for a project in Racket.
 I'm creating a peer-to-peer network but now I encountered a small problem.
 For a multicast I want to connect with each server on the same network.
 For this I use tcp-connect, but when i try to connect to an ip address
 which is not hosting a server, throwing the error only happens after more
 than 1 minute. So I would like to use a modified tcp-connect with a
 smaller time-out.

 Where can I find the implementation of tcp-connect?

 I already found tcp.rkt but there it gets the tcp-connect method from
 '#%network but I can't find this one...

 Greetings!
 Nicolas

 _
   Racket Developers list:
   http://lists.racket-lang.org/dev


_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Pre-Release Checklist for v6.0.1

2014-04-19 Thread Michael Sperber

Ryan Culpepper ry...@ccs.neu.edu writes:

 * Mike Sperber sper...@deinprogramm.de
   - DMdA Tests
   - Stepper Tests
   - Signature Tests

Done.

-- 
Regards,
Mike
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Implementation question

2014-04-19 Thread Matthias Felleisen

Let me recommend events instead: 

#lang racket

;; Nat - Void 
;; wait for t seconds before connecting to google.com, then stop
(define (do-work t)
  (thread
   (lambda ()
 (with-handlers ((exn:fail:network? (lambda (x) (displayln (exn-message 
x)
   (sleep t)
   (define-values (in out) (tcp-connect google.com 80)) 
   'done

;; returns #f if 3 seconds pass w/o the thread shutting down 
(sync/timeout 3 (do-work (random 6)))



On Apr 19, 2014, at 8:34 AM, Laurent wrote:

 One simpler possibility is to use `tcp-connect/enable-break` and run a timer 
 in parallel to break it after a shorter delay.
 For example:
 
 (define-values (in out) (values #f #f))
 
 (define connect-thread
   (thread
(λ()(set!-values (in out) 
 (tcp-connect www.google.com 80)
 
 (sleep 3)
 (unless in
   (displayln Connection not established. Breaking thread.)
   (break-thread connect-thread))
 
 The timer can also be place into its own thread if you need to set up several 
 connections in parallel.
 
 Hope this helps,
 Laurent
 
 
 On Thu, Apr 17, 2014 at 6:48 PM, nicolas carraggi nicocarra...@hotmail.com 
 wrote:
 Hello,
 
 I am actually using Racket/tcp for a project in Racket.
 I'm creating a peer-to-peer network but now I encountered a small problem.
 For a multicast I want to connect with each server on the same network. 
 For this I use tcp-connect, but when i try to connect to an ip address 
 which is not hosting a server, throwing the error only happens after more 
 than 1 minute. So I would like to use a modified tcp-connect with a smaller 
 time-out.
 
 Where can I find the implementation of tcp-connect?
 
 I already found tcp.rkt but there it gets the tcp-connect method from 
 '#%network but I can't find this one...
 
 Greetings!
 Nicolas
 
 _
   Racket Developers list:
   http://lists.racket-lang.org/dev
 
 
 _
  Racket Developers list:
  http://lists.racket-lang.org/dev

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Catching the undefined value

2014-04-19 Thread Gustavo Massaccesi
I found another problem with the optimizer and the new undefined behavior.

(letrec ([x (if #t 8 x)]) x) ;==8

I also consider this correct in a strange sense :).

Gustavo


Welcome to Racket v6.0.1.4.
 (letrec ([x x]) x)
x: undefined;
 cannot use before initialization
  context...:
   C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
 (letrec ([x 5]) x)
5
 (letrec ([x (if #t 8 x)]) x)
8
 (letrec ([x (if #f 8 x)]) x)
x: undefined;
 cannot use before initialization
  context...:
   C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7



On Wed, Apr 16, 2014 at 10:09 AM, Matthias Felleisen
matth...@ccs.neu.edu wrote:

 Ah, too bad:

 pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 ~~~
 --- OLD/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 +++ NEW/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 @@ -3416,5 +3416,16 @@
   (read (open-input-bytes (get-output-bytes o))

 ;; 
 +;; Check that an unsufe opertion's argument is
 +;; not optimized away if it's a use of
 +;; a variable before definition:
 +
 +(err/rt-test (let ()
 +   (unsafe-fx+ x 1)
 +   (define x 3)
 +   x)
 + exn:fail:contract:variable?)
 +
 +;; 


 :-)

 On Apr 16, 2014, at 9:02 AM, Matthias Felleisen matth...@ccs.neu.edu wrote:


 On Apr 15, 2014, at 9:29 PM, Asumu Takikawa as...@ccs.neu.edu wrote:

 On 2014-04-15 18:13:31 -0400, claire alvis wrote:
 The push below includes changes to letrec expressions, internal
 definitions, units, classes, and certain ill-formed shared expressions so
 that they no longer leak the `undefined' value.

 This is great! (especially happy that TR, even with classes, doesn't
 have to worry about #undefined anymore)

 BTW, I found this weird behavior:

 Welcome to Racket v6.0.1.3.
 - (require racket/unsafe/ops)
 - (let () (+ x 3) (define x 3) 5)
 ; x: variable used before its definition [,bt for context]
 - (let () (unsafe-fx+ x 3) (define x 3) 5)
 5


 I consider this correct in a strange sense.

 Interestingly enough,

 (let () (displayln  (unsafe-fx+ x 3)) (define x 3) 5)
 x: variable used before its definition
  context...:
   /Users/matthias/plt/racket/collects/racket/private/misc.rkt:87:7

 which is good too. I don't know how Claire and Matthew did this,
 but it's good :-)
 _
  Racket Developers list:
  http://lists.racket-lang.org/dev

 _
   Racket Developers list:
   http://lists.racket-lang.org/dev
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Catching the undefined value

2014-04-19 Thread Robby Findler
These seem correct to me. What were you expecting (and why?).

Robby

On Saturday, April 19, 2014, Gustavo Massaccesi gust...@oma.org.ar wrote:

 I found another problem with the optimizer and the new undefined behavior.

 (letrec ([x (if #t 8 x)]) x) ;==8

 I also consider this correct in a strange sense :).

 Gustavo


 Welcome to Racket v6.0.1.4.
  (letrec ([x x]) x)
 x: undefined;
  cannot use before initialization
   context...:
C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
  (letrec ([x 5]) x)
 5
  (letrec ([x (if #t 8 x)]) x)
 8
  (letrec ([x (if #f 8 x)]) x)
 x: undefined;
  cannot use before initialization
   context...:
C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
 


 On Wed, Apr 16, 2014 at 10:09 AM, Matthias Felleisen
 matth...@ccs.neu.edu javascript:; wrote:
 
  Ah, too bad:
 
  pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  ~~~
  --- OLD/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  +++ NEW/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  @@ -3416,5 +3416,16 @@
(read (open-input-bytes (get-output-bytes o))
 
  ;; 
  +;; Check that an unsufe opertion's argument is
  +;; not optimized away if it's a use of
  +;; a variable before definition:
  +
  +(err/rt-test (let ()
  +   (unsafe-fx+ x 1)
  +   (define x 3)
  +   x)
  + exn:fail:contract:variable?)
  +
  +;; 
 
 
  :-)
 
  On Apr 16, 2014, at 9:02 AM, Matthias Felleisen 
  matth...@ccs.neu.edujavascript:;
 wrote:
 
 
  On Apr 15, 2014, at 9:29 PM, Asumu Takikawa 
  as...@ccs.neu.edujavascript:;
 wrote:
 
  On 2014-04-15 18:13:31 -0400, claire alvis wrote:
  The push below includes changes to letrec expressions, internal
  definitions, units, classes, and certain ill-formed shared
 expressions so
  that they no longer leak the `undefined' value.
 
  This is great! (especially happy that TR, even with classes, doesn't
  have to worry about #undefined anymore)
 
  BTW, I found this weird behavior:
 
  Welcome to Racket v6.0.1.3.
  - (require racket/unsafe/ops)
  - (let () (+ x 3) (define x 3) 5)
  ; x: variable used before its definition [,bt for context]
  - (let () (unsafe-fx+ x 3) (define x 3) 5)
  5
 
 
  I consider this correct in a strange sense.
 
  Interestingly enough,
 
  (let () (displayln  (unsafe-fx+ x 3)) (define x 3) 5)
  x: variable used before its definition
   context...:
/Users/matthias/plt/racket/collects/racket/private/misc.rkt:87:7
 
  which is good too. I don't know how Claire and Matthew did this,
  but it's good :-)
  _
   Racket Developers list:
   http://lists.racket-lang.org/dev
 
  _
Racket Developers list:
http://lists.racket-lang.org/dev
 _
   Racket Developers list:
   http://lists.racket-lang.org/dev

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Catching the undefined value

2014-04-19 Thread Gustavo Massaccesi
 (letrec ([x (if #t 8 x)]) x) ;==8

It was a mistake. I thought that the “x: undefined; ...” error was an
expansion-time error, not a run-time error.

(I expected an error, because the x in the else part is “undefined”,
even if it’s never accessed.)

Gustavo


On Sat, Apr 19, 2014 at 1:02 PM, Robby Findler
ro...@eecs.northwestern.edu wrote:
 These seem correct to me. What were you expecting (and why?).

 Robby


 On Saturday, April 19, 2014, Gustavo Massaccesi gust...@oma.org.ar wrote:

 I found another problem with the optimizer and the new undefined behavior.

 (letrec ([x (if #t 8 x)]) x) ;==8

 I also consider this correct in a strange sense :).

 Gustavo


 Welcome to Racket v6.0.1.4.
  (letrec ([x x]) x)
 x: undefined;
  cannot use before initialization
   context...:
C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
  (letrec ([x 5]) x)
 5
  (letrec ([x (if #t 8 x)]) x)
 8
  (letrec ([x (if #f 8 x)]) x)
 x: undefined;
  cannot use before initialization
   context...:
C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
 


 On Wed, Apr 16, 2014 at 10:09 AM, Matthias Felleisen
 matth...@ccs.neu.edu wrote:
 
  Ah, too bad:
 
  pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  ~~~
  --- OLD/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  +++ NEW/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  @@ -3416,5 +3416,16 @@
(read (open-input-bytes (get-output-bytes o))
 
  ;; 
  +;; Check that an unsufe opertion's argument is
  +;; not optimized away if it's a use of
  +;; a variable before definition:
  +
  +(err/rt-test (let ()
  +   (unsafe-fx+ x 1)
  +   (define x 3)
  +   x)
  + exn:fail:contract:variable?)
  +
  +;; 
 
 
  :-)
 
  On Apr 16, 2014, at 9:02 AM, Matthias Felleisen matth...@ccs.neu.edu
  wrote:
 
 
  On Apr 15, 2014, at 9:29 PM, Asumu Takikawa as...@ccs.neu.edu wrote:
 
  On 2014-04-15 18:13:31 -0400, claire alvis wrote:
  The push below includes changes to letrec expressions, internal
  definitions, units, classes, and certain ill-formed shared
  expressions so
  that they no longer leak the `undefined' value.
 
  This is great! (especially happy that TR, even with classes, doesn't
  have to worry about #undefined anymore)
 
  BTW, I found this weird behavior:
 
  Welcome to Racket v6.0.1.3.
  - (require racket/unsafe/ops)
  - (let () (+ x 3) (define x 3) 5)
  ; x: variable used before its definition [,bt for context]
  - (let () (unsafe-fx+ x 3) (define x 3) 5)
  5
 
 
  I consider this correct in a strange sense.
 
  Interestingly enough,
 
  (let () (displayln  (unsafe-fx+ x 3)) (define x 3) 5)
  x: variable used before its definition
   context...:
/Users/matthias/plt/racket/collects/racket/private/misc.rkt:87:7
 
  which is good too. I don't know how Claire and Matthew did this,
  but it's good :-)
  _
   Racket Developers list:
   http://lists.racket-lang.org/dev
 
  _
Racket Developers list:
http://lists.racket-lang.org/dev
 _
   Racket Developers list:
   http://lists.racket-lang.org/dev

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Catching the undefined value

2014-04-19 Thread Robby Findler
Ah. There are other approaches to this problem that result in
compile-time errors for such programs. Maybe the TR guys will adopt
one or figure out a better one! But for regular ole Racket, we're
stuck with a runtime error, I'm afraid.

Robby

On Sat, Apr 19, 2014 at 2:04 PM, Gustavo Massaccesi gust...@oma.org.ar wrote:
 (letrec ([x (if #t 8 x)]) x) ;==8

 It was a mistake. I thought that the “x: undefined; ...” error was an
 expansion-time error, not a run-time error.

 (I expected an error, because the x in the else part is “undefined”,
 even if it’s never accessed.)

 Gustavo


 On Sat, Apr 19, 2014 at 1:02 PM, Robby Findler
 ro...@eecs.northwestern.edu wrote:
 These seem correct to me. What were you expecting (and why?).

 Robby


 On Saturday, April 19, 2014, Gustavo Massaccesi gust...@oma.org.ar wrote:

 I found another problem with the optimizer and the new undefined behavior.

 (letrec ([x (if #t 8 x)]) x) ;==8

 I also consider this correct in a strange sense :).

 Gustavo


 Welcome to Racket v6.0.1.4.
  (letrec ([x x]) x)
 x: undefined;
  cannot use before initialization
   context...:
C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
  (letrec ([x 5]) x)
 5
  (letrec ([x (if #t 8 x)]) x)
 8
  (letrec ([x (if #f 8 x)]) x)
 x: undefined;
  cannot use before initialization
   context...:
C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
 


 On Wed, Apr 16, 2014 at 10:09 AM, Matthias Felleisen
 matth...@ccs.neu.edu wrote:
 
  Ah, too bad:
 
  pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  ~~~
  --- OLD/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  +++ NEW/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
  @@ -3416,5 +3416,16 @@
(read (open-input-bytes (get-output-bytes o))
 
  ;; 
  +;; Check that an unsufe opertion's argument is
  +;; not optimized away if it's a use of
  +;; a variable before definition:
  +
  +(err/rt-test (let ()
  +   (unsafe-fx+ x 1)
  +   (define x 3)
  +   x)
  + exn:fail:contract:variable?)
  +
  +;; 
 
 
  :-)
 
  On Apr 16, 2014, at 9:02 AM, Matthias Felleisen matth...@ccs.neu.edu
  wrote:
 
 
  On Apr 15, 2014, at 9:29 PM, Asumu Takikawa as...@ccs.neu.edu wrote:
 
  On 2014-04-15 18:13:31 -0400, claire alvis wrote:
  The push below includes changes to letrec expressions, internal
  definitions, units, classes, and certain ill-formed shared
  expressions so
  that they no longer leak the `undefined' value.
 
  This is great! (especially happy that TR, even with classes, doesn't
  have to worry about #undefined anymore)
 
  BTW, I found this weird behavior:
 
  Welcome to Racket v6.0.1.3.
  - (require racket/unsafe/ops)
  - (let () (+ x 3) (define x 3) 5)
  ; x: variable used before its definition [,bt for context]
  - (let () (unsafe-fx+ x 3) (define x 3) 5)
  5
 
 
  I consider this correct in a strange sense.
 
  Interestingly enough,
 
  (let () (displayln  (unsafe-fx+ x 3)) (define x 3) 5)
  x: variable used before its definition
   context...:
/Users/matthias/plt/racket/collects/racket/private/misc.rkt:87:7
 
  which is good too. I don't know how Claire and Matthew did this,
  but it's good :-)
  _
   Racket Developers list:
   http://lists.racket-lang.org/dev
 
  _
Racket Developers list:
http://lists.racket-lang.org/dev
 _
   Racket Developers list:
   http://lists.racket-lang.org/dev

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Catching the undefined value

2014-04-19 Thread Matthias Felleisen

Morally TR ought to report the type of this x as empty set, 
which would inform you that the else branch is unreachable: 

  (letrec ([x : Integer (if #t 0 x)]) x)

One day we may wish to augment syntax check in TR so that 
programmers can read of the reconstructed types for interior 
expressions. 

-- Matthias







On Apr 19, 2014, at 3:26 PM, Robby Findler wrote:

 Ah. There are other approaches to this problem that result in
 compile-time errors for such programs. Maybe the TR guys will adopt
 one or figure out a better one! But for regular ole Racket, we're
 stuck with a runtime error, I'm afraid.
 
 Robby
 
 On Sat, Apr 19, 2014 at 2:04 PM, Gustavo Massaccesi gust...@oma.org.ar 
 wrote:
 (letrec ([x (if #t 8 x)]) x) ;==8
 
 It was a mistake. I thought that the “x: undefined; ...” error was an
 expansion-time error, not a run-time error.
 
 (I expected an error, because the x in the else part is “undefined”,
 even if it’s never accessed.)
 
 Gustavo
 
 
 On Sat, Apr 19, 2014 at 1:02 PM, Robby Findler
 ro...@eecs.northwestern.edu wrote:
 These seem correct to me. What were you expecting (and why?).
 
 Robby
 
 
 On Saturday, April 19, 2014, Gustavo Massaccesi gust...@oma.org.ar wrote:
 
 I found another problem with the optimizer and the new undefined behavior.
 
 (letrec ([x (if #t 8 x)]) x) ;==8
 
 I also consider this correct in a strange sense :).
 
 Gustavo
 
 
 Welcome to Racket v6.0.1.4.
 (letrec ([x x]) x)
 x: undefined;
 cannot use before initialization
  context...:
   C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
 (letrec ([x 5]) x)
 5
 (letrec ([x (if #t 8 x)]) x)
 8
 (letrec ([x (if #f 8 x)]) x)
 x: undefined;
 cannot use before initialization
  context...:
   C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
 
 
 
 On Wed, Apr 16, 2014 at 10:09 AM, Matthias Felleisen
 matth...@ccs.neu.edu wrote:
 
 Ah, too bad:
 
 pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 ~~~
 --- OLD/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 +++ NEW/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 @@ -3416,5 +3416,16 @@
  (read (open-input-bytes (get-output-bytes o))
 
 ;; 
 +;; Check that an unsufe opertion's argument is
 +;; not optimized away if it's a use of
 +;; a variable before definition:
 +
 +(err/rt-test (let ()
 +   (unsafe-fx+ x 1)
 +   (define x 3)
 +   x)
 + exn:fail:contract:variable?)
 +
 +;; 
 
 
 :-)
 
 On Apr 16, 2014, at 9:02 AM, Matthias Felleisen matth...@ccs.neu.edu
 wrote:
 
 
 On Apr 15, 2014, at 9:29 PM, Asumu Takikawa as...@ccs.neu.edu wrote:
 
 On 2014-04-15 18:13:31 -0400, claire alvis wrote:
 The push below includes changes to letrec expressions, internal
 definitions, units, classes, and certain ill-formed shared
 expressions so
 that they no longer leak the `undefined' value.
 
 This is great! (especially happy that TR, even with classes, doesn't
 have to worry about #undefined anymore)
 
 BTW, I found this weird behavior:
 
 Welcome to Racket v6.0.1.3.
 - (require racket/unsafe/ops)
 - (let () (+ x 3) (define x 3) 5)
 ; x: variable used before its definition [,bt for context]
 - (let () (unsafe-fx+ x 3) (define x 3) 5)
 5
 
 
 I consider this correct in a strange sense.
 
 Interestingly enough,
 
 (let () (displayln  (unsafe-fx+ x 3)) (define x 3) 5)
 x: variable used before its definition
 context...:
  /Users/matthias/plt/racket/collects/racket/private/misc.rkt:87:7
 
 which is good too. I don't know how Claire and Matthew did this,
 but it's good :-)
 _
 Racket Developers list:
 http://lists.racket-lang.org/dev
 
 _
  Racket Developers list:
  http://lists.racket-lang.org/dev
 _
  Racket Developers list:
  http://lists.racket-lang.org/dev


_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] [plt] Push #28576: master branch updated

2014-04-19 Thread Vincent St-Amour
At Sat, 19 Apr 2014 13:19:25 -0400,
mfl...@racket-lang.org wrote:
 a01b12e Matthew Flatt mfl...@racket-lang.org 2014-04-19 10:11
 :
 | optimizer: don't move expressions into a `with-continuation-mark`
 |
 | ... unless the optimizer can prove that the expression doesn't
 | inspect continuation marks.
 :
   M pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl | 12 +++-
   M racket/src/racket/src/optimize.c|  5 +

This optimization can be observed from another thread, like a profiler's
sampling thread, even if the relevant code doesn't observe continuation
marks itself.

Vincent
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Catching the undefined value

2014-04-19 Thread Sam Tobin-Hochstadt
On Sat, Apr 19, 2014 at 4:45 PM, Matthias Felleisen
matth...@ccs.neu.edu wrote:

 Morally TR ought to report the type of this x as empty set,
 which would inform you that the else branch is unreachable:

   (letrec ([x : Integer (if #t 0 x)]) x)

I don't think that's right -- the else branch is unreachable, but
that's not a fact about the type of `x` in particular, any more than
it's a fact about the type of `+` if it was used in the else branch.

 One day we may wish to augment syntax check in TR so that
 programmers can read of the reconstructed types for interior
 expressions.

Definitely.

Sam







 On Apr 19, 2014, at 3:26 PM, Robby Findler wrote:

 Ah. There are other approaches to this problem that result in
 compile-time errors for such programs. Maybe the TR guys will adopt
 one or figure out a better one! But for regular ole Racket, we're
 stuck with a runtime error, I'm afraid.

 Robby

 On Sat, Apr 19, 2014 at 2:04 PM, Gustavo Massaccesi gust...@oma.org.ar 
 wrote:
 (letrec ([x (if #t 8 x)]) x) ;==8

 It was a mistake. I thought that the “x: undefined; ...” error was an
 expansion-time error, not a run-time error.

 (I expected an error, because the x in the else part is “undefined”,
 even if it’s never accessed.)

 Gustavo


 On Sat, Apr 19, 2014 at 1:02 PM, Robby Findler
 ro...@eecs.northwestern.edu wrote:
 These seem correct to me. What were you expecting (and why?).

 Robby


 On Saturday, April 19, 2014, Gustavo Massaccesi gust...@oma.org.ar wrote:

 I found another problem with the optimizer and the new undefined behavior.

 (letrec ([x (if #t 8 x)]) x) ;==8

 I also consider this correct in a strange sense :).

 Gustavo


 Welcome to Racket v6.0.1.4.
 (letrec ([x x]) x)
 x: undefined;
 cannot use before initialization
  context...:
   C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7
 (letrec ([x 5]) x)
 5
 (letrec ([x (if #t 8 x)]) x)
 8
 (letrec ([x (if #f 8 x)]) x)
 x: undefined;
 cannot use before initialization
  context...:
   C:\Program Files\Racket-6.0.1.4\collects\racket\private\misc.rkt:87:7



 On Wed, Apr 16, 2014 at 10:09 AM, Matthias Felleisen
 matth...@ccs.neu.edu wrote:

 Ah, too bad:

 pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 ~~~
 --- OLD/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 +++ NEW/pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl
 @@ -3416,5 +3416,16 @@
  (read (open-input-bytes (get-output-bytes o))

 ;; 
 +;; Check that an unsufe opertion's argument is
 +;; not optimized away if it's a use of
 +;; a variable before definition:
 +
 +(err/rt-test (let ()
 +   (unsafe-fx+ x 1)
 +   (define x 3)
 +   x)
 + exn:fail:contract:variable?)
 +
 +;; 


 :-)

 On Apr 16, 2014, at 9:02 AM, Matthias Felleisen matth...@ccs.neu.edu
 wrote:


 On Apr 15, 2014, at 9:29 PM, Asumu Takikawa as...@ccs.neu.edu wrote:

 On 2014-04-15 18:13:31 -0400, claire alvis wrote:
 The push below includes changes to letrec expressions, internal
 definitions, units, classes, and certain ill-formed shared
 expressions so
 that they no longer leak the `undefined' value.

 This is great! (especially happy that TR, even with classes, doesn't
 have to worry about #undefined anymore)

 BTW, I found this weird behavior:

 Welcome to Racket v6.0.1.3.
 - (require racket/unsafe/ops)
 - (let () (+ x 3) (define x 3) 5)
 ; x: variable used before its definition [,bt for context]
 - (let () (unsafe-fx+ x 3) (define x 3) 5)
 5


 I consider this correct in a strange sense.

 Interestingly enough,

 (let () (displayln  (unsafe-fx+ x 3)) (define x 3) 5)
 x: variable used before its definition
 context...:
  /Users/matthias/plt/racket/collects/racket/private/misc.rkt:87:7

 which is good too. I don't know how Claire and Matthew did this,
 but it's good :-)
 _
 Racket Developers list:
 http://lists.racket-lang.org/dev

 _
  Racket Developers list:
  http://lists.racket-lang.org/dev
 _
  Racket Developers list:
  http://lists.racket-lang.org/dev


 _
   Racket Developers list:
   http://lists.racket-lang.org/dev

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Catching the undefined value

2014-04-19 Thread Matthias Felleisen

On Apr 19, 2014, at 5:57 PM, Sam Tobin-Hochstadt wrote:

 On Sat, Apr 19, 2014 at 4:45 PM, Matthias Felleisen
 matth...@ccs.neu.edu wrote:
 
 Morally TR ought to report the type of this x as empty set,
 which would inform you that the else branch is unreachable:
 
  (letrec ([x : Integer (if #t 0 x)]) x)
 
 I don't think that's right -- the else branch is unreachable, but
 that's not a fact about the type of `x` in particular, any more than
 it's a fact about the type of `+` if it was used in the else branch.


Correct! 
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


[racket-dev] Regular expression types [was Re: [racket-bug] all/14455: wrong type for hash]

2014-04-19 Thread Neil Toronto
Are there type systems that can? It seems like you could specify this 
type and similar ones using regular expressions.


In my research, I'll probably use regular expressions to represent sets 
of strings. I've been curious about how well regular-expression-like 
things generalize to cartesian products with repeating structure.


Neil ⊥

On 04/19/2014 03:44 PM, Eric Dobson wrote:

The type for hash is conservative. TR currently cannot express the
alternating requirement that hash requires.

On Sat, Apr 19, 2014 at 2:40 PM,  alexan...@knauth.org wrote:

A new problem report is waiting at
   http://bugs.racket-lang.org/query/?cmd=viewpr=14455

Reported by Alex Knauth for release: 6.0

*** Description:
the type for hash appears to be (All (a b) (- (HashTable a b))), so it's not 
letting me supply it with arguments, saying that it expects 0 arguments

*** How to repeat:
#lang typed/racket
(hash 0 0)



_
 Racket Developers list:
 http://lists.racket-lang.org/dev


Re: [racket-dev] Regular expression types [was Re: [racket-bug] all/14455: wrong type for hash]

2014-04-19 Thread Sam Tobin-Hochstadt
On Sat, Apr 19, 2014 at 7:24 PM, Neil Toronto neil.toro...@gmail.com wrote:
 Are there type systems that can? It seems like you could specify this type
 and similar ones using regular expressions.

There is lots of work on types for XML specification that can handle
this sort of thing, I believe, but not specifically in the context of
function arguments.

Note that TR can handle alternating types just fine in lists, for
example -- it's just that the function argument sequence is different.

Sam
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] [plt] Push #28576: master branch updated

2014-04-19 Thread Matthew Flatt
At Sat, 19 Apr 2014 17:36:40 -0400, Vincent St-Amour wrote:
 At Sat, 19 Apr 2014 13:19:25 -0400,
 mfl...@racket-lang.org wrote:
  a01b12e Matthew Flatt mfl...@racket-lang.org 2014-04-19 10:11
  :
  | optimizer: don't move expressions into a `with-continuation-mark`
  |
  | ... unless the optimizer can prove that the expression doesn't
  | inspect continuation marks.
  :
M pkgs/racket-pkgs/racket-test/tests/racket/optimize.rktl | 12 
  +++-
M racket/src/racket/src/optimize.c|  5 +
 
 This optimization can be observed from another thread, like a profiler's
 sampling thread, even if the relevant code doesn't observe continuation
 marks itself.

Right: If there's some synchronization point within the expression so
that you could reliably observe the thread at that point, then the
expression doesn't get moved relative to marks.


_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Pre-Release Checklist for v6.0.1

2014-04-19 Thread Gregory Cooper

 * Greg Cooper g...@cs.brown.edu
   - FrTime Tests


Done.
_
  Racket Developers list:
  http://lists.racket-lang.org/dev