J. Ian Johnson | 29 Jul 22:23 2014

Surprising behavior of for/fold. Bug?

This will eat all your memory,

(for/list ([x '(0 1 2 3 4 5 6)]
           #:unless (= x 4)
           [i (in-naturals)])
  x)

and this won't.

(for/list ([x '(0 1 2 3 4 5 6)]
           [i (in-naturals)]
           #:unless (= x 4))
  x)

Should we expect this behavior? I was really surprised by this.
-Ian
_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev

Ryan Culpepper | 28 Jul 20:33 2014

Release Announcement for v6.1

The release announcement sketch that I have so far is below.  Please
mail me new items and/or edits.
----------------------------------------------------------------------

mflatt:
- ARM JIT: fix software floating-point (ffb0dd52)
- add plumbers (d5b42f8c)
- raco make: improve parallelism (9e3b9844)
- deprecate 3-arg module name resolver calls (8aaa3fc5)
- win32: support symbolic links (3e3cb716, 9fed5b58)
- drawing, bounding boxes, picts, scribble
   (970b040d, 37af1c8e, c4a58dc4, 05760a12, dac8ba28)

robby:
- random generation from contracts (1cb1ff28, 76c6a1b7)
- contract improvements (c64d70ab)
- change semantics of _!_ variables under ellipses (69c96c62)
- change metafunction contract formatting (d067311c)
- recursive-contract and cyclic values
   (7728e062, d664ee14, ..., 0db4df1d, f49dd363)
- add dvipdf backend to scribble (5280395f)
- add history (???) (3cd15cea, 145644ac, 83e8cfba, fb048647, d9dae651)

matthias:
- add check-random (aec84f4a)

ryanc:
- ssl DHE/ECDHE, TLS 1.1,1.2 (thanks to Edward Lee) (5c11e621)
- add SSL client SNI (Jay Kominek) (52159fea)

(Continue reading)

Sam Tobin-Hochstadt | 25 Jul 16:59 2014
Picon
Picon

Re: [plt] Push #29098: master branch updated

On Fri, Jul 25, 2014 at 10:39 AM,  <mflatt@...> wrote:
>
> | As far as I can tell, we have to compute ourselves whether a
> | date is in daylight-saving time based on specifications of
> | when daylight and standard times start. That part seems tricky
> | and could use extra review.

From a quick search of the repository, it looks like
`scheme_get_seconds` and `seconds_to_date` aren't used anywhere else
in the C code, and thus could be rewritten in Racket using the FFI,
which might make the extra review easier. :)

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

Sam Tobin-Hochstadt | 24 Jul 22:08 2014
Picon
Picon

strange top-level binding for module-defined identifiers

If you take this program (which is a lot like the implementation of
`racket/fixnum`):

#lang racket/base

(require '#%flfxnum
         racket/private/vector-wraps
         racket/unsafe/ops
         (for-syntax racket/base))

(define-vector-wraps "fxvector"
  "fixnum?" fixnum?
  fxvector? fxvector-length fxvector-ref fxvector-set! make-fxvector
  unsafe-fxvector-ref unsafe-fxvector-set! unsafe-fxvector-length
  in-fxvector*
  in-fxvector
  for/fxvector
  for*/fxvector
  fxvector-copy
  0)

And run it in the macro stepper with macro hiding off, at the end you
get a fully-expanded module where the first definition is
`:fXvector-gen`. However, if you click on this identifier, either in
the definition or in a subsequent use, it says "Apparent identifier
binding: none" (which means that `identifier-binding` returns #f,
which can be confirmed on the expanded syntax).

How can this happen? Is it a bug in something, or a special case that
I didn't expect?
(Continue reading)

Sam Tobin-Hochstadt | 24 Jul 21:45 2014
Picon
Picon

A tricky chaperone puzzle

Consider the following module:

(module m racket
  (struct x [a])
  (define v1 (x 'secret))
  (define v2 (x 'public))
  (provide v1 v2)
  (provide/contract [x-a (-> x? (not/c 'secret))]))

It appears that this ensures that you can't get 'secret. But, it turns
out that I can write a function outside of `m` that behaves like `x-a`
without the contract:

(require (prefix-in m: 'm))

(define (x-a v)
  (define out #f)
  (with-handlers ([void void])
    (m:x-a (chaperone-struct v m:x-a (λ (s v) (set! out v) v))))
  out)

Now this works:

(displayln (x-a m:v1)) ;; => 'secret

The problem is that `m:x-a` is treated as a
`struct-accessor-procedure?`, which is a capability for accessing the
a field, even though it's a significantly restricted capability.

There are a couple possible solutions I've thought of:
(Continue reading)

Pedro Ramos | 23 Jul 17:54 2014
Picon

Racket hash tables vs. Python dicts - Performance

Hi,

I've been developing an implementation of Python in Racket, where I'm implementing Python's dictionaries over Racket custom hash tables.

While my occasional benchmarks typically show better performance on Racket programs than their Python equivalents, Racket's hash tables generally seem to be slower than Python's dicts.

I've set up this benchmark in Racket:


#lang racket

(define alphabet "abcdefghijklmnopqrstuvwxyz")
(define (random-word n)
  (build-string n (lambda (x) (string-ref alphabet (random 23)))))

(define words (for/list ([k 1000000])
                (random-word 3)))
(define d (make-hash))

(time (for ([w words])
        (if (hash-has-key? d w)
            (hash-set! d w (add1 (hash-ref d w)))
            (hash-set! d w 1))))


And its equivalent in Python:


import random
import time

alphabet = "abcdefghijklmnopqrstuvwxyz"
def random_word(n):
  return ''.join([random.choice(alphabet) for i in range(n)])

words = [random_word(3) for k in xrange(1000000)]
d = {}

a = time.time()
for w in words:
  if w in d:
    d[w] = d[w] + 1
  else:
    d[w] = 1
b = time.time()
print b-a, 'seconds'


The Racket example yields running times of around 500 ms (running on Racket v6.0.1) while the Python example yields running times of around 330 ms (running on Python 2.7.3).

I find this unusual because Python is somewhat more dynamic than Racket, since
(a) Python's equality and hashing functions have to dispatched at runtime for each key;
(b) referencing and setting values in a Python dict is done using a very general operator, [], whose behaviour also has to be dispatched at runtime, unlike the more specific hash-ref and hash-set! Racket functions.

Is there something I'm missing about Racket's hash tables which explains this slower speed?

Thanks,
Pedro Ramos
_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev
Antonio Menezes Leitao | 23 Jul 21:20 2014
Picon

Problem with Values type constructor

Hi,

Although the typed racket documentation mentions Values as a type constructor, it does not work:

Welcome to DrRacket, version 6.1.0.3--2014-07-18(e827817/a) [3m].
Language: typed/racket; memory limit: 1024 MB.
> (define (foo) : (Values Number Number) (values 1 2))
. Type Checker: parse error in type;
 type name `Values' is unbound in: Values
. Type Checker: wrong number of values: expected 1 but got 2 in: (values 1 2)
. Type Checker: Summary: 2 errors encountered in:
  Values
  (values 1 2)

OTOH, the lowercase values seems to work as a type constructor.

> (define (bar) : (values Number Number) (values 1 2))
> bar
- : (-> (values Number Number))
#<procedure:bar>

Moreover, there is some kind of confusion between values and Values:

> (values 1 2)
- : (values Integer Integer) [more precisely: (Values One Positive-Byte)]
1
2

Am I missing something?

Best,
António.
_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev
J. Ian Johnson | 21 Jul 18:39 2014

Re: pkg account creator not working?

I've tried both now. No go.
-Ian
----- Original Message -----
From: "Leif Andersen" <leif@...>
To: "J. Ian Johnson" <ianj@...>
Cc: "dev" <dev@...>
Sent: Monday, July 21, 2014 12:35:06 PM GMT -05:00 US/Canada Eastern
Subject: Re: [racket-dev] pkg account creator not working?

What web browser are you using?

I was only able to make an account using Chromium. (Firefox didn't work for me.)

~Leif Andersen

On Mon, Jul 21, 2014 at 12:27 PM, J. Ian Johnson <ianj@...> wrote:
> I tried to make an account of pkgs.racket-lang.org, and it never emailed me a code. Is something in the
pipeline not working?
> -Ian
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev
_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev

J. Ian Johnson | 21 Jul 18:27 2014

pkg account creator not working?

I tried to make an account of pkgs.racket-lang.org, and it never emailed me a code. Is something in the
pipeline not working?
-Ian
_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev

Alexander D. Knauth | 20 Jul 02:25 2014

Help with build failed error message

I made a fork of the racket repo and committed some changes in a topic branch, but I got this:
make[8]: Leaving directory `/home/travis/build/AlexKnauth/racket/racket/src/build'
make[7]: Leaving directory `/home/travis/build/AlexKnauth/racket/racket/src/build'
make[6]: Leaving directory `/home/travis/build/AlexKnauth/racket/racket/src/build'
racket/racket3m -X "/home/travis/build/AlexKnauth/racket/racket/collects" -G "/home/travis/build/AlexKnauth/racket/racket/etc" -G /home/travis/build/AlexKnauth/racket/build/config -N "raco" -l- setup --no-user -j 2
raco setup: bootstrapping from source...
Killed
make[5]: *** [install-3m] Error 137
make[5]: Leaving directory `/home/travis/build/AlexKnauth/racket/racket/src/build'
make[4]: *** [install] Error 2
make[4]: Leaving directory `/home/travis/build/AlexKnauth/racket/racket/src/build'
make[3]: *** [base] Error 2
make[3]: Leaving directory `/home/travis/build/AlexKnauth/racket'
make[2]: *** [plain-in-place] Error 2
make[2]: Leaving directory `/home/travis/build/AlexKnauth/racket'
make[1]: *** [cpus-in-place] Error 2
make[1]: Leaving directory `/home/travis/build/AlexKnauth/racket'
make: *** [in-place] Error 2
The command "make CPUS="2" PKGS="racket-test db-test unstable-flonum-lib net-test"" exited with 2.

What does this mean?

What does the “Killed” mean?
And what is error 137?

_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev
Matthias Felleisen | 20 Jul 01:20 2014

Re: [plt] Push #29062: master branch updated


Thanks for the extensive internal documentation. -- Matthias

On Jul 19, 2014, at 7:07 PM, gcooper@... wrote:

> gcooper has updated `master' from 45306397cc to 2881b60536.
>  http://git.racket-lang.org/plt/45306397cc..2881b60536
> 
> =====[ One Commit ]=====================================================
> Directory summary:
> 100.0% pkgs/frtime/
> 
> ~~~~~~~~~~
> 
> 2881b60 Gregory Cooper <ghcooper@...> 2014-07-19 16:06
> :
> | Rewrite the delay-by primitive so it's easier to understand.
> |
> | Also, add comments that attempt to explain how it's intended to work.
> :
>  M pkgs/frtime/lang-ext.rkt | 139 ++++++++++++++++++++++++++++++++------------
> 
> =====[ Overall Diff ]===================================================
> 
> pkgs/frtime/lang-ext.rkt
> ~~~~~~~~~~~~~~~~~~~~~~~~
> --- OLD/pkgs/frtime/lang-ext.rkt
> +++ NEW/pkgs/frtime/lang-ext.rkt
>  <at>  <at>  -3,6 +3,7  <at>  <at> 
>                      (only-in racket/list first second last-pair empty empty?))
>          (only-in racket/list first second cons? empty empty? rest last-pair)
>          (only-in racket/function identity)
> +         data/queue
>          (only-in frtime/core/frp super-lift undefined undefined? behavior? do-in-manager-after
do-in-manager proc->signal set-signal-thunk! register unregister 
>                   signal? signal-depth signal:switching? signal-value value-now signal:compound?
signal:compound-content signal:switching-current signal:switching-trigger 
>                   set-cell! snap? iq-enqueue value-now/no-copy event-receiver event-set? proc->signal:switching
set-signal-producers! set-signal-depth! safe-signal-depth 
>  <at>  <at>  -403,46 +404,110  <at>  <at> 
>     (set-signal-value! ret ((signal-thunk ret)))
>     ret))
> 
> -; XXX general efficiency fix for delay
> -; signal[a] signal[num] -> signal[a]
> -(define (delay-by beh ms-b)
> -  (letrec ([last (mcons (cons (if (zero? (value-now ms-b))
> -                                  (value-now/no-copy beh)
> -                                  undefined)
> -                              (current-inexact-milliseconds))
> -                        empty)]
> -           [head last]          
> -           [consumer #f]
> -           [producer (proc->signal
> -                      (lambda ()
> -                        (let* ([now (and (signal? consumer) (current-inexact-milliseconds))]
> -                               [ms (value-now ms-b)])
> -                          (let loop ()
> -                            (if (or (empty? (mcdr head))
> -                                    (< now (+ ms (cdr (mcar (mcdr head))))))
> -                              (let ([val (car (mcar head))])
> -                                (if (event-set? val)
> -                                  (make-events-now (event-set-events val))
> -                                  val))
> -                              (begin
> -                                (set! head (mcdr head))
> -                                (loop)))))))])
> +;; signal[a] num -> signal[a]
> +;;
> +;; Returns a signal whose value at (approximately) time (+ t |delay-millis|) is a (deep) snapshot
> +;; of the value of |sig| at time t, for all times t from now on. For earlier times, the value of the
> +;; returned signal is undefined.
> +;;
> +;; Assumptions: (current-inexact-milliseconds) is monotonically non-decreasing; |delay-millis| is
> +;; positive and finite.
> +(define (delay-by sig delay-millis)
> +  ;; Implementation strategy:
> +  ;;
> +  ;; Maintain a queue of pairs (snapshot . timestamp) of the observed signal going back in
> +  ;; time for at least |delay-millis|. Start with (undefined . -inf.0) and (current-value . now), so
> +  ;; there should always be at least one item (value . timestamp) in the queue such that
> +  ;; (>= now (+ timestamp delay-millis)).
> +  ;;
> +  ;; |consumer| runs whenever |sig| changes and adds an item with the observed value and current
> +  ;;     time to the queue; schedules |producer| to run at |delay-millis| in the future, by which
> +  ;;     time it should be ready to take on that observed value.
> +  ;;
> +  ;; |producer| has no dependencies recorded in the dataflow graph and only runs when scheduled
> +  ;;     by the consumer. (This is what allows delay-by to break cycles.) It traverses the queue
> +  ;;     looking for the latest observation (value . timestamp) such that
> +  ;;     (>= now (+ timestamp delay-millis)), and takes on the observed value. |producer| is the
> +  ;;     value returned by this procedure, so it stays alive as long as anything cares about its
> +  ;;     value.
> +  (let* ([queue (make-queue)]
> +         
> +         ;; finish : (a . num) a -> a
> +         ;; Puts |queue-item| back on the front of the queue and returns |val|, updating the
> +         ;; occurrence timestamp if |val| represents an event set.
> +         ;; TODO(gcooper): We could avoid this if data/queue supported a "peek" operation.
> +         [finish! (lambda (queue-item val)
> +                    (enqueue-front! queue queue-item)
> +                    (if (event-set? val)
> +                        (make-events-now (event-set-events val))
> +                        val))]
> +         [now-millis (current-inexact-milliseconds)]
> +          
> +         [_ (begin
> +              ;; Add initial observations to the queue.
> +              (enqueue! queue (cons undefined -inf.0))
> +              (enqueue! queue (cons (deep-value-now sig empty) now-millis)))]
> +         
> +         ;; |consumer|'s thunk needs |producer| to be in scope so it can schedule it, and
> +         ;; |producer|'s thunk needs |consumer| to be in scope so it can keep it alive. To set up
> +         ;; this cycle, we first create |consumer| with a dummy thunk (void), then define
> +         ;; |producer|, and finally update |consumer|'s thunk to what we want it to be.
> +         [consumer (proc->signal void sig)]
> +         [producer (proc->signal
> +                    (lambda ()
> +                      (let ([now-millis (current-inexact-milliseconds)])
> +                        ;; There's no way to "peek" at the next item in the queue, so we have to
> +                        ;; dequeue it, check whether we're ready for it, and if not, stick it back
> +                        ;; on the front...
> +                        (let loop ([front (dequeue! queue)])
> +                          ;; |val| is our current candidate value; we'll use it if there's no later
> +                          ;; observation that's at least |delay-millis| old.
> +                          (let* ([val (car front)])
> +                            (if (queue-empty? queue)
> +                                ;; There are no later observations to consider, so use the current
> +                                ;; one.
> +                                (finish! front val)
> +                                ;; Look at the next item in the queue to see if we're ready for it.
> +                                ;; If so, recur. Otherwise, put it back on the front of the queue
> +                                ;; and use the previous value.
> +                                (let* ([next (dequeue! queue)]
> +                                       [timestamp-millis (cdr next)])
> +                                  ;; Kludge: since there's nothing that would otherwise keep
> +                                  ;; |consumer| alive, we retain a reference to it here, and we
> +                                  ;; trick the runtime into not optimizing it away by calling a
> +                                  ;; predicate and using the result in a conditional expression. If
> +                                  ;; the compiler ever gets smart enough to determine that the
> +                                  ;; outcome is provably always true, and therefore that it can
> +                                  ;; optimize away this code, we'll have to come up with a
> +                                  ;; different strategy (e.g., adding a special field to the signal
> +                                  ;; structure).
> +                                  (if (and (signal? consumer)
> +                                           (< now-millis (+ timestamp-millis delay-millis)))
> +                                      ;; We're not ready for the next value yet, so push it back
> +                                      ;; and proceed with the previous value.
> +                                      (begin
> +                                        (enqueue-front! queue next)
> +                                        (finish! front val))
> +                                      (loop next)))))))))])
>     (begin
> -      (set! consumer (proc->signal
> -                      (lambda ()
> -                        (let* ([now (current-inexact-milliseconds)]
> -                               [new (deep-value-now beh empty)]
> -                               [ms (value-now ms-b)])
> -                          (when (not (equal? new (car (mcar last))))
> -                            (set-mcdr! last (mcons (cons new now)
> -                                                   empty))
> -                            (set! last (mcdr last))
> -                            (schedule-alarm (+ now ms) producer))))
> -                      beh ms-b))
> +      (set-signal-thunk!
> +       consumer
> +       (lambda ()
> +         (let* ([now-millis (current-inexact-milliseconds)]
> +                [new-value (deep-value-now sig empty)])
> +           ;; Record the current observation and schedule |producer| to run when it's time to take
> +           ;; on this value.
> +           (enqueue! queue (cons new-value now-millis))
> +           (schedule-alarm (+ now-millis delay-millis) producer))))
> +      
> +      ;; Make sure producer is scheduled to run as soon as there's a value ready for it.
> +      (schedule-alarm (+ now-millis delay-millis) producer)
>       producer)))
> 
> -(define (inf-delay beh)
> -  (delay-by beh 0))
> +;; signal[a] -> signal[a]
> +;; Delays |sig| by the smallest possible amount of time.
> +(define (inf-delay sig)
> +  (delay-by sig 0))
> 
> ; XXX fix to take arbitrary monotonically increasing number
> ; (instead of milliseconds)

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


Gmane