[racket-users] Racket v7.1

2018-10-26 Thread Vincent St-Amour
Racket version 7.1 is now available from

http://racket-lang.org/

* Although it is still not part of this release, the development of
  Racket on Chez Scheme continues. We still hope and expect that
  Racket-on-Chez will be ready for production use later in the v7.x
  series, perhaps mid-2019.

* Trackpad scrolling works in more reliably in some Windows and
  Linux/Unix environments.

* New users of DrRacket will open files into new tabs (by default).

* The teaching languages support the unicode character for lambda.
  The teaching unit test framework no longer stops testing when a tested
  expression signals an error.

* A refinement to error reporting for compile-time code helps clarify
  when an syntax error is likely due to an earlier unbound identifier
  (because the unbound-identifier error otherwise must be delayed, in
  case a definition appears later).

* A `++lang ` flag for `raco exe` simplifies the creation of
  executables that dynamically load `#lang ` modules at run
  time.

* Typed Racket adds types for mutable and immutable vectors:
  `(Mutable-Vectorof T)`, `(Immutable-Vectorof T)`, `(Immutable-Vector T)`,
  and `(Mutable-Vector T)`. The new types are subtypes of the existing
  `Vectorof` and `Vector` types. The return types of a few standard vector
  functions use the new, more specific, types. When an immutable vector
  flows from untyped code to typed code, Typed Racket may be able to check
  the vector with a flat contract.

* The hashing functions `sha1-bytes`, `sha224-bytes`, and
  `sha256-bytes` are added to `racket/base`.

* `curry` from racket/function supports currying functions with keyword
  arguments, and `procedure-arity` and `procedure-keywords` return the
  correct result when applied to curried functions.

* Slideshow supports widescreen mode (finally!). Implement widescreen
  slides using `slideshow/widescreen` or provide the `--widescreen`
  command-line flag to Slideshow. Combine `--widescreen` with
  `--save-aspect` to make widescreen mode the default in your
  installation.

* Racket supports FreeBSD/aarch64.

* Various improvements and additions were made to the DeinProgramm
  teaching languages and their documentation.

The following people contributed to this release:
Akihide Nano, Alex Harsányi, Alex Knauth, Alexander McLin, Alexis King,
Andrew Kent, Ben Greenman, Bruno Cuconato, Chongkai Zhu, Claes Wallin,
David Benoit, Gary F. Baumgartner, Gustavo Massaccesi, Jay McCarthy,
Jens Axel Søgaard, Jérôme Martin, John Clements, Jordan Johnson, Kimball
Germane, Leif Andersen, Matthew Butterick, Matthew Flatt, Matthias
Felleisen, Mike Sperber, Milo Turner, myfreeweb, Oling Cat, Paulo Matos,
Philip McGrath, Robby Findler, Roman Klochkov, Ryan Culpepper, Sam
Caldwell, Sam Tobin-Hochstadt, Shu-Hung You, Stephen Chang, Tong-Kiat
Tan, Vincent St-Amour, Winston Weinert, and yjqww6.

Feedback Welcome

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] confusion about call-with-current-continuation

2018-10-26 Thread Shu-Hung You
Because applying the continuation captured by Racket's
call-with-current-continuation will *replace* existing continuations.
Therefore the exception handler is removed. To obtain a continuation
that will only *extend* the current continuation, use
call-with-composable-continuation.

