mb | 27 Nov 17:09 2015

change DrRacket syntax coloring per-source rather than per-lang?

In `#lang pollen`, which uses a variant of at-expressions, you can change the command character on a
per-source-file basis, so you can say `◊(+ 1 1)` or `∆(+ 1 1)` or ` <at> (+ 1 1)` ...

I'm trying to figure out if I can bubble this up to DrRacket for syntax coloring. I see two wrinkles:

1) For syntax-coloring purposes, the command character is set in the `get-info` function for the #lang,
which in pollen looks like this:

(define (get-info in mod line col pos)
      (λ (key default)
        (case key
           (define make-scribble-inside-lexer2
             (dynamic-require 'syntax-color/scribble-lexer 'make-scribble-inside-lexer (λ () #f)))
           (cond [make-scribble-inside-lexer2
                  (make-scribble-inside-lexer2 #:command-char #\◊)]
                 [else default])]
          [else default])))

I could set the command character properly if I had access to the path of the source file. But IIUC DrRacket
invokes the `get-info` for a #lang on a "global" basis, i.e., before it considers any source-specific information.

2) DrRacket seems to cache the result of `get-info` for a whole session. So even if I could set the command
character correctly for the first source file, it wouldn't change if I had multiple source files open with
multiple command characters (in different tabs or windows).


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+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.
(Continue reading)

Paolo Giarrusso | 27 Nov 13:13 2015

DrRacket fights `racket` on print behavior in `#lang racket/base`

Here's an example showing that this test will not behave consistently in DrRacket and Racket, because
`print` won't.

Is that a bug, or is it a "bad practice (tm)" that I ever use `print` programmatically and expect specific
output? Take the question as "me learning Racket, somewhat chaotically" :-).
(This question arose in the context of another thread, but I'd like the version without the context).

#lang racket/base

(require rackunit

(struct posn (x y) #:transparent)
(struct game-state (speed circle target) #:transparent)
(define p (posn 150 100))
(list (game-state p p p))

; This test works in DrRacket and fails with `racket -t $ThisFile`
(check-equal? (~v (list (game-state p p p))) "(list (game-state (posn 150 100) (posn 150 100) (posn 150 100)))")

The `print` statement produces `(list (game-state (posn 150 100) (posn 150 100) (posn 150 100)))` in
DrRacket and `(list (game-state #0=(posn 150 100) #0# #0#))` otherwise:

$ racket -t printing.rkt
(list (game-state #0=(posn 150 100) #0# #0#))
(Continue reading)

Paolo Giarrusso | 27 Nov 01:16 2015

Value printing in REPL and for students

Hi all!

How does the REPL print values? In some circumstances I see graph printing markers, even though
`(print-graph)` is disabled. Because these are error messages for students using teaching languages,
cycle printing is not an option.

messages.rkt> (print-graph)
messages.rkt> (list (game-state p p p))
(list (game-state (posn 150 100) (posn 150 100) (posn 150 100)))
messages.rkt> (~v (list (game-state p p p)))
"(list (game-state #0=(posn 150 100) #0# #0#))"

Funnily, that doesn't happen in DrRacket, but it does happen both in racket-mode, in my actual production
environment, and under raco test. In particular, test results in DrRacket are the ones I'd want, but are
inconsistent with the ones everywhere else.

Apart from being frustrated at parameters, how do I gain control over this?

PS: I've just found that `global-port-print-handler` is customized by DrRacket. That seems
incompatible with using `print` and relying on it producing certain results. I understand that's the
point of `print`, but neither `write` nor `display` does what I want.

HTDP code itself uses `~e` (also in htdp/error), but finding the appropriate handler to install isn't
trivial either; and that's not enough, because sometimes I need to show the source code we evaluated.

Sorry for how chaotic is this message — I guess that reflects my confusion at Racket printing. (I've taken
some looks at the relevant documentation, but not at all of it).

(Continue reading)

Dmitry Pavlov | 25 Nov 22:29 2015

lib-search-dirs in config.rktd discards Racket's own libs on Windows


I edit etc/config.rktd on every installation of Racket to add a path
to my own libraries:

(lib-search-dirs . ("C:/my/libs"))

Older versions of Racket were OK with that setting.
Current version obeys that setting too strongly, forgetting
where its own libraries are. For example, DrRacket can not start:

ffi-lib: couldn't open "libintl-8.dll" ([...] errno=126)
Files\Racket\share\pkgs\draw-lib\racket\draw\unsafe\glib.rkt: [running body]
[traversing imports]

I do not complain; the following line does the job for me

(lib-search-dirs . ("C:/Program Files/Racket/lib" "C:/my/libs"))

Just wondering whether it is a planned change or not.




(Continue reading)

Paolo Giarrusso | 25 Nov 13:35 2015

"bad variable linkage" after restarting handin server under load

Hi all,
it's me, handin server guy again. Sorry to bother.

Our handin server started "crashing" with "bad variable linkage" errors at deadline time (presumably
under somewhat high load), and since it happened twice, I thought I'd report it. Any ideas on what's
causing this?

After this "crash", the server keeps running, but rejects all submissions because the same checker keeps
not loading.


[1|2015-11-23T14:51:31] (re)loading module from (file /var/handin_config/info1-teaching-material/checkers/06-Datentypen/REDACTED-USER-NAME/../checker.rkt)
[1|2015-11-23T14:51:33] ERROR: link: bad variable linkage;
[1|2015-11-23T14:51:33]  reference to a variable that is uninitialized
[1|2015-11-23T14:51:33]   reference phase level: 0
[1|2015-11-23T14:51:33]   variable module: "/var/handin_home/handin/handin-server/checker.rkt"
[1|2015-11-23T14:51:33]   variable phase: 0
[1|2015-11-23T14:51:33]   reference in module: "/var/handin_config/info1-teaching-material/checkers/checker-extras.rkt"
[1|2015-11-23T14:51:33]   in: submission-eval

Bigger log fragment available at https://gist.github.com/Blaisorblade/7f9c6e7f4f456b588a8a

Other info:
- Restarting the server does fix the error. Somehow.
- For those unfamiliar with the handin server: it has code which automatically reloads checkers, as
witnessed by the log above
But that code doesn't fix the problem.
- Googling suggests that stale compiled code might be there. But the source code hadn't changed. (Also, I
(Continue reading)

Lehi Toskin | 25 Nov 11:44 2015

current-text-keymap-initializer problems in v6.2.1

I've been messing around with GUI programming and I came across current-text-keymap-initializer which,
according to the documentation, may accept a procedure that itself takes a single parameter (a keymap%).

Now, I've tried to invoke this via
`(current-text-keymap-initializer (lambda (keymap) (void)))`
but then I get this error:

init-editor-keymap: arity mismatch;
 the expected number of arguments does not match the given number
  expected: 0
  given: 1

Okay, so I guess the procedure actually doesn't need a parameter.

`(current-text-keymap-initializer (λ () (void)))` also gives an error!

default-text-keymap-initializer: contract violation
  expected: (procedure-arity-includes/c 1)
  given: #<procedure>`

Now it's breaking contract because it expected a procedure that has a single parameter!

Is this a bug in the code or is this a bug in the documentation? Or both!


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+unsubscribe@...
(Continue reading)

thomas.lynch | 25 Nov 11:05 2015

error with no location and no traceback, with -l errotrace etc. - how do you get racket to say where?

Ok, here is a new one, but first a summary.

To summarize, I originally posted a number of racket error messages that had no backtrace, or no backtrace
nor location information.  So far, here is people have contributed as fixes, though unfortunately cases
remain (see below):

1. errortrace is in a library, and that must be included to get traces.
2. tail called functions, whether they are in recursion or not, are 
not in the function traceback 
3.  datum->syntax only affects the outer scope, but syntax instead and everything will have a syntax

For point 2, adding dummy code to the end of functions after tail calls will bring things back into the
function back trace.

For point 3 here, I had wondered if macros would be transparent, but it turns out they don't have to be.  Take
this example:

    (define-syntax (messup8 stx)
      (let* (
             [a 7]
             [b 8]
        (quasisyntax/loc stx
          (+ #,a #,b (^ 3 4))

    racket@...> (messup8)
    ^: undefined;
     cannot reference an identifier before its definition
(Continue reading)

Ryan Culpepper | 24 Nov 05:34 2015

Racket v6.3

Racket version 6.3 is now available from


- Racket's macro expander uses a new representation of binding called
   "set of scopes". The new binding model provides a simpler
   explanation of how macros preserve binding, especially across module
   boundaries and in hygiene-bending expansions. The new expander is
   mostly compatible with existing Racket macros, but there are some
   incompatibilities. For the formally inclined, a research paper on
   this macro system will appear at POPL next year:


- Racket's GUI library now uses Gtk+ 3 when available, instead of Gtk+
   2. Set the `PLT_GTK2` environment variable to select Gtk+ 2.

- Added a new Redex tutorial based on a week-long workshop in SLC.

- Better syntax error checking for Redex patterns that do not use
   holes correctly.

- The blueboxes are more agressive about finding names to look up in
   the docs, meaning they are useful much more often.

- Submodules are now fully supported in Typed Racket. Previously, some
   uses of submodules would produce internal errors, making it hard to
   `module+ test` and `module+ main` effectively in Typed Racket. The
   switch to the set-of-scopes expander fixed these problems, and
   submodules are now happily at home in Typed Racket.
(Continue reading)

Champignac | 22 Nov 17:04 2015

Unneeded console window when running a Racket Windows executable


I have created a small Windows application in Racket starting with:

#lang racket
(require racket/gui)
(define frame (new frame% 
                 ... etc

with a few controls.

I compile it in a distribution (to run on other machines) with DrRacket menu "Racket / Create executable".

The application runs fine showing the expected frame when I double-click on its executable.

However there is always a secondary window, a console window, popping up at the same time. I want to get rid of
this console window.

Any way to do that?


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+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.
Paolo Giarrusso | 21 Nov 12:51 2015

list? not in HtDP's BSL

list? is not available [1] in either BSL or BSL with list abbreviations. Why?
Lists are used everywhere even in BSL, and `list?` literally appears in half its documented contracts  in
beginner docs [2] — how should students understand them?

I've looked for reasons, to no avail. I've only learned that:
- unlike in Racket, the disjunction of `cons?` and `empty?` would be enough to redefine `list?`, since
improper lists are forbidden
- HtDP/2e doesn't mention `list?` in the chapter on lists [3], even though it comes after the chapter where
"sum types" (ahem, itemizations) are introduced.

[1] Racket rejects `(list? empty)` with "list?: this function is not defined"
[2] http://docs.racket-lang.org/htdp-langs/beginner.html
[3] http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/part_two.html
[4] http://www.ccs.neu.edu/home/matthias/HtDP2e/Draft/part_one.html


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+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.
thomas.lynch | 21 Nov 12:21 2015

quote-srcloc an questions of getting location

The example in the manual for quote-srcloc shows it wrapped as a syntax object, and it gives the correct call
point location answer.  however, when the result from quoteloc is instead put in a variable, then variable
has the wrong location (not the call location of stx).

An explanation of this behavior would shed a lot of light on this subject.

The objective here is to get a source/loc structure with call point from the stx passed into the syntax
transformer.  Is this what quote-srcloc is for?

  #lang racket

    (require racket/match)
    (require (for-syntax racket/match))

    (require syntax/location)
    (require (for-syntax syntax/location))

  (define-syntax (here stx) #`(quote-srcloc #,stx))

  (define-syntax (here2 stx) 
            [a-location (quote-srcloc stx)]
        (datum->syntax stx a-location)


(Continue reading)