(Another way to get "div by 0" is to wrap the call to saved-k in a
prompt via call-with-continuation-prompt so saved-k would not remove
the portion of continuation that installs the handler.)
On Fri, Oct 26, 2018 at 3:53 AM  wrote:
>
>
> Thanks Shu-hung.
>
> So here is my understanding:
>
> #lang racket
>
> (begin
>
>   (define saved-k #f) ; wrapped in "prompt 1"
>
>   (+ 1 (call/cc
> (lambda (k)
>   (set! saved-k k)
>   0))) ; wrapped in "prompt 2"
>
>   (println 'hello) ; wrapped in "prompt 3"
>
>   (saved-k 100) ; wrapped in "prompt 4"
>
>   (println 'hello2) ; wrapped in "prompt 5"
>
>   )
>
> When we call (saved-k 100), control flow jump to the continuation saved 
> before, but it still in "prompt 4".
> After "prompt 4" all finished, the next prompt is "prompt 5" (prompt is also 
> a continuation, but marked) , so print 'hello2.
> Then all end.
>
> Everything is fine.
>
> But what about this code:
>
> #lang racket
>
> (begin
>
>   (define saved-k #f) ; wrapped in "prompt 1"
>
>   (/ 1 (call/cc
> (lambda (k)
>   (set! saved-k k)
>   1))) ; wrapped in "prompt 2"
>
>   (println 'hello) ; wrapped in "prompt 3"
>
>   (with-handlers ([exn:fail:contract:divide-by-zero?
>(lambda (exn) (println "div by 0"))])
> (saved-k 0)) ; wrapped in "prompt 4"
>
>   (println 'hello2) ; wrapped in "prompt 5"
>
>   )
>
> Since the continuation executed in "prompt 4", why I can not print "div by 0" 
> ?
>
>
> On Friday, October 26, 2018 at 3:57:57 AM UTC+8, Shu-Hung You wrote:
>>
>> FWIW here's the part in the document that could be helpful:
>>
>> 1. The section in the Guide that talks about the concept of prompts
>> and their usage in the continuation in Racket:
>> https://docs.racket-lang.org/guide/prompt.html
>> The prompt is kind of like a mark on the continuations that lets the
>> control operators find the portion of continuations they want to
>> manipulate.
>>
>> 2. About your original question (why (print 'hello) isn't captured),
>> there are two things happening here:
>>
>> 2a. Begin is a special syntactic form. It does not just mean
>> evaluating a sequence of expressions in order. When used at certain
>> contexts such as top-level (module-level) context, begin splices the
>> forms it contains to the surrounding context. The last paragraph in
>> the guide ( https://docs.racket-lang.org/guide/begin.html ) briefly
>> talked about it. The reference (
>> https://docs.racket-lang.org/reference/begin.html#(form._((quote._~23~25kernel)._begin))
>> ) made it explicit that the forms
>> (begin expr expr ...)   and
>> (begin form form ...)
>> are different.
>>
>> As an example, in the following module, with or without begin makes no
>> difference at all. The subforms are spliced to the module-level
>> context:
>>
>> #lang racket
>>
>> (define (even??? x) (odd??? (- x 1)))
>>
>> ;; At module-level context, this begin works as if the
>> ;; program were just written directly without begin:
>> ;; (displayln ...)
>> ;; (define (odd??? ...
>> (begin
>> (displayln "No difference")
>> (define (odd??? x) (odd? x)))
>>
>> (odd??? 9)
>> (even??? 8)
>>
>> This, combined with the following reason (2b) is why your code didn't
>> work as expected.
>>
>> 2b. The evaluation of module-level expressions and definitions are
>> implicitly wrapped in a prompt. That is, for a module
>>
>> #lang racket
>>
>> expr1
>> (define def2 expr2)
>> expr3
>> expr4
>> (define def5 expr5)
>> ...
>>
>> the evaluation of each expr is implicitly wrapped by the default
>> prompt as if it were evaluated using:
>>
>> procedure instantiate a module M:
>> for each module-level expression/definition EXPR do:
>>   with DEFAULT_PROMPT:
>>   result = eval(EXPR)
>>   ...
>>
>> The control operators (e.g. call/cc and abort) by default looks for
>> the default prompt. This effectively delimits the control effect of
>> each module-level expression and therefore the call/cc in your code
>> will not capture the println portion.
>>
>> This behavior is described in the reference about how the body of a
>> module is evaluated, starting from the paragraph ``A module body is
>> executed only when the module is explicitly instantiated ...''
>> https://docs.racket-lang.org/reference/module.html
>>
>> On Thu, Oct 25, 2018 at 2:00 PM  wrote:
>> >
>> >
>> > About (+ 1 (prompt (* 2 (call/cc (lambda (k) (set! x k) 2)
>> >
>> > 1. "prompt" form does not exist in racket.
>> > It is a procedure application or special form ?
>> >
>> > 2. assume this procedure or special form exists to construct a prompt.
>> >
>> > (+ 1 (prompt (* 2 (call/cc (lambda (k) (set! x k) 2)
>> >
>> > After the (lambda (k) ...) 

Re: [racket-users] confusion about call-with-current-continuation

2018-10-26 Thread serioadamo97

Thanks Shu-hung.

So here is my understanding:

#lang racket

(begin

  (define saved-k #f) ; wrapped in "prompt 1"

  (+ 1 (call/cc
(lambda (k)
  (set! saved-k k)
  0))) ; wrapped in "prompt 2"

  (println 'hello) ; wrapped in "prompt 3"

  (saved-k 100) ; wrapped in "prompt 4"

  (println 'hello2) ; wrapped in "prompt 5"
  
  )

When we call (saved-k 100), control flow jump to the continuation saved 
before, but it still in "prompt 4".
After "prompt 4" all finished, the next prompt is "prompt 5" (prompt is 
also a continuation, but marked) , so print 'hello2.
Then all end.

Everything is fine.

But what about this code:

#lang racket

(begin

  (define saved-k #f) ; wrapped in "prompt 1"

  (/ 1 (call/cc
(lambda (k)
  (set! saved-k k)
  1))) ; wrapped in "prompt 2"

  (println 'hello) ; wrapped in "prompt 3"

  (with-handlers ([exn:fail:contract:divide-by-zero?
   (lambda (exn) (println "div by 0"))])
(saved-k 0)) ; wrapped in "prompt 4"

  (println 'hello2) ; wrapped in "prompt 5"
  
  )

Since the continuation executed in "prompt 4", why I can not print "div by 
0" ?


On Friday, October 26, 2018 at 3:57:57 AM UTC+8, Shu-Hung You wrote:
>
> FWIW here's the part in the document that could be helpful: 
>
> 1. The section in the Guide that talks about the concept of prompts 
> and their usage in the continuation in Racket: 
> https://docs.racket-lang.org/guide/prompt.html 
> The prompt is kind of like a mark on the continuations that lets the 
> control operators find the portion of continuations they want to 
> manipulate. 
>
> 2. About your original question (why (print 'hello) isn't captured), 
> there are two things happening here: 
>
> 2a. Begin is a special syntactic form. It does not just mean 
> evaluating a sequence of expressions in order. When used at certain 
> contexts such as top-level (module-level) context, begin splices the 
> forms it contains to the surrounding context. The last paragraph in 
> the guide ( https://docs.racket-lang.org/guide/begin.html ) briefly 
> talked about it. The reference ( 
>
> https://docs.racket-lang.org/reference/begin.html#(form._((quote._~23~25kernel)._begin))
>  
> ) made it explicit that the forms 
> (begin expr expr ...)   and 
> (begin form form ...) 
> are different. 
>
> As an example, in the following module, with or without begin makes no 
> difference at all. The subforms are spliced to the module-level 
> context: 
>
> #lang racket 
>
> (define (even??? x) (odd??? (- x 1))) 
>
> ;; At module-level context, this begin works as if the 
> ;; program were just written directly without begin: 
> ;; (displayln ...) 
> ;; (define (odd??? ... 
> (begin 
> (displayln "No difference") 
> (define (odd??? x) (odd? x))) 
>
> (odd??? 9) 
> (even??? 8) 
>
> This, combined with the following reason (2b) is why your code didn't 
> work as expected. 
>
> 2b. The evaluation of module-level expressions and definitions are 
> implicitly wrapped in a prompt. That is, for a module 
>
> #lang racket 
>
> expr1 
> (define def2 expr2) 
> expr3 
> expr4 
> (define def5 expr5) 
> ... 
>
> the evaluation of each expr is implicitly wrapped by the default 
> prompt as if it were evaluated using: 
>
> procedure instantiate a module M: 
> for each module-level expression/definition EXPR do: 
>   with DEFAULT_PROMPT: 
>   result = eval(EXPR) 
>   ... 
>
> The control operators (e.g. call/cc and abort) by default looks for 
> the default prompt. This effectively delimits the control effect of 
> each module-level expression and therefore the call/cc in your code 
> will not capture the println portion. 
>
> This behavior is described in the reference about how the body of a 
> module is evaluated, starting from the paragraph ``A module body is 
> executed only when the module is explicitly instantiated ...'' 
> https://docs.racket-lang.org/reference/module.html 
>
> On Thu, Oct 25, 2018 at 2:00 PM > 
> wrote: 
> > 
> > 
> > About (+ 1 (prompt (* 2 (call/cc (lambda (k) (set! x k) 2) 
> > 
> > 1. "prompt" form does not exist in racket. 
> > It is a procedure application or special form ? 
> > 
> > 2. assume this procedure or special form exists to construct a prompt. 
> > 
> > (+ 1 (prompt (* 2 (call/cc (lambda (k) (set! x k) 2) 
> > 
> > After the (lambda (k) ...) evaluated, value of k is (* 2 []), then I 
> call 
> > (k 0) ; < When does the control flow come back here? 
> > 
> > (k 0) ---jump to--> (* 2 []), and then? 
> > 
> > What happens after (*2 0) ? What is the continuation of (*2 0)? 
> > 
> > 
> > On Friday, October 26, 2018 at 2:11:43 AM UTC+8, Joao Pedro Abreu De 
> Souza wrote: 
> >> 
> >> well, let's go by parts : 
> >> 
> >> 1) call/cc in principle will capture the complete continuation of a 
> expression, right? Delimited continuation will capture ... welll, delimited 
> continuations. But delimited by what? By a prompt. 
> >> In a delimited