Re: [racket-users] Annoying run-warnings in DrR 7.5: How to disable?

2020-01-24 Thread Jordan Johnson
On 24 Jan 2020, at 14:00, Robby Findler  wrote:
> In the preferences dialog, in the General tab, the last checkbox is
> the one you want.

The one for saving files upon switching tabs?

> But let me confirm: the reason it is painful to turn on the preference
> is that you have to choose a file?

Well, I hadn’t ever turned on the preference before, so I didn’t know whether 
it would necessitate choosing a file. But in answer to your question, no. See 
below.

> Would it work well for you if it
> only wanted to save files that already had filenames?

AFAICT now that I’ve turned on that preference, this is the behavior it has. It 
doesn’t prompt me to save an untitled file. And this is the behavior I would 
want, if DrR is saving upon tab-switching.

It feels weird to me to have DrR save files when I switch tabs; I’m somewhat 
trained to use the “modified” state as a marker that I’m in the middle of 
something, and “is everything saved?” is a part of my “am I done?” mental 
checklist when I’m working on multiple unrelated things in different tabs. I’ll 
have to impose a different discipline on myself (which may be for the best).

For now, I’ll try living with the preference enabled for a while. I don’t 
foresee doing any complicated work this spring, so it’s no big deal right now.

Thanks for the reply.

Cheers,
Jordan

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/2702DF36-1CB7-40F3-AF5D-3D0AABC8D395%40fellowhuman.com.


[racket-users] Annoying run-warnings in DrR 7.5: How to disable?

2020-01-24 Thread Jordan Johnson
Hi all,

One thing I’ve noticed is new in DrRacket 7.5 is the warning dialog that pops 
up upon hitting Run, saying
“The file  is not saved; save it before Run?”
where  may be in some other tab than the one that has focus.

This is annoying the heck out of me, as I usually tend to have at least one tab 
open that’s just for doing little experiments that aren’t worth saving. I can’t 
seem to find any relevant preference settings.

How do I disable these warnings?

Thanks,
Jordan

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/0A128CFA-BA1B-41AD-A9AB-843328DE267D%40fellowhuman.com.


[racket-users] Long-term substitute teaching post available at private school

2019-07-30 Thread Jordan Johnson
Dear Racket friends & teachers,

I’m taking a semester of leave from my teaching position at Kirby School in 
Santa Cruz, CA, and the school is looking for a part-time sub to cover my 
programming class, which I teach based on HtDP. This would be one period, 
Mondays/Wednesdays/Fridays — usually 50 min on M, 85 min on W/F. Small class 
size — I don’t know the exact number, but it’s fewer than 14 students. The 
semester starts mid-August and ends mid-December.

It’s a private school, so this doesn’t require a teaching credential if you 
know the subject well and can teach it.

If you are close enough to Santa Cruz and would want to teach part-time, please 
email me directly and I will put you in touch with the head of school. I won’t 
be checking this mailing list consistently, so please respond in a new email 
thread.

Cheers,
Jordan

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/B12F28CF-74EA-4EA3-924A-03DB65A90EB4%40fellowhuman.com.


Re: [racket-users] Editor task: finding end of code on line

2019-07-05 Thread Jordan Johnson
Thanks for the reply, Robby.

On Jul 2, 2019, at 19:11, Robby Findler  wrote:
> One note not related to what you ask: lines in editor<%> parlance are 
> soft-breaking; the methods about paragraphs are the ones you want.

For which specific purpose?

The method that c:e is bound to by default (end-of-line, IIRC — I’m on my 
phone) is a line method, not paragraph, right? I am (wrongly?) confident that 
it is the one I need to wrap for my new binding. When I tested it out in DrR 
with an editor that had some wrapped lines, c:e behaved as I’d expected: it 
jumps the cursor to the end of the row of characters the cursor is on, which is 
right before the actual newline iff the line isn’t wrapped. (However, I’ve only 
tried this with wrapping turned on.) Am I understanding correctly?

Does c:e have different behavior in editing Scribble or other less-schemey 
texts? I’ve been assuming it is totally language-agnostic.

Thanks again,
J

> Robby
> 
> 
>> On Tue, Jul 2, 2019 at 11:41 AM Jordan Johnson  wrote:
>> Dear Racket folks,
>> 
>> I’m trying to implement a keybinding to get me more familiar with the editor 
>> toolkit. I’m working on modifying the Ctrl+E keybinding so it behaves more 
>> like the Ctrl+A keybinding (which, once at the beginning of the line, 
>> toggles between the true beginning of the line and the beginning of 
>> non-whitespace text on the line). The behavior I want is (I think) outlined 
>> pretty well in the code below, but to be clear: if the cursor is already at 
>> the line end, I want Ctrl+E to make the cursor jump to (right after) the end 
>> of the last s-exp that ends to the left of the cursor on the present line if 
>> there is such a s-exp. (The cursor can stay put if there is no such s-exp.)
>> 
>> Here’s what I have so far:
>> 
>> ;;;
>> #lang s-exp framework/keybinding-lang
>>  
>> (require drracket/tool-lib)
>> 
>> (define (at-EOL? ed) ; text% -> Boolean, #true iff cursor is right before 
>> newline
>>   (define sp (send ed get-start-position))
>>   (= sp
>>  (send ed get-end-position)
>>  (send ed line-end-position (send ed find-line sp
>> 
>> (define (go-to-eol ed evt)
>>   (send (send ed get-keymap) call-function "end-of-line" ed evt #t))
>> 
>> (define (go-to-end-of-code-on-line ed) ;; text% -> void?
>>   ;; jump to the end of the code that is on the current line
>>   (void)) ;; TODO
>> 
>> (keybinding "c:e" (λ (ed evt)
>> (if (at-EOL? ed)
>> (go-to-end-of-code-on-line ed)
>> (go-to-eol ed evt
>> ;;;
>> 
>> Two questions for those of you who know the editor toolkit well:
>> Given what’s in the tool-lib, what’d be the best way to approach writing 
>> go-to-end-of-code-on-line? (I was thinking: save cursor position & line no; 
>> move left/backward by one s-exp; then move right/forward by one s-exp; then 
>> check if still on the same line, and if not restore the cursor position from 
>> before the moves.)
>> Does it look like I’m on the right track, otherwise?
>> 
>> Thanks,
>> Jordan
>> 
>> -- 
>> 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/641F6290-D258-4D8D-B774-CAF5D9327204%40fellowhuman.com.
>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAL3TdOO-1u_25gOUGjhQXdWii4jkyub9F1PfWH6wZ0kG%2BEtp%3Dw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/557A65BF-F4F8-445F-B567-91E0CAD8C3EF%40fellowhuman.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Editor task: finding end of code on line

2019-07-02 Thread Jordan Johnson
Dear Racket folks,

I’m trying to implement a keybinding to get me more familiar with the editor 
toolkit. I’m working on modifying the Ctrl+E keybinding so it behaves more like 
the Ctrl+A keybinding (which, once at the beginning of the line, toggles 
between the true beginning of the line and the beginning of non-whitespace text 
on the line). The behavior I want is (I think) outlined pretty well in the code 
below, but to be clear: if the cursor is already at the line end, I want Ctrl+E 
to make the cursor jump to (right after) the end of the last s-exp that ends to 
the left of the cursor on the present line if there is such a s-exp. (The 
cursor can stay put if there is no such s-exp.)

Here’s what I have so far:

;;;
#lang s-exp framework/keybinding-lang
 
(require drracket/tool-lib)

(define (at-EOL? ed) ; text% -> Boolean, #true iff cursor is right before 
newline
  (define sp (send ed get-start-position))
  (= sp
 (send ed get-end-position)
 (send ed line-end-position (send ed find-line sp

(define (go-to-eol ed evt)
  (send (send ed get-keymap) call-function "end-of-line" ed evt #t))

(define (go-to-end-of-code-on-line ed) ;; text% -> void?
  ;; jump to the end of the code that is on the current line
  (void)) ;; TODO

(keybinding "c:e" (λ (ed evt)
(if (at-EOL? ed)
(go-to-end-of-code-on-line ed)
(go-to-eol ed evt
;;;

Two questions for those of you who know the editor toolkit well:
Given what’s in the tool-lib, what’d be the best way to approach writing 
go-to-end-of-code-on-line? (I was thinking: save cursor position & line no; 
move left/backward by one s-exp; then move right/forward by one s-exp; then 
check if still on the same line, and if not restore the cursor position from 
before the moves.)
Does it look like I’m on the right track, otherwise?

Thanks,
Jordan

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/641F6290-D258-4D8D-B774-CAF5D9327204%40fellowhuman.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] bugs.racket-lang.org down?

2019-05-08 Thread Jordan Johnson
On 8 May 2019, at 11:53, Sam Tobin-Hochstadt  wrote:
> bugs.racket-lang.org was hosted on a server at Northeastern, which
> died recently (this resulted in a number of other problems as well).
> While we will bring back that data, I would encourage you to submit
> bugs at https://github.com/racket/racket/issues/new.

Since you say “bring back that data”, I wonder: should the “Submit Bug Report” 
menu item in DrRacket now launch that URL you’ve given rather than bring up the 
little DrRacket bug report window?

Best,
Jordan

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/6FB4B2C1-41A0-4EAB-ABAE-E67B606BA0D4%40fellowhuman.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] bugs.racket-lang.org down?

2019-05-08 Thread Jordan Johnson
Hi all,

I’m unsuccessful in connecting to bugs.racket-lang.org, and 
downforeveryoneorjustme.com also reports it being down. Is the web server there 
not running for some reason?

Best,
Jordan

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ED6E726A-3884-4E9E-8902-525B0EE8335E%40fellowhuman.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] 2htdp/image: Alpha blending

2019-04-26 Thread Jordan Johnson
Hi all,

The docs for image->color-list say:

> The list of colors is obtained by drawing the image on a white background and 
> then reading off the colors of the pixels that were drawn.


According to that description, if I evaluate...

> (first (image->color-list (square 2 'solid (make-color 255 50 50 100


...I would expect to get a color that is slightly lighter than the given 
(make-color 255 50 50 100), because my somewhat transparent image is being 
drawn onto a white background.

But no, instead I get (make-color 255 48 48 100) ...which is darker than the 
color I started with.

What am I misunderstanding?

Thanks,
Jordan

-- 
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] How do you make students submit programming assignments online for automatic tests?

2019-02-21 Thread Jordan Johnson
On Feb 20, 2019, at 10:40, 'John Clements' via Racket Users 
 wrote:
> One solution would be to use the command-line version of Racket’s 
> handin-server, which is language-agnostic to the degree that it can just 
> submit arbitrary files to the server, and what happens on the back end is up 
> to you
> 
> I look forward to hearing about anything awesome that others use.

I’ve been working on making the handin server fit the way I think about things, 
and I’m hoping to get my code to the point where “awesome” would be a 
reasonable descriptor.

Here’s a sketch of the core ideas.

1) I want to be able to code up a solution for each assignment I write, and use 
the solution file in assessing student work. My students’ work is in *SL, so I 
want to write my solutions in that language as well. I have a library that 
provides macros check-expect*, check-within*, etc; they expand to check-expect 
& co for use on my own code, but they also get collected as tests to run on 
student submissions. The library makes my solution file provide a handle on 
these tests, so I can just require my solution file from the checker.

2) I want automated checking that the student has defined all the 
functions/constants that I’ve explicitly named in the assignment, and I do this 
via a students-must-define macro that the solution library provides; again, my 
resulting assignment solution file then provides a handle on the required names.

I'm satisfied that the above two points are clear wins, at least for me; the 
interface is comfortable to work with.

3) I use the web-server/templates library to generate a partially-filled rubric 
based on the solution file. For each assignment I include a rubric (.txt file) 
in the assignment directory for this purpose.

4) I want the code that actually resides in checker.rkt to be about how to 
respond to student code passing or failing the desiderata I’ve set out in the 
solution file, rather than about what the student should  define and what tests 
should run.

I also want to incorporate some cosmetic checks (like indentation) but haven’t 
gotten around to it yet.

My motivation in all this is that the convenience of submitting from DrR is 
great, but I’ve found it hard to write checkers that yield good UX for students 
whose work is imperfect. The typical failure mode is that errors are raised and 
handin fails; I generally would rather accept the handin and log its 
shortcomings in the rubric, and sometimes also give the student a notification 
(like, “hey, please break your long lines and re-submit”).

Longer term I’d like to come up with something to serve as an instructor 
dashboard, with an aggregate display of features like who left what function 
undefined, and what tests were failed by multiple students’ code.

If I get to a point where I’m satisfied that the end product is useful enough 
to warrant sharing, I’ll write it all up and share the code. If anybody wants 
to collaborate I’d be happy to discuss and share off-list.

Best,
J

-- 
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] Finding the right font%

2019-02-14 Thread Jordan Johnson
Ok, thanks for the replies! —Jordan

> On Feb 14, 2019, at 07:57, Matthew Flatt  wrote:
> 
> I have noticed that some fonts I used to use became inaccessible on Mac
> OS in v7.0, which is when we upgraded Pango. In my case, the relevant
> change seems to be that Pango became better at tracking which Mac OS
> faces are condensed, and it insists on condensed or not matching
> exactly when you request a face. I've made face selection more flexible
> by allowing match of a condensed face for a non-condensed request and
> vice versa, although an exact match is preferred.
> 
> While investigating, I noticed that `(get-face-list #:all-variants?
> #t)` didn't work as intended, because it used the wrong part of the
> Pango API and produced names that cannot be parsed by Pango. I pushed a
> repair for that problem, so hopefully `(get-face-list #:all-variants?
> #t)` will now produce strings that let you get more faces.
> 
> At Mon, 11 Feb 2019 12:20:14 +0100, Jens Axel Søgaard wrote:
>> Den man. 11. feb. 2019 kl. 02.58 skrev Robby Findler <
>> ro...@eecs.northwestern.edu>:
>> 
>>> I confess to not understanding the details here either but i have had to
>>> put the appropriate weighting or italic to get the face name to show up in
>>> some cases.
>>> 
>> 
>> Ditto. FWIW the issue reminds of a recent (2017) change in how macOS
>> handles fonts.
>> Maybe macOS changed the way it reports font names?
>> 
>> http://dessci.com/en/support/mathtype/tsn/tsn176.htm
>> 
>> /Jens Axel
>> 
>> -- 
>> 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.
> 

-- 
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.


[racket-users] Finding the right font%

2019-02-10 Thread Jordan Johnson
Hi all,

I’m using a typeface (Espinosa Nova 
) comprised of twelve 
distinct fonts. When I use the pict or 2htdp/image library to create an image 
of some text — e.g.,

> (text "Foo bar!" 24 "Espinosa Nova") ; pict lib


— Racket gives me the special font that’s intended for drop caps, not the 
default text font (which is called “Regular” in the OSX Font Book app and other 
apps). (The drop-cap variant is the one that shows up first in all other apps’ 
font lists, but every app but Racket still gives me the correct “Regular” 
variant by default.)

Being more explicit doesn’t help:

> (text "Foo bar!" 24 "Espinosa Nova, Regular")


This still gives me the drop-cap variant. However, AFAICT Racket is recognizing 
the strings as representing two distinct fonts:

> > (send the-font-name-directory find-or-create-font-id "Espinosa Nova" 
> > 'default)
> 11
> > (send the-font-name-directory find-or-create-font-id "Espinosa Nova, 
> > Regular" 'default)
> 13


Different IDs, same font appearance, neither of them being the “regular” font.

Is there a reliable way to relate the font names I see in (e.g.) Font Book to 
the names Racket uses?

Is there a way (based on the-font-list or the-font-name-directory, for example) 
to browse the list of installed font names in Racket (to try and identify the 
magic words Racket needs in order to give me the font% I want)?

Thanks,
Jordan

-- 
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] Some concern about ChezScheme...

2019-02-08 Thread Jordan Johnson
On Feb 6, 2019, at 11:28, Matthias Felleisen  wrote:
> On Feb 6, 2019, at 2:22 PM, 'Paulo Matos' via Racket Users 
>  wrote:
>> Interestingly according to Matt these ideas were already floating around at 
>> his uni as early as 98?
> My recollection is that Kent taught with this approach because it simplified 
> homeworks for students and graders and I encouraged him to write it up for 
> the “education pearl” section that I launched for JFP in ’03. 

When I took Kent’s compilers class (which would’ve been around ’98 or ’99), 
which he co-taught with Dan Friedman, they were in the early-ish stages of 
exploring the idea; it might have been the first year of implementation, and I 
don’t doubt it helped the graders since the class was fairly large. I can say 
from a student perspective, it was really helpful for understanding what was 
going on: each pass had one very specific purpose — a few maybe had two, but 
almost all passes were straightforward on their own. By the end of the semester 
we had a Scheme-to-Sparc-ASM compiler written in about 36 passes.

At the time, the only special tooling we had was a form of match that had a 
shorthand for “recur and bind variable(s) to the result(s)”, so we had to write 
all the just-copy-the-AST branches of our recursion manually. A big chunk of 
the work in implementing nanopass was setting up a language-definition 
framework that’d allow the copying code to be generated.

Cheers,
Jordan

-- 
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.


[racket-users] SXML/SXPath: selecting a node, keeping small subset of children

2019-02-08 Thread Jordan Johnson
Hi all,

Is there an idiom in SXPath/SXSLT for selecting a node and keeping only a small 
subset of its children by name?

E.g., if, somewhere in my document, I have



...50 other elements...

...
...more elements...


(where the child elements may be in any order), is there a brief way to specify 
that I want every foo, but with only its bar, baz, and qux child elements 
attached in the result? If so, how?

Presently I’m just using SXPath to get hold of the foo, then using match with 
list-no-order to get only the elements I want. I’m wondering if there’s a way 
to skip the match with better XML-fu.

Thanks,
Jordan

-- 
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] Making evaluators / handin server setup

2019-01-12 Thread Jordan Johnson
Hi Matthew et al.,

Following up some work from last fall:

On Oct 6, 2018, at 15:58, Matthew Flatt  wrote:
> At Wed, 26 Sep 2018 15:57:12 -0700, Jordan Johnson wrote:
>>> (require racket/sandbox)
>>> (make-evaluator "beginner-lang.rkt")
>> . . ../../../../../../../../Applications/Racket 
>> v7.0/collects/racket/private/kw-file.rkt:102:2: open-input-file: `read' 
>> access 
>> denied for /Users/jteach/Library/Racket/7.0/pkgs/.LOCKpkgs.rktd
> 
> That was a problem with creating a sandbox in DrRacket, as opposed to
> `racket` at the command line or with the handin server. It's fixed for
> the next release.

Having downloaded Racket 7.1, I’m playing with evaluator-related code again 
(for the first time since October), and now am seeing this behavior in DrRacket:

> > (require racket/sandbox)
> > (define e (make-evaluator 'lang/htdp-beginner))
> . . ../../Applications/Racket v7.1/collects/pkg/private/lock.rkt:26:0: 
> directory-exists?: `exists' access denied for /Applications/Racket 
> v7.1/share/pkgs
> > 

Command-line `racket’ doesn’t exhibit this problem; it just creates the 
evaluator and lets me run with it. This is on Mac OS X (High Sierra, 10.13.4).

I’m posting here in case it’s the same as (or related to) the bug Matthew 
mentioned, meaning the bug wasn’t completely squashed the first time around. Is 
there another likely possibility I’m missing? Is there something more I can do 
to help diagnose what’s going on?

Thanks,
Jordan

-- 
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] handin-server: reader used in checker modules

2018-10-17 Thread Jordan Johnson
> On Oct 17, 2018, at 11:30, Shu-Hung You  > wrote:
>> 
>> Would it help if in the check module you use `=' as the equality test,
>> or specify #e10.25 instead?
> 
> Success!
> 
> Specifying
> (!test (hour-angle 12 20 30) #e10.25)
> produces the behavior I expected, correctly comparing the numbers.

Ehh, I spoke too soon. The analagous student test —
(check-expect (hour-angle 12 20 30) 10.25)
— fails when included in the handin submission.

My working hypothesis is that I just need to configure the handin server’s 
evaluator to have (read-decimal-as-inexact #f). I’m trying to work out how to 
do that from the (check: ...) form, and failing that, will manually create & 
configure the evaluator.

If you can tell me how to do that — or tell me if I’m wrong — I’d much 
appreciate the saved time. But I do expect it’s a problem I can solve on my own 
with enough time.

Thanks,
Jordan


-- 
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] handin-server: reader used in checker modules

2018-10-17 Thread Jordan Johnson
On Oct 17, 2018, at 11:30, Shu-Hung You  
wrote:
> 
> Would it help if in the check module you use `=' as the equality test,
> or specify #e10.25 instead?

Success!

Specifying
(!test (hour-angle 12 20 30) #e10.25)
produces the behavior I expected, correctly comparing the numbers.

Thanks, all!

Best,
Jordan

-- 
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] handin-server: reader used in checker modules

2018-10-17 Thread Jordan Johnson
>> So, what aspect of the language config would be responsible for 41/4 not 
>> equaling 10.25?
> 
> Welcome to Racket v7.0.0.20.
>> (= 41/4 10.25)
> #t
>> (read-decimal-as-inexact #f)
>> (= 41/4 10.25)
> #t
> 
> Do you perhaps print and read the result? 

Nope. The code that’s generating the error is

(check: :language 'lang/htdp-intermediate
...
(!test (hour-angle 12 20 30) 10.25)
...)

I’m looking into !test now; I don’t yet know how it does its comparison.

jmj

-- 
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] handin-server: reader used in checker modules

2018-10-17 Thread Jordan Johnson

> On Oct 17, 2018, at 10:35, Matthias Felleisen  wrote:
>>  (check-expect (+ 10 .25) 10.25)
>> 
>> errors with check-expect’s message about not comparing inexact numbers, but 
>> in DrRacket+BSL the decimals are treated as exact numbers.
>> 
>> What do I need to change in the checker, in order to obtain the same numeric 
>> behavior as in DrRacket?
> Set read-decimal-as-inexact might solve the problem. 

Progress! But not completely solved. By adding 
(read-decimal-as-inexact #f)
to the checker module, I now don’t get the check-expect error. Instead, I’m 
seeing
submit error: your code failed a test: (hour-angle 12 20 30) evaluated to 41/4, 
expecting 10.25

produced by the checker line
(!test (hour-angle 12 20 30) 10.25)
where hour-angle computes exactly.

So, what aspect of the language config would be responsible for 41/4 not 
equaling 10.25?

Best,
Jordan

-- 
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.


[racket-users] handin-server: reader used in checker modules

2018-10-17 Thread Jordan Johnson
Hi all,

In my last thread regarding the handin server, Matthew suggested:
> A workaround is to use `'lang/htdp-beginner` as the language instead of
> `'(special beginner)`. That happens to avoid a redundant and
> troublemaking `require`.

So, I’m using 'lang/htdp-beginner in an assignment’s checker.rkt file, and I am 
seeing errors that appear to be the result of the handin server using a 
different reader (or configuration thereof) than DrRacket does for BSL. 
Specifically,

(check-expect (+ 10 .25) 10.25)

errors with check-expect’s message about not comparing inexact numbers, but in 
DrRacket+BSL the decimals are treated as exact numbers.

What do I need to change in the checker, in order to obtain the same numeric 
behavior as in DrRacket?

Thanks,
Jordan

-- 
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.


[racket-users] Making evaluators / handin server setup

2018-09-26 Thread Jordan Johnson
Dear Racketeers,

I’m writing about difficulties using make-evaluator in Racket v7.0 with a 
module that selectively (or not) re-exports bindings from an existing language. 
This is related to work I’m doing with the handin server.

- the short version -

Create this file, and use as follows:

; beginner-lang.rkt ;

#lang racket

(require lang/htdp-beginner)
(provide (all-from-out lang/htdp-beginner))

; Interactions, launched from the same directory: ;

> (require racket/sandbox)
> (make-evaluator "beginner-lang.rkt")
. . ../../../../../../../../Applications/Racket 
v7.0/collects/racket/private/kw-file.rkt:102:2: open-input-file: `read' access 
denied for /Users/jteach/Library/Racket/7.0/pkgs/.LOCKpkgs.rktd

; end code ;

Q: Can you tell me why I’m seeing this behavior?

- the longer version, with context -

After a couple years of just having my small classes email me their work, I’m 
trying the handin server again. For the next assignment, students are writing 
BSL code that uses 2htdp/image and the animate function from 2htdp/universe. 
Their code also uses bitmap/url to load an image I provided via the class 
website.

In doing a trial run of submitting my test solutions, I found my checker.rkt 
signaling errors from the check: form: Using :language '(special 
htdp-beginner), I get an error from the student’s (require 2htdp/image) line, 
saying that image? is being imported twice.

Q: How do I make the import “just work”, as it ordinarily does in DrRacket?

Going further, I’ve kludged together a wrapper lib that imports all the needed 
functions while taking care to remove clashes, at which point I got the odd 
read-access error above. Here’s that code:

; img.rkt ;

#lang racket

(require racket/require) ; for subtract-in

(require (combine-in [except-in lang/htdp-beginner require image?]
 [subtract-in [except-in 2htdp/image bitmap/url]
  lang/htdp-beginner]))
 
(provide (all-from-out lang/htdp-beginner)
 (all-from-out 2htdp/image)
 bitmap/url
 animate
 (rename-out [%require require]))

(define-syntax-rule (%require . blahblah) (void)) ; ignore student's requires

(define (animate _) (void)) ; ignore student's calls to animate from universe

(define (bitmap/url url) ; replace bitmap/url with something harmless
  (rectangle 50 35 'solid 'lavender))

; end img.rkt; I am using it in checker.rkt as follows: ;

(check: :language "../../img.rkt"  ; escape to assignment base dir
...)

; end ;

This approach works for now, but seems like an ungainly way to do it, and I’ll 
be surprised if this level of manual disambiguation is what everybody’s been 
doing for years. Is there a more elegant way?

Best,
Jordan

-- 
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] Strange window behavior in OSX Yosemite DrRacket

2018-01-25 Thread Jordan Johnson
Thanks for the suggestions, guys. Glad to hear it’s a known-and-fixed bug.

We’ll poke at it when we’re back in the lab tomorrow, and if we can’t resolve 
it I’ll follow up with another query here.

Thanks again,
jmj

> On Jan 25, 2018, at 11:42, Robby Findler  wrote:
> 
> This double contour thing is a bug that has been fixed, but the fix wasn't in 
> the last release.
> 
> If you first quit DrRacket and then open an older version of DrRacket and 
> disable the contour, then the doubled thing will go away in the new version.
> 
> Robby
> 
> 
> On Thu, Jan 25, 2018 at 11:38 AM, Philip McGrath  <mailto:phi...@philipmcgrath.com>> wrote:
> In case it's relevant, I recently tried using text:inline-overview-mixin <> 
> for the first time in the hope that it would give me something like Program 
> Contour in DrRacket, and instead it did something very similar to the second 
> screenshot (using Racket 6.11 on Mac OS 10.13.2):
> 
> 
> ​
> 
> -Philip
> 
> On Thu, Jan 25, 2018 at 11:10 AM, 'John Clements' via Racket Users 
> mailto:racket-users@googlegroups.com>> wrote:
> 
> 
> > On Jan 25, 2018, at 8:48 AM, Jordan Johnson  > <mailto:j...@fellowhuman.com>> wrote:
> >
> > Hi all,
> >
> > One of my students is observing some strange behavior involving the Program 
> > Contour pane of DrRacket. He’s using v6.11 on OS X Yosemite 10.10.5.
> >
> > This is the top-right corner of his DrR window, with Program Contour open:
> > 
> >
> > Upon pressing Cmd+U to hide it, this is what happens:
> > 
> >
> > Additionally, the previous day he’d found that (with the Contour pane open) 
> > DrR was flickering while he typed, and (when I suggested closing the 
> > Contour pane to see if it was slowing down the window redraws) pressing 
> > Cmd+U or selecting the “Hide Program Contour” menu item did not hide the 
> > Contour pane.
> >
> > Any ideas of what we could do to diagnose this problem?
> 
> I believe the behavior of the contour window has changed recently, and I 
> conjecture that both mechanisms might still be implemented; would it help to 
> edit or remove the preferences file? I believe that you’ll find them in 
> ~/Library/Preferences/, and there are two:
> 
> org.racket-lang.DrRacket.plist
> org.racket-lang.prefs.rktd
> 
> I’m guessing the first is the one that would be relevant.
> 
> Just a thought,
> 
> John Clements
> 
> 
> 
> --
> 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 
> <mailto:racket-users%2bunsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> 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 
> <mailto:racket-users+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 

-- 
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.


[racket-users] Strange window behavior in OSX Yosemite DrRacket

2018-01-25 Thread Jordan Johnson
Hi all,

One of my students is observing some strange behavior involving the Program 
Contour pane of DrRacket. He’s using v6.11 on OS X Yosemite 10.10.5.

This is the top-right corner of his DrR window, with Program Contour open:


Upon pressing Cmd+U to hide it, this is what happens:


Additionally, the previous day he’d found that (with the Contour pane open) DrR 
was flickering while he typed, and (when I suggested closing the Contour pane 
to see if it was slowing down the window redraws) pressing Cmd+U or selecting 
the “Hide Program Contour” menu item did not hide the Contour pane.

Any ideas of what we could do to diagnose this problem?

Thanks,
Jordan

-- 
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] 2htdp/universe: behavior of dual shift keys

2017-12-19 Thread Jordan Johnson
Thanks, Alex.

A little more digging, and here’s some more info; I’m hoping this will be 
enough for the maintainers of 2htdp/universe to track down what’s going on.

In 2htdp/private/check-aux.rkt in the htdp-lib package, I opened a REPL and ran 
this code:
> (require racket/gui)
> (define f
(let ([es (make-eventspace)])
  (parameterize ([current-eventspace es])
(new (class frame%
   (define/override (on-subwindow-char r e)
 (define ps (key-event->parts e))
 (if (equal? ps "release")
   (printf "released ~a~%" (key-release->parts e))
   (printf "pressed ~a~%" ps)))
   (super-new))
 [label "foo"]
> (define p (new panel%
 [parent f]
 [min-width 200]
 [min-height 100]))
> (send f show #t)

Then, with focus on the frame I created, I:
held left-shift
held right-shift
released right-shift
released left-shift

This triggered the messages:
pressed shift
pressed rshift
pressed rshift
released shift

I wrote the above class definition as I did, because I see that 2htdp/world.rkt 
uses that technique (checking the output of key-event->parts) to tell if it’s 
got a key release. What I’ve observed is that if one shift key is released 
while the other is held down, the key event's get-key-code method is producing 
the symbol 'shift or 'rshift, not 'release as the universe library expects.

So it appears that this is a bug originating down where the key-event% is being 
instantiated in the MrEd library layer, which is a bit beyond the depth I can 
troubleshoot in the time I have. I’ve created an issue on Github 
, and will leave it at that.

Hope this helps.

Regards,
Jordan


> On Dec 17, 2017, at 18:45, Alex Harsanyi  wrote:
> 
> I tested this on a Windows platform and have the same result. It seems there 
> is a problem in Racket with handling the right shift key: pressing down the 
> right shift key results in "keydown" being invoked with a "rshift" argument, 
> but releasing the right shift key results in "keyup" being called with a 
> "shift" argument (instead of "rshift")
> 
> Best Regards,
> Alex.
> 
> -- 
> 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 
> .

-- 
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.


[racket-users] 2htdp/universe: behavior of dual shift keys

2017-12-17 Thread Jordan Johnson
Hi all,

The attached program exhibits some odd behavior in 2htdp/universe, and I want 
to track down where it’s coming from. AFAICT it’s not an error in the program 
itself, but if I’m mistaken I’d be pleased to have confirmation that the cause 
isn’t in the OS or the 2htdp/universe library.

Here’s how to reproduce the behavior I’m seeing, which is on OS X 10.11.6:

1. Run the program
2. Hold down one of the two Shift keys
3. Hold down the other Shift key
4. Release one of the keys
5. Release the other key

Expected behavior: After step 4, one of the keys reverts to its #false state; 
after step 5, both are #false.

Actual behavior: Step 4 does not provoke a change in the program’s state. After 
step 5, the last-released key reverts to #false.

Does this occur on other platforms or other verions of OS X? Do you see a 
problem I’m missing in the program?

Thanks,
Jordan

-- 
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.


tracking keypresses.rkt
Description: Binary data


Re: [racket-users] DrRacket (6.11) issue on Windows 10

2017-11-13 Thread Jordan Johnson
There’s also (Windows key)+(left/right arrow), which will move the window to 
the left/right half of the current display, and (Windows key)+Shift+(left/right 
arrow), which cycles it to the previous or next display (in case, e.g., the 
window is on a different display because the student had the laptop connected 
to an external monitor).

Jordan

> On Nov 13, 2017, at 1:10 PM, George Neuner  wrote:
> 
> Hi David,
> 
>> On 11/13/2017 3:14 PM, David Van Horn wrote:
>> I have a student who is has a strange problem that is preventing him
>> from using DrRacket.
>> 
>> When he opens DrRacket, it goes through the launch window, all the
>> tools load, etc., but then when the main DrRacket window should
>> appear, it doesn't.  Or rather it does, but not somewhere visible or
>> accessible.
>> 
>> There's a DrRacket icon on the taskbar, indicating it's running, and
>> if you hover over it, it shows a preview of the DrRacket window, but
>> clicking on it does not bring it up.
>> 
>> If he opens a saved file from the filesystem, you can see in the
>> preview that the file has been opened in the inaccessbile DrRacket
>> window.
>> 
>> He's tried restarting, uninstalling/reinstalling Racket, but gets the
>> same issue.
>> 
>> Any ideas how to resolve this?  (Sorry I haven't used Windows in many
>> years, so I really don't know how to help.)
>> 
>> David
> 
> I've seen this behavior before - though not for a very long time.  It used to 
> happen rather frequently in Win3 and Win9x.
> 
> If the window is there but simply off the screen, you can try (emphasis on 
> "try") to move it back on screen.  
> first, make sure DrRacket is the only application open.
> select the task bar icon to make sure you are in the window. 
> press ALT-Space to open the window's system menu. 
> press the down arrow once to select "move".
> press enter to start the move operation.
> press the right arrow and down arrow a couple of times each.
> At this point ... if it is going to work ... you should see (at least) the 
> outline of the window at the upper left corner of the screen (whether you see 
> any content depends on Windows user preferences).  Once you see the outline, 
> you should then be able to move the mouse (don't press any buttons) and the 
> window's outline should follow where the mouse is pointing.
> Once you get the window's title bar on screen, you can fix the size and 
> position - and hopefully it won't happen again for a while.
> 
> If this doesn't help, then I'm out of ideas.
> George
> 
> -- 
> 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.

-- 
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] Connecting a language and its reader

2017-10-01 Thread Jordan Johnson
Ok. Thanks, Philip! —jmj

> On Oct 1, 2017, at 5:04 PM, Philip McGrath  wrote:
> 
> Using `mylang/semantics` will work as long as you have the `mylang` 
> collection installed, which is necessary for `#lang` to work anyway.
> 
> In cases when it is sensible to use your new language without the custom 
> reader (e.g. for languages which don't have a custom reader), it is often 
> pleasant to have the name of the language be the same regardless of whether 
> the programmer writes `#lang mylang` or `(module some-module mylang body 
> ...)`. This can be accomplished by putting the contents of your current 
> "semantics.rkt" in "main.rkt" and then giving "main.rkt" a reader submodule 
> that refers to the enclosing module, e.g. `(module reader 
> syntax/module-reader mylang)`. Whether or not this makes sense depends, of 
> course, on the particulars of the language you're defining.
> 
> -Philip
> 
>> On Sun, Oct 1, 2017 at 2:50 PM, Jordan Johnson  wrote:
>> Hi all,
>> 
>> I’ve been putting together a little language to learn more about how the 
>> Racket #lang ecosystem works, and I’m hung up on bundling up the language as 
>> a collection. I’m not sure I correctly understand the point where the reader 
>> attaches to the macros that specify how to expand the language forms, and I 
>> want to check.
>> 
>> So, say I have a file semantics.rkt (in mylang/, the main dir of the 
>> collection) defining the macros that make up the language, and a reader 
>> lang/reader.rkt (in the same dir):
>> #lang s-exp syntax/module-reader
>> "../semantics.rkt"
>> #:read my-read
>> #:read-syntax my-read-syntax
>> 
>> (require "lang/parser.rkt" syntax/strip-context)
>> ;; ...simple defs of my-read and my-read-syntax...
>> 
>> This much works. My question is how to attach the semantics.rkt file to my 
>> reader code correctly if I don’t use syntax/module-reader. If that’s not 
>> clear enough, a more detailed description of the problem follows.
>> 
>> Following the “Installing a Language” section in the Racket Guide, I moved 
>> this reader code into a main.rkt file in the main dir of the collection 
>> (call it mylang/):
>> (module reader racket
>>   (require "lang/parser.rkt" syntax/strip-context)
>>  
>>   (provide (rename-out [my-read read]
>>[my-read-syntax read-syntax]))
>>  
>>   (define (my-read in) (syntax->datum (my-read-syntax #f in)))
>> 
>>   (define (my-read-syntax src in)
>> (with-syntax ([(program-part ...) (parse-program-file src in)])
>>   (strip-context
>>#'(module IGNORE "semantics.rkt"
>>program-part ...)
>> 
>> I can then write
>>  #lang mylang
>> in another file, and it works as expected iff the file I’m loading is in the 
>> mylang/ directory as well, failing otherwise with an error like this:
>> /path/to/mylang/main.rkt:17:24: cannot open module file
>>   module path: #
>>   path: /tmp/semantics.rkt
>> 
>> The module language spec I’ve highlighted in red seems brittle; because 
>> Racket’s looking for semantics.rkt in the directory of the file containing 
>> #lang mylang and not mylang/, I’ve been assuming that’s where the problem 
>> is. Correct me if I’m wrong in this understanding: the #'(module ...) is 
>> effectively replacing the body of whatever program is written in #lang 
>> mylang, so the path-string "semantics.rkt" must be interpreted relative to 
>> that program’s source file.
>> 
>> Anyway, the solution I found is to replace "semantics.rkt" with 
>> mylang/semantics, but that seems like it might be brittle as well; is that 
>> the right way, though? If not, how should I be specifying the connection to 
>> the macros?
>> 
>> Thanks,
>> Jordan
>> 
>> -- 
>> 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.
> 

-- 
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.


[racket-users] Connecting a language and its reader

2017-10-01 Thread Jordan Johnson
Hi all,

I’ve been putting together a little language to learn more about how the Racket 
#lang ecosystem works, and I’m hung up on bundling up the language as a 
collection. I’m not sure I correctly understand the point where the reader 
attaches to the macros that specify how to expand the language forms, and I 
want to check.

So, say I have a file semantics.rkt (in mylang/, the main dir of the 
collection) defining the macros that make up the language, and a reader 
lang/reader.rkt (in the same dir):
#lang s-exp syntax/module-reader
"../semantics.rkt"
#:read my-read
#:read-syntax my-read-syntax

(require "lang/parser.rkt" syntax/strip-context)
;; ...simple defs of my-read and my-read-syntax...

This much works. My question is how to attach the semantics.rkt file to my 
reader code correctly if I don’t use syntax/module-reader. If that’s not clear 
enough, a more detailed description of the problem follows.

Following the “Installing a Language 
” 
section in the Racket Guide, I moved this reader code into a main.rkt file in 
the main dir of the collection (call it mylang/):
(module reader racket
  (require "lang/parser.rkt" syntax/strip-context)
 
  (provide (rename-out [my-read read]
   [my-read-syntax read-syntax]))
 
  (define (my-read in) (syntax->datum (my-read-syntax #f in)))

  (define (my-read-syntax src in)
(with-syntax ([(program-part ...) (parse-program-file src in)])
  (strip-context
   #'(module IGNORE "semantics.rkt"
   program-part ...)

I can then write
#lang mylang
in another file, and it works as expected iff the file I’m loading is in the 
mylang/ directory as well, failing otherwise with an error like this:
/path/to/mylang/main.rkt:17:24: cannot open module file
  module path: #
  path: /tmp/semantics.rkt

The module language spec I’ve highlighted in red seems brittle; because 
Racket’s looking for semantics.rkt in the directory of the file containing 
#lang mylang and not mylang/, I’ve been assuming that’s where the problem is. 
Correct me if I’m wrong in this understanding: the #'(module ...) is 
effectively replacing the body of whatever program is written in #lang mylang, 
so the path-string "semantics.rkt" must be interpreted relative to that 
program’s source file.

Anyway, the solution I found is to replace "semantics.rkt" with 
mylang/semantics, but that seems like it might be brittle as well; is that the 
right way, though? If not, how should I be specifying the connection to the 
macros?

Thanks,
Jordan

-- 
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] document as fn from strings to HTML/text

2017-09-28 Thread Jordan Johnson
Fantastic. Thank you, Neil & Ben.

Regards,
Jordan

> On Sep 28, 2017, at 11:09, Neil Van Dyke  wrote:
> 
> If you don't care whether you edit in HTML syntax, and you'd like a slightly 
> more programming-ish interface, there's also: 
> http://www.neilvandyke.org/racket/html-template/
> 
> -- 
> 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.

-- 
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.


[racket-users] document as fn from strings to HTML/text

2017-09-28 Thread Jordan Johnson
Hi all,

Problem: I want to generate many documents from a source template (of which 
only a few small parts change, from doc to doc) and many groups of values. 
Ideally I’d like to be able to write files like this:

*** template ***
...

  @(for/list ([item my-list]) (li item))

...


*** list source file A ***
this is item 1A
this is item 2A

*** list source file B ***
this is item 1B
this is item 2B

*** end ***

(I’m simplifying — among other things, multiple variables/lists are involved, 
and there’s some sorting/filtering of the lists — but that’s the crux of it.) 
Essentially, the template is a function from the list my-list to a document. 
Implicit in the above examples is the idea that I should somehow be able to do 
an equivalent of

(require "my-template-file")
(my-template '("this is item 1A" "this is item 2A”))

Can I use some part of the Scribble ecosystem to accomplish this, or am I 
barking up the wrong tree here?

Thanks,
Jordan

-- 
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.


[racket-users] table lookup shorthands?

2017-08-06 Thread Jordan Johnson
Hi all,

I’m writing some music-related code for which I find myself using a lot of 
lookup tables, following the pattern of making an alist or hash table and then 
writing a function that consults the table. I wound up writing a macro for this 
pattern; one example of its use is:

;; key->fifths : PitchName -> Int[-7..7]
;; tells how many perfect fifths above C the given pitch is (and
;; therefore how many sharps or flats its key signature has)
(define-lookup-function key->fifths
  [C 0] [G 1] [D 2] [A 3] [E 4] [B 5]
  [F# 6] [F♯ 6]
  [C# 7] [C♯ 7]
  [F -1]
  [Bb -2] [Eb -3] [Ab -4] [Db -5] [Gb -6] [Cb -7]
  [B♭ -2] [E♭ -3] [A♭ -4] [D♭ -5] [G♭ -6] [C♭ -7])
;; Ex:
(key->fifths 'Gb) ;; -> -6

This seems like a simple and common enough pattern that there must be such a 
facility in some Racket library out there already, but I haven’t found one. Am 
I reinventing a wheel here?

Thanks,
Jordan

-- 
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] ~literal vs ~datum

2017-08-02 Thread Jordan Johnson
On Aug 1, 2017, at 11:34, Jens Axel Søgaard  wrote:
> The binding information is attached a syntax object during expansion.
> In your example the #'(define x y) haven't gone through expansion,
> so you do not get what your expected result.
> 
> However we can change your macro a little...

Ah, that clarifies everything. Thanks!

So, the example I quoted is actually from the docs on ~datum 
,
 and it seems pretty clear that it’s trying unsuccessfully to elicit different 
behaviors that show the difference between ~literal and ~datum. Based on the 
code you’ve provided, I think this would be a better illustration:

> (define-syntax (is-define? stx)
>   (syntax-parse stx
> [(_is-define? id)
>  (syntax-parse #'id
>[(~literal define) #''yes]
>[(~datum   define) #''not-really]
>[_ #''not-even-close])]))
> 
> (is-define? define) ;; 'yes
> 
> (let ([define 42])
>   (is-define? define))  ;; 'not-really
> 
> (is-define? something-else) ;; 'not-even-close

I’ve submitted that as a PR on the doc file linked above. I hope you don’t mind 
my using your example in that way. It was very helpful.

Regards,
Jordan

-- 
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.


[racket-users] ~literal vs ~datum

2017-08-01 Thread Jordan Johnson
Hi all,

Reading the documentation on ~datum in syntax/parse, I see:

The ~datum 

 form is useful for recognizing identifiers symbolically, in contrast to the 
~literal 

 form, which recognizes them by binding.

That makes sense to me. But then I see:

> (syntax-parse 
> 
>  (let 
> 
>  ([define 
> 
>  'something-else]) #'(define 
> 
>  x y))
[((~datum 

 define 
)
 var:id e:expr) 'yes]
[_ 

 'no])
'yes
> (syntax-parse 
> 
>  (let 
> 
>  ([define 
> 
>  'something-else]) #'(define 
> 
>  x y))
[((~literal 

 define 
)
 var:id e:expr) 'yes]
[_ 

 'no])
'yes

I’m confused by this. It seems, based on the first sentence I quoted, that in 
the second example, in which the syntax being parsed has define bound to 
something other than the usual, the use of ~literal should make the first 
clause fail to match. And I’d have expected the examples to contrast ~datum and 
~literal, rather than exhibit the same behavior.

Could someone please explain this to me?

Thanks,
Jordan

-- 
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] Hint on opening enclosing directory of current file from DrRacket

2017-07-04 Thread Jordan Johnson
IIRC on windows, at the cmd prompt (and hence maybe through DrR's "system" 
procedure) you can type "explorer ." to obtain the same behavior.

Cheers,
Jordan

> On Jun 28, 2017, at 5:38 PM, James  wrote:
> 
> 
>> On Jun 28, 2017, at 5:42 PM, Glenn Hoetker wrote:
>> 
>> Caveats: 1. Since CWD is set to the most recently run file, you have to have 
>> run the file whose enclosing directory you wish to open. The default appears 
>> to the home directory. 2. I know this works on MacOS. I can't see why it 
>> wouldn't work on Unix systems. Windows scares me, so I have idea if it would 
>> work there.
> 
> The open command, as such, is Mac specific.  The "." argument to open tells 
> it to open the current working directory but you can specify any folder or 
> file to open.  In Debian, the xdg-open command is very similar.  
> 
> -- 
> 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.

-- 
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] Question: 2D data (Arrays?) in Universe Teachpack

2017-05-27 Thread Jordan Johnson
On May 27, 2017, at 7:00 AM, A Mauer-Oats  wrote:
> I thought it would be interesting to work with 2D data in an "advanced 
> introductory" class. At least to the extent of being able to model classic 
> board games like Battleship and Checkers.
> [...]
> Any suggestions or tales of relevant experience would be welcome. (Even 
> "don't do that!" notes from people with more experience. :)

Albeit not recently, I've had students do Battleship as a project near the end 
of second semester (of HS intro programming using HtDP). It was all using lists 
of lists. For the size of the board, the performance of LOLs (vs. arrays) is 
perfectly adequate, and I see no reason to get into arrays just for this one 
project.

IIRC the data defs were something like this:

;; A Cell is either
;;  #f- meaning an unplayed cell
;;  'hit  - meaning a cell that a previous shot hit
;; 'miss - meaning a cell where a previous shot missed

;; A Board is a Listof[Listof[Cell]].
;; Each list in the Board represents one
;; row, and all rows are of equal length.

;; A Ship is a (make-ship String Listof[Posn])
(define-struct ship [name cells])
;; indicating a ship's name
;; and all locations on it that aren't yet hit.

;; A Game is a (make-game Bool Listof[Ship] Board):
(define-struct game [my-turn? ships shots])
;; in which my-turn? is true iff it's the player's turn,
;; ships represents the locations of all the player's ships, and
;; shots represents shots the player has fired
;;   at the enemy's ships.

I did this after all students had done the problems on lists of lists (e.g., 
reading file input as lists of lists of words), and after the 
two-complex-parameters work that includes writing the equivalent of list-ref — 
so it isn't a huge stretch at that point for them to write functions occupied? 
: Nat Nat Game -> Boolean (asking "does one of my ships occupy (row,col)?") and 
remove-ship-posn : Nat Nat Listof[Ship] -> Listof[Ship] (used when one of the 
player's ships is hit) for tracking enemy shots, and functions such as 
record-shot : Nat Nat Game -> Game (which records a shot the player has fired 
at the enemy, by updating the Board) for dealing with the player's own shots.

It was a fun project. The game was networked using 2htdp/universe, so the above 
definitions are for client side only; the server maintained each client's list 
of ships and a list of the shots each player had fired (plus whose turn it is, 
of course). I don't remember whether I provided the server code, or had one 
team write the server code, but having the choice is one nice thing about this 
game as a project: it scales to several different levels of student ability.

Cheers,
Jordan

-- 
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] Re: Proper non-tail recursion?

2017-04-25 Thread Jordan Johnson
On Apr 25, 2017, at 6:09 PM, Matthias Felleisen  wrote:
> While I am at it, let me advocate PITCH as the slogan for Proper 
> Implementation of Tail Calls. (Where does the H come from? I added it to make 
> a complete word.)

Proper Implementation of Tail Call Handling? :)

Cheers,
Jordan

-- 
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] Should I keep all of the definitions from HTDP2e in one definitions save file?

2017-04-15 Thread Jordan Johnson
If I were doing it from scratch, I would keep one file for each section or each 
grouping of exercises.

One big file for the whole book is a bit much, especially given that sometimes 
definitions are revisited with similar names. And one file per exercise is 
probably too small, and could make it harder to find the file you want when 
reviewing your work.

But whatever you choose, name the files clearly so you can tell what part of 
the book each one goes with. That's more important than how many definitions 
you decide to stuff into any given file.

Cheers,
jmj

> On Apr 15, 2017, at 1:21 PM, Evan Root  wrote:
> 
> Essentially I was following htdp2e and at Chapter I second 3 I created a new 
> definitions file for the cars. I then got stuck because I apparently needed a 
> definition from section 2 for 'BACKGROUND' but I didn't realize it. That made 
> me think; because I'm doing this without an instructor I don't have other 
> people to go off of by looking at their DrRackets. 
> 
> For the people who have followed the book, how long do you all keep the 
> definitions? Like one file for the whole book? or perhaps per chapter? I was 
> doing one file per section and now I think I need input from people who have 
> done this successfully. 
> 
> -- 
> 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.

-- 
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.


[racket-users] TCP listening & custodians

2017-02-23 Thread Jordan Johnson
Hi all,

The code below is a simple server based on the web server in the “More: Systems 
programming in Racket” tutorial.

This behavior is puzzling me:
I run the server (from the OS X Terminal) and connect a client.
After a wait, the client is disconnected by the timeout (shown in red).
I halt the server with ^C, by triggering the thunk shown in blue.
I start the server again — same way, from the Terminal — and get an “Address 
already in use” error.

This behavior happens consistently.

What’s perplexing is that if I close the connection from the client side 
instead of waiting in step (2) — in which case I understand the bold purple 
expression to be closing the connection — I consistently do not get an error.

I’m puzzled because my current understanding is that the two identical calls to 
custodian-shutdown-all should both be shutting down the same threads and I/O 
ports that were created under the custodian cust — and that even if this 
weren’t the case, the (custodian-shutdown-all main-cust) call should be 
cleaning up those same resources (in addition to shutting down the listener), 
because cust is subordinate to main-cust.

So my question is: What difference between the two cases accounts for the 
different behavior?

Thanks,
Jordan

; Example server ;

#!/usr/local/racket/bin/racket
#lang racket/base

(require racket/tcp)

(define (serve port)
  (define main-cust (make-custodian))
  (parameterize ([current-custodian main-cust])
(define listener (tcp-listen port))
(define (loop) (accept/handle listener) (loop))
(thread loop)
;; Hook to shutdown the server:
(lambda ()
  (printf "Exiting...~n")
  (custodian-shutdown-all main-cust)
  (exit 0

(define (accept/handle l)
  (define cust (make-custodian))
  (parameterize ([current-custodian cust])
(define-values (in out) (tcp-accept l))
(thread (lambda ()
  (let loop ([s (read-line in)])
(unless (eof-object? s)
  (fprintf out "Got it.~n")
  (flush-output out)
  (loop (read-line
  (custodian-shutdown-all cust)))
;; Timeout:
(thread (lambda () (sleep 5) (custodian-shutdown-all cust)

(define stop (serve 9001))

(with-handlers ([exn:break? (lambda (e) (stop))])
  (let loop () (sleep 10) (loop)))

-- 
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.


[racket-users] Detecting EOT when reading a TCP port

2017-02-22 Thread Jordan Johnson
Hi all,

Quick question: Given a listener and input port defined thus:

(define listener (tcp-listen port))
(define-values (in out) (tcp-accept listener))

while reading lines of text, what’s the correct way to detect an EOT (^D or 
U+0004) character?

This “obvious” solution does not work:

(for ([line (in-lines in)])
 #:break (eof-object? line)
  ...)

Neither does this (which I wouldn’t expect to work, after the above didn’t):
(let loop ([val (read-line in)])
  (unless (eof-object? val)
...))

I’ve determined that the eof-object? calls are never producing #t, even if ^D 
is the very first thing the client sends. I’m thinking there’s something 
super-basic that I’m forgetting.

What am I missing here?

Thanks,
Jordan

-- 
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.


[racket-users] Limiting memory for raco

2016-04-21 Thread Jordan Johnson
Hi all,

Is it possible to limit the memory that raco uses for running builds (beyond 
whatever reduction I might get by using the -j option to reduce the number of 
parallel jobs)?

If so, how?

Thanks,
jmj

-- 
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] Order of argument conventions, or ... conventions of argument ordering

2016-04-21 Thread Jordan Johnson
1) With many of these functions, there's usually an imaginary preposition 
there, when I read most of them functions:

sort ls by >
cons X onto ls
remove X from ls
map f over ls

2) Any "-ref" function — list-ref, vector-ref, hash-ref — has the object first. 
Longstanding Scheme/lisp convention, and it resembles array/object 
dereferencing in C-style languages.

3) Most of the higher-order list functions — folds, maps, and filters — take 
the function first and the list last.

4) The only ones that trip me up repeatedly are the take and drop family of 
functions. Putting the list first clashes with the obvious (to me) 
imaginary-preposition reading — "take n from ls" is wrong, as you said — and 
also is opposite to how Haskell does it (and Haskell is where I first used take 
and drop). Otherwise, they've all seemed intuitive to me.

Best,
Jordan

> On Apr 21, 2016, at 3:04 AM, Daniel Prager  wrote:
> 
> Does anyone else struggle to remember the order of arguments for some of the 
> common functions?
> 
> There seem to be two extant conventions, roughly:
> object-first: (function obj other)
> object-last: (function other obj): e.g.
> Object-first: take, drop, list-ref, add-between, sort
> Object-last: cons, member, remove, map, filter, foldl, foldr
> 
> (remove v lst) means "remove the first instance of v from lst" and reads ok..
> 
> OTOH (take lst n) means "take the first n items from lst", which occasionally 
> trips me up, possibly guided by the flipped order in the English 
> interpretation.
> 
> Am I missing some sort of principal or mnemonic?
> 
> How do others cope? Do you make heavy use of the "blue box" in DrRacket?
> 
> Dan
>  
> -- 
> 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.

-- 
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] Package catalog - can't connect

2016-04-19 Thread Jordan Johnson

> At Mon, 18 Apr 2016 14:32:20 -0700, Jordan Johnson wrote:
>> ssl-connect: connect failed (error:14090086:SSL 
>> routines:ssl3_get_server_certificate:certificate verify failed)
>>  context…: [stack trace follows]
> 
> I've seen these kinds of problems where the set of trusted certificates
> had not been updated recently enough. Maybe there's an update for the
> "ca-certificates" package for your installation?

Possibly; I may have to kick this over to my ISP’s support, since it’s a 
managed VPS on which I can’t install packages system-wide.

> You could also try setting the `PLT_PKG_SSL_NO_VERIFY` environment
> variable. As a workaround, that's a last resort, but it might help
> clarify whether it issue is with the set of trusted root certificates.

Ah! OK, I tried that, and got:

>>> ssl-connect: connect failed (error:14090086:SSL 
>>> routines:ssl3_get_server_certificate:certificate verify failed)

Same error, suggesting the problem isn’t failure to verify. Is there any way to 
get more info from raco about the cause of failure? I looked for a “verbose” 
option to raco pkg install, but AFAICT there is none.

Best,
jmj

-- 
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.


[racket-users] Package catalog - can't connect

2016-04-18 Thread Jordan Johnson
Hi all,

I just downloaded Racket 6.4 onto my VPS (running Debian 6.0), and when I try 
to install packages (with raco pkg), I’m getting failures to connect to the 
server. First this:

ssl-connect: connect failed (error:14077410:SSL 
routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure)
  context...: [stack trace follows]

Also, the catalog URL it shows, 
https://download.racket-lang.org/releases/6.4/catalog/, produces a 404 error 
when I try it in a browser. Don’t know if that’s significant.

I guessed, on the basis of the SSL error message, that the SSL package on my 
server may be part of the problem. It reported what looks like an old version 
(0.9.8o 01 Jun 2010). So I tried downloading a newer version of OpenSSL (1.0.2g 
1 Mar 2016), and now it fails with:

ssl-connect: connect failed (error:14090086:SSL 
routines:ssl3_get_server_certificate:certificate verify failed)
  context…: [stack trace follows]

I haven’t played around enough with OpenSSL to know what’s missing in the 
configuration. So,

1) Does this indeed sound like an OpenSSL problem and not a Racket one?
2) Are there any things I am likely missing, in order to make Racket’s package 
system work?

Thanks,
Jordan

-- 
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] Playing sound

2016-04-06 Thread Jordan Johnson
On Apr 6, 2016, at 15:18, John Clements  wrote:
> 1) The “stop” procedure is a giant end-of-the-world hammer; I wouldn’t expect 
> it to be useful while a program is running.

OK. It had that feel.

> 2) I hesitate to suggest this, but there is a “pstream-set-volume!” function 
> that can silence a pstream. (that was the caveat.)

I think this points to a hackish solution that’ll work for us for now:
https://gist.github.com/RenaissanceBug/da7027d8c55a1819f9bae274e189ccac 

The only concern I have thought of so far is whether this’ll cause memory 
leakage over the course of a number of switches between pstreams; I don’t know 
if there’s anything that will keep the GC from cleaning up the pstream when it 
becomes unreachable.

> 3) You are also correct in your supposition that the interface I proposed is 
> not implemented. It looks like it could be done quickly, meaning probably on 
> the order of 10-20 hours of work for me.

I’m glad I asked rather than just dive in trying to figure it out in the middle 
of a busy semester.

> The relevant code to look at here would probably be
> https://github.com/jbclements/RSound/blob/master/rsound/sequencer.rkt 
> 
> [...]
> Adding the stop-playing! call would probably involve adding some king of 
> message queue to the sequencer to receive fade-out messages, and updating the 
> ‘entry’ structure to contain information about sounds that are currently 
> fading in or out.

I’ll look into it at some point, time permitting. But I think the gist above 
will obviate my need for it, at least for the time being.

Thanks again!

Best,
jmj

-- 
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] Playing sound

2016-04-06 Thread Jordan Johnson
Hey, so I’m now looking at how to set up background music in rsound with the 
ability to switch tracks. Below is the suggestion from John Clements that seems 
right:
>> I’m guessing you’re looking for an imperative API that looks something like 
>> this:
>> 
>> (start-playing! stream sound at-time #:fade-in time-duration) => token
>> (stop-playing! stream token at-time #:fade-out time-duration)

AFAICT this isn’t already in existence in the rsound library. My impression is 
that we will need to build this on top of signals and networks — but I want to 
check that, before we pour the time into doing it.

I’m thinking signals & networks because we tried to build it using pstreams, 
and ran into a snag when trying to stop playback and switch to a new track:

;; Given a pstream bgmusic and rsounds bgsong1, bgsong2, the following 
Interactions
;; occur:
> (pstream-play bgmusic bgsong1)
"sound is queued"
> (stop)
> (pstream-play bgmusic bgsong2)
"sound is queued";; BUT NO SOUND PLAYS.
> 
;; - end interactions -

So, am I correct in thinking that pstreams aren’t sufficient for what I’m 
attempting? Is there another way to stop playback, other than calling (stop)?

Thanks,
Jordan

-- 
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] Playing sound

2016-01-29 Thread Jordan Johnson
Hi John,

Thanks for the reply.

> If you’re concerned about test failures in pkg.racket-lang.org… well, my test 
> cases try to load the shared libraries and play sound, so that’s not possible 
> in pkg.racket-lang.org’s environment.

Oh, good. That's less of a worry then.

Will the separate shared libraries likely cause any extra difficulties when he 
bundles his code up into Win/Mac executables?

> I’m guessing you’re looking for an imperative API that looks something like 
> this:
> 
> (start-playing! stream sound at-time #:fade-in time-duration) => token
> (stop-playing! stream token at-time #:fade-out time-duration)

Yep, that should do what he wants.


Best,
Jordan

-- 
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.


[racket-users] Playing sound

2016-01-27 Thread Jordan Johnson
Hi all,

I'm looking at audio again because I have a student doing a game project for 
which he wants background music to play — and I'm feeling some trepidation 
based on most of the audio-tagged packages on pkgs.racket-lang.org showing some 
test failures or other build problems.

His minimal goal is to loop a sound file from the start of play until the end, 
and have it work on Windows and Mac. We tried play-sound from racket/gui/base, 
and it almost fits: we just need to be able to kill the sound at the end, and 
it seems that killing the sound-playing thread is not enough. Is there a way to 
stop the audio?

His ideal goal is to be able to play different background music depending on 
the room the player is in. AFAICT this is beyond play-sound's ability, at least 
if he wants to do smooth transitions. Is there another library which would 
facilitate cross-fading from one audio file to another?

More generally, what are currently our best tools for incorporating music and 
sound effects into Racket games?

Best,
Jordan

-- 
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] A template/example to use to build a workflow illustration/flowchart in slideshow

2016-01-15 Thread Jordan Johnson
Yes. The slideshow tutorial referenced near the top of
 http://docs.racket-lang.org/slideshow/index.html
("Run Tutorial") incorporates a slideshow in which you can inspect the source.

Best,
Jordan

> On Jan 13, 2016, at 5:10 PM, C K Kashyap  wrote:
> 
> Dear group,
> 
> I am trying to use racket for my presentation - essentially document the flow 
> of code of a system I've been going through for a few days - I was wondering 
> if there is a slideshow example that I could use to build on top of to 
> illustrate a workflow.
> 
> Regards,
> Kashyap
> -- 
> 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.

-- 
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] racket users fight for their right to colon keywords

2015-10-26 Thread Jordan Johnson
On Oct 23, 2015, at 8:30 AM, Greg Hendershott  wrote:
> Keyword arguments:  Although I'm comfortable in the #: camp, I can
> understand people preferring :foo over #:foo for the reason that it is
> faster to type. #: requires two shifted chars. If you touch type you
> use both left and right shift keys O_o. 

Catching up late on this discussion, I found only the above surprising; I 
touch-type, but always use left-shift for both hash and colon.

Maybe it's a lefty thing.

FWIW, I'm in the "please don't break existing code for this reason" camp, 
though I also appreciate the extra visual distinction of an octothorp'd keyword.

Best,
Jordan

-- 
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.


[racket-users] Multiple colorschemes for multiple DrR versions?

2015-09-09 Thread Jordan Johnson
Hi all,

Is there a way to specify that DrRacket use a certain color scheme for a 
certain version, or to dynamically choose a color scheme at startup?

It occurred to me that since I sometimes run a DrRacket built from the nightly 
snapshots and sometimes run the latest stable build, it’d be nice to have a big 
obvious visual distinction between the two. Since they share preferences, 
though, I can’t just set different colors via Preferences.

Also, I know I’m not the only one to have multiple DrRackets installed, so if 
you have a different technique for distinguishing them visually (aside from the 
version number in the repl), I’d be interested to hear it.

Thanks,
jmj

-- 
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] Frog/Scribble: h* tag substitution

2015-08-29 Thread Jordan Johnson
On Aug 28, 2015, at 9:06 AM, Greg Hendershott  wrote:
> 
> Yes. It's happening in Frog, where the HTML generated by Scribble is
> adjusted in a few ways:
> ...
>  Maybe you'll agree that behavior is OK, now that you know what's going on 
> and why?

This takes care of my immediate need, since I can just redefine my hN functions 
to output h(N+2), knowing Frog will map them right back to hN. Thanks.

As to the bigger question of what behavior is preferable, I'd have to think 
about it. The conflict for me is that in page sources I would want the hoisted 
behavior you're talking about, but in post sources I wouldn't. For example, for 
semantic reasons, I would never want an H1 in a post; the containing page 
already has a top-level header.

So, I'll think about it and let you know if a decent compromise comes to mind.

Best,
Jordan

-- 
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.


[racket-users] Frog/Scribble: h* tag substitution

2015-08-27 Thread Jordan Johnson
Hi all,

I’m using Greg Hendershott’s Frog[1] tool for my web site, and since I know I’m 
outputting HTML I sometimes want to be able to tell Frog/Scribble, “Just use 
this HTML tag here.” I’ve looked at the docs on implementing styles[2], and 
came up with this attempt:

> ;; string? -> (string? ... -> element?)
> (define (tag-function tag-name)
>   (lambda content
> (keyword-apply elem
>'(#:style)
>(list (style #f (list (alt-tag tag-name
>content)))

This worked great for inserting EM and STRONG tags:

> @(define em (tag-function "em”))
> ...
> Here’s something @em{really important}!
> ...

What’s got me baffled is that if I try to access H1..H5 tags this way, other 
tags get substituted. For example:

> @(define h3 (tag-function "h3”))
> ...
> @h3{Section 2}

renders as

> Section 2


So far it’s just the H* tags I’ve found misbehaving.

So, my plea to Greg & other Scribblers: can you give any insight into where the 
H3 might be getting replaced with an H1?

Thanks,
Jordan

[1] https://github.com/greghendershott/frog
[2] http://docs.racket-lang.org/scribble/extra-style.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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Scribble: Wrap text in examples/interactions?

2015-08-09 Thread Jordan Johnson
Hi all,

Is there a way to get long lines of text in a Scribble @examples block to wrap? 
(Perhaps looking something like DrRacket’s wrapped lines?)

Thanks,
jmj

-- 
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] Scribble undefined tags

2015-07-26 Thread Jordan Johnson
On Jul 25, 2015, at 2:48 PM, Matthew Flatt  wrote:
> Do the broken references show up when rendering docs with `raco setup`
> or `raco pkg {install,update}`, or do they show up when running
> `scribble` directly on the ".scrbl" file?

The former.

> If you're seeing this behavior when using `raco setup` or `raco pkg`,
> then it sounds like a bug. Using collection-based paths instead of
> relative paths may be a good idea (to enable directly running
> `scribble`, for example), but it shouldn't be required.

Good to know.

I’ve cleared out all the undefined tag warnings, but without a complete 
understanding of what’s going on. Some further info:

The code I’m documenting is all in TR.
Some of the undefined-tag warnings I saw resulted from the same identifier 
being imported (with for-label) from multiple modules.

When I discovered the multiple-imports problem, I managed to eliminate most of 
the warnings, but until minutes ago I was stuck with a few yet:

raco setup: 0 running: /jwt/net/jwt/jwt.scrbl
raco setup: WARNING: undefined tag in /jwt/net/jwt/jwt.scrbl:
raco setup:  ((lib "net/jwt.rkt") decode-jwt)
raco setup:  ((lib "net/jwt.rkt") decode/verify)
raco setup:  ((lib "net/jwt.rkt") verify-jwt)
raco setup:  ((lib "typed/json.rkt") JSExpr)

I’m ignoring the JSExpr one, since I know JSExpr is not in the Scribble docs 
yet. (FWIW, about a month ago I put in a pull request that would add that to 
the TR docs <https://github.com/racket/typed-racket/pull/155>.)

Here’s the Scribble file:
  https://github.com/RenaissanceBug/racket-jwt/blob/master/net/jwt/jwt.scrbl

Here’s the net/jwt.rkt file referenced above:
  https://github.com/RenaissanceBug/racket-jwt/blob/master/net/jwt.rkt
It pulls in, and then re-provides, the three offending names from this file:
  
https://github.com/RenaissanceBug/racket-jwt/blob/master/net/jwt/encode-decode.rkt
I’ve checked that those names are not being required from any other module by 
the Scribble file.

And then I happened to add this line 
<https://github.com/RenaissanceBug/racket-jwt/blob/master/net/jwt/jwt.scrbl#L131>,
 and the undefined-tag errors magically went away.

Since there’s no obvious likely connection between that section header and the 
names being (un)defined, my best guess at what happened is that
I discovered the relationship to names imported from two sources, and started 
adjusting my imports
I made some unrelated changes to the Scribble doc
I rebuilt the docs and got only the four errors I pasted above
I removed the remaining double-imports
I rebuilt the docs and saw no change — maybe raco setup wasn’t recompiling the 
.scrbl file because it hadn’t been edited?
I made an unrelated change to jwt.scrbl, causing raco setup to detect jwt.scrbl 
had changed and do something differently
The remaining errors then disappeared

(And when I tried removing the section header again, the errors didn’t return.)

Still, I’ve no idea what exact connection there might be to multiple imports of 
the same name, but AFAICT that was related. I hope this info, vague as it is, 
is still of some help.

Best,
jmj

> 
> At Fri, 24 Jul 2015 21:56:45 -0700, Matthew Butterick wrote:
>> I’ve always found that it’s more reliable to use fully-qualified package
>> names with `for-label`, e.g.
>> 
>> (require (for-label jordan/package))
>> 
>> rather than
>> 
>> (require (for-label "main.rkt"))
>> 
>> Once upon a time I had similar problems, and noticed that fully-qualified
>> names is the habit used in many internal Racket packages. The reasons why
>> this works are dimly remembered. I presume it has something to do with the
>> fact that all Scribble docs are rendered into the main docs directory for
>> your installation, thus breaking local paths that wander outside your
>> 'scribblings' subdirectory.
>> 
>> On Fri, Jul 24, 2015 at 8:58 AM, Jordan Johnson  wrote:
>> 
>>> Hi all,
>>> 
>>> I have a file *main.scrbl* in the same directory as a file *main.rkt*. In
>>> the .scrbl file, I have
>>> 
>>> (require (for-label "main.rkt"))
>>> 
>>> and several *defproc* and *defstruct** forms. For some reason, one of my
>>> *defstruct** forms works as expected, while all of the other *defstruct** 
>>> and
>>> *defproc* forms produce undefined-tag warnings (when I build the docs via
>>> raco setup), and compile to a red-underlined name in the resulting HTML.
>>> 
>>> In DrRacket, mousing over the struct names in *main.scrbl*, I see a pink
>>> arrow with a question mark pointing from the *for-label* line to the
>>> struct name, and DrRacket correctly reports that the struct name’s binding
>>> is imported from *m

[racket-users] TR: Option values

2015-07-26 Thread Jordan Johnson
Hi all,

Writing TR code, I find that the more I use the Option type, the more I want 
something like Haskell’s Maybe monad. Is there any existing tool I’m missing, 
that provides for applying functions to values of type (Option x), by 
propagating failures?

If not, would it be sensible to include such a thing in one of the TR packages 
as a standard TR library?

Unfortunately, I haven’t figured out a way to write a variable-arity version: 
This fails, presumably because TR’s occurrence typing is (quite understandably) 
not able to do much with ormap:

(: maybe-apply (All (a b) ((a * -> (Option b)) (Option a) * -> (Option b
(define (maybe-apply f . vs)
  (if (ormap not vs) #f (apply f vs)))

Error:
Type Checker: Bad arguments to function in `apply':
Domain: a *
Arguments: (Listof (U False a)) *
 in: (apply f vs)

But even having a trio of unary/binary/ternary versions would be very helpful. 
I’ve put up a tiny and crude library here 
, but imagine there’s a better 
way to bring it into the racket ecosystem. Thoughts?

Cheers,
jmj

-- 
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.


[racket-users] Scribble undefined tags

2015-07-24 Thread Jordan Johnson
Hi all,

I have a file main.scrbl in the same directory as a file main.rkt. In the 
.scrbl file, I have

(require (for-label "main.rkt"))

and several defproc and defstruct* forms. For some reason, one of my defstruct* 
forms works as expected, while all of the other defstruct* and defproc forms 
produce undefined-tag warnings (when I build the docs via raco setup), and 
compile to a red-underlined name in the resulting HTML.

In DrRacket, mousing over the struct names in main.scrbl, I see a pink arrow 
with a question mark pointing from the for-label line to the struct name, and 
DrRacket correctly reports that the struct name’s binding is imported from 
main.rkt.

What might I be missing, that could be causing undefined-tag errors?

Thanks,
jmj

-- 
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.


[racket-users] Scribble: referencing struct fields

2015-07-23 Thread Jordan Johnson
Hi all,

What are the appropriate function and the preferred practice for referring to 
struct fields in a Scribble document? For example, if I’m writing the 
defstruct* body text and want to say, “the x field is intended for blah blah 
blah”, is @racket[x] the right way to typeset the field name “x”?

Thanks,
jmj

-- 
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.


[racket-users] TR: require/typed and parametric polymorphism

2015-07-02 Thread Jordan Johnson
Hi all,

If I’m reading the docs & source correctly, it looks like it’s impossible to 
use require/typed to attach a parametric type to an import. Is that right?

I’m also a bit curious if that’s because adding that capability is a difficult 
or impossible proposition.

Cheers,
jmj

-- 
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] Moving an image with the keyboard

2015-06-26 Thread Jordan Johnson
Hi Patrick,

The problem you’re up against is that in the code you’ve attached, we don’t 
have a clear picture of what the signatures for your functions are, nor of the 
“world” upon which big-bang operates. Standard practice in HtDP-based courses 
dictates that
every big-bang program should have a data definition for the world in comments, 
and
every function should have a signature and brief description of its purpose in 
comments (as well as one or more examples/tests to illustrate its use).

Because you write (big-bang (ufo 70 60) ...), you clearly intend for your 
“world” to be a ufo struct. So in order for your readers to not have to guess 
at what you mean, you need a comment to accompany your struct definition:

;; A World is a (ufo Number Number):
(struct ufo (xpos ypos))
;; where xpos is ...
;;   and ypos is ...

And say what xpos and ypos represent. Thereafter, when you write function 
signatures, you can use World to describe the kind of data that’s passing in or 
out, e.g.,

;; SIGNATURE: render-ufo : World -> Image
;; PURPOSE: draws the UFO at the given location

If you look at the Help Desk docs for 2htdp/universe, one fine thing it gives 
you in the description of big-bang is the signature required for every one of 
the handler functions. For example: big-bang’s first parameter must be a World, 
and in
 [to-draw f]
the signature of f must be
 ;; f : World -> Image

Once you’ve worked out what the signatures should be for all of your handler 
functions, take a look at your code and start writing signatures for the 
functions you’ve written. This will lead you to figure out what’s going wrong.

Cheers,
jmj

On Jun 26, 2015, at 4:42 PM, Patrick Ester  wrote:
> 
> Dear All,
> 
> I am not sure if this is the right place since I am working from the Realm of 
> Racket book. If not, please let me know where I can take my question. I 
> finished up chapter five, and wanted to modify the UFO example to move in 
> relation to the arrow keys. Here is the code that I wrote:
> 
> #lang racket
> (require 2htdp/universe 2htdp/image)
> 
> (define WIDTH 600)
> (define HEIGHT 600)
> ;;The image won't copy and paste, but you get the idea.
> (define IMAGE-of-ufo .)
> 
> (struct ufo (xpos ypos))
> 
> (define (move-up w)
>  (add1 (ufo-xpos w)))
> 
> (define (move-down w)
>  (sub1 (ufo-xpos w)))
> 
> (define (move-right w)
>  (add1 (ufo-ypos w)))
> 
> (define (move-left w)
>  (sub1 (ufo-ypos w)))
> 
> (define (render-ufo w)
>  (place-image
>   (scale 0.25 IMAGE-of-ufo) (ufo-xpos w) (ufo-ypos w)
>   (empty-scene WIDTH HEIGHT)))
> 
> (define (move-UFO w key)
>  (cond [(key=? key "up") (move-up w)]
>[(key=? key "down") (move-down w)]
>[(key=? key "left") (move-left w)]
>[(key=? key "right") (move-right w)]
>[else w]))
> 
> (big-bang (ufo 70 60)
>  (on-key move-UFO)
>  (to-draw render-ufo))
> 
> When I click the Run button, the output initially looks good. However, when I 
> press an arrow key, I get an error. Attached is a screenshot with what I see 
> in the definitions pane.
> 
> The error message in the interactions pane is:
> 
> "ufo-xpos: contract violation
>  expected: ufo?
>  given: 61"
> 
> I do not get why the contract is broken. The function place-image takes an 
> image, number, number, and a scene. What mistake am I making? Thanks in 
> advance.
> 
> Patrick
> 
> -- 
> 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.
> 

-- 
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.


[racket-users] TR typed-racket-more library docs

2015-06-26 Thread Jordan Johnson
Hi all,

One thing I’ve noticed in working with Typed Racket is that some of the 
libraries on the “Libraries Provided with Typed Racket 
”
 docs page have type definitions that aren’t documented anywhere, but that 
ought to be visible to TR programmers. Sometimes, I look at that docs page and 
think, “Gee, I’d be happy to spend a little time writing docs for those types, 
if I knew where to do it.”

So, is there any planned idea of where the documentation for the TR-specific 
parts of all those wrapper libraries currently in the typed-racket-more package 
ought best to wind up? AFAICT there are at least three possibilities:

The wrappers eventually migrate to the libraries they wrap, and the docs then 
have an obvious home there.
The wrappers stay where they are, and documentation for a wrapper lib goes 
beneath its (require …) rectangle on the TR libs page linked above.
The wrapper libs get separate HTML files in the TR reference.

I don’t have a preference, but would gladly do some writing if the main TR devs 
suggest where.

Regards,
Jordan

-- 
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.


[racket-users] ANN: cookies library for clients and servers

2015-04-07 Thread Jordan Johnson
Hi all, 

This weekend I added to the package catalog a set of libraries (named 
net-cookies) for managing cookies as per RFC6265, the most recent cookie RFC.

Documentation: http://pkg-build.racket-lang.org/doc/cookies/index.html

Source: https://github.com/RenaissanceBug/racket-cookies

Examples are available in the docs. Feedback and bug reports welcome.

Best,
jmj

-- 
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] run big-bang universe server on headless server?

2015-03-02 Thread Jordan Johnson
I'd imagine running it under Xvfb would be worth a try:
 http://en.wikipedia.org/wiki/Xvfb

I know I've used that to be able to run gracket-text stuff on my Linux VPS 
before. Don't know if there's anything in universe that would pose an obstacle, 
however.

Best,
Jordan

On Feb 27, 2015, at 4:18 PM, Stephen Chang  wrote:

>> It shows state windows and debugging windows only when you specify 
>> appropriate clauses in its description.
> 
> They seem to appear by default and I don't see anywhere to disable them?
> 
> 
> 
> 
> But, it pulls in a shared library from 'world' that relies on
> racket/gui. So the answer is 'currently not possible but doable in
> principle'.
>> 
>> -- Matthias
>> 
>> 
>> 
>> 
>> 
>>> On Feb 27, 2015, at 6:12 PM, Stephen Chang wrote:
>>> 
>>> Is there any way to run a big-bang universe server without the gui?
>>> 
>>> Or more generally has anyone figured out how to run a big-bang
>>> universe server on a headless server?
>>> 
>>> Racket Users list:
>>> http://lists.racket-lang.org/users
> 
>  Racket Users list:
>  http://lists.racket-lang.org/users

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] min and max representable dates

2015-03-02 Thread Jordan Johnson
On Mar 2, 2015, at 6:59 AM, Hendrik Boom  wrote:
> On Sun, Mar 01, 2015 at 04:07:57PM -0800, Jordan Johnson wrote:
>> 
>> I expect a pretty conservative estimate is A-OK if it’d be sure of 
>> not throwing an error on 32+-bit systems;
>> I see 2^32 seconds would get us at least to the year 2106...
> 
> Which is why the world is shifting to 64-bit dates.

Yes, so I’d feel a lot more comfortable if I can give a bigger max than 2^32 
(which I expect I can, but want to check). I found that in Racket v6.1.1 the 
max is 2^31 - 1. In v6.1.1.8 all I’ve determined is that the max is somewhere 
between 2^55 and 2^56, on the machine I have access to at the moment. I’d be 
perfectly happy to take 2^55 as the constant, IF it will work on all machines; 
that’d give 1.1 billion years to implement an improvement. With a coffee break, 
even.

Best,
jmj



  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] How can I dump (display) the variables defined in current the global environment

2015-03-01 Thread Jordan Johnson
On Mar 1, 2015, at 5:37 PM, Rufus  wrote:
> And also
> a function to save this state (variables in the global environment) in a
> fashion that could be quickly/easily (ie one short function call) be
> reloaded the next day to continue from where I left off.

The typical workflow in DrRacket is to use the Definitions pane for this.

If I were working through TLS from scratch in DrRacket, here is how I would do 
it, knowing what I now know:

Start a new file when I start a new chapter.
When a definition comes up, add it to the Definitions pane, then save and click 
“Run”.
When a name from a previous chapter is referenced in an expression or 
definition, copy it in from that chapter’s file, then save and click “Run”.
When expressions are being evaluated, type the expressions in the Interactions 
pane.

I don’t remember if there is use of set! in TLS — that would complicate things 
a bit — but I don’t think there was much if any.

HTH,
jmj


  Racket Users list:
  http://lists.racket-lang.org/users


[racket] min and max representable dates

2015-03-01 Thread Jordan Johnson
Hi all,

Am I right in thinking the min and max dates that racket/date can handle are 
platform-dependent? If so, is there any constant I can reasonably use as a 
least or greatest representable date?

I’ve looked in racket/date.rkt and see that there’s some code that appears to 
be doing binsearch on greatest/least values that seconds->date will accept 
without error, and eventually I gave up chasing seconds->date down the rabbit 
hole of racket/base. I really don’t want to get into putting the same binsearch 
code into my library, but need plausible-yet-safe min/max values.

Context: I’m working on RFC6265 cookie support, and there are some places where 
the RFC calls for these min/max values explicitly. I expect a pretty 
conservative estimate is A-OK if it’d be sure of not throwing an error on 
32+-bit systems; I see 2^32 seconds would get us at least to the year 2106...

Best,
jmj

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] net/cookie update

2015-02-07 Thread Jordan Johnson
Hi all,

In writing some cookie-handling code I noticed that
1) the Racket net/cookie library is based on RFC 2109, obsoleted by two 
new cookie RFCs since then (the current being 6265)
2) the net/cookie library’s imperative interface feels very un-Rackety

I initially just wanted to be able to use the HttpOnly flag, and later got to 
thinking it’d be more Rackety to have a cookie constructor based on keyword 
args, like (using provide/contract syntax):
[make-cookie (->* (cookie-name? cookie-value?)
  (#:expires (or/c date? #f)
   #:max-age (or/c (and/c integer? positive?) #f)
   #:domain (or/c valid-domain? #f)
   #:path (or/c path/extension-value? #f)
   #:secure? boolean?
   #:http-only? boolean?
   #:extension (or/c path/extension-value? #f))
  cookie?)]
where cookie-name?, cookie-value?, and path/extension-value? are written as per 
RFC 6265.

So I’ve done some work and would like to eventually volunteer an updated cookie 
lib that complies with the newer RFC. Thing is, it’s going to be 
backward-incompatible in some small ways, since RFC 6265 disallows some things 
(like double-quotes as non-start/end chars of a cookie value) that net/cookie 
permits.

My question is, which approach would the Racket maintainers prefer:
add a new constructor, like the above, that does RFC6265 checking and leave all 
of net/cookie’s machinery otherwise untouched
do the above and also add RFC 6265 checks to the relevant cookie:... functions 
in the library (which involves rewriting the tests and may break some old apps 
that use it)
replace the old net/cookie interface altogether
add a differently-named library to net/ (and mark the old one as deprecated?)
add a library somewhere else (e.g., somewhere in web-server/)
just write a separate cookie package that can be made available via 
pkg.racket-lang.org (I noticed an undocumented attempt at this at 
https://github.com/Kalimehtar/client-cookies)
or something else?

Regards,
jmj


  Racket Users list:
  http://lists.racket-lang.org/users


[racket] SRFI 19 string->date: Error reading dates

2015-01-31 Thread Jordan Johnson
Hi all,

I’m running into this problem with string->date in srfi/19:

;;; begin Interactions
> (require srfi/19)
> (string->date "Sun, 02 Feb 2015" "~a, ~d ~b ~Y”)
result arity mismatch;
expected number of values not received
 expected: 1
 received: 0
 values...:
;;; end Interactions

I’m assuming there’s something I am missing about how dates are handled, but 
from what I’ve read it seems like the code above should be doing it. What am I 
missing?

(And, is there a better way to be reading dates in Racket, or is this the 
preferred way?)

Best,
jmj

P.S. Attempting to copy/paste the above error message from the Interactions 
window crashed DrR (v6.1.1) three times. This doesn’t seem to be reproducible 
by copying any other error messages, though, so I haven’t filed a bug report 
yet; figured perhaps the answer to the string->date problem may shed some light 
on this, too...



  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] 2htdp/image: Silent cropping?

2015-01-24 Thread Jordan Johnson
I'd be fine with that solution.

Best,
Jordan

> On Jan 24, 2015, at 7:10 AM, Matthias Felleisen  wrote:
> 
> 
> I prefer leaving it alone but documenting the limitation -- Matthias
> 
> 
> 
> 
> 
>> On Jan 23, 2015, at 9:30 PM, Robby Findler wrote:
>> 
>> Maybe the right thing to do is leave the arbitrary limit in there, but
>> make it based on the area, not based independently on the width and
>> height. Then your example would work, but (ellipse 5050 5050)
>> wouldn't.
>> 
>> Robby
>> 
>> 
>> On Fri, Jan 23, 2015 at 8:22 PM, Robby Findler
>>  wrote:
>>> Yes, 2htdp/image truncates the images to 5000x5000 when building a bitmap.
>>> 
>>> I did that in response to this PR:
>>> 
>>> http://bugs.racket-lang.org/query/?debug=&database=default&cmd=view+audit-trail&cmd=view&pr=12277
>>> 
>>> but I'm not sure what's the right answer here. I'm hesitant to add
>>> errors but maybe that's the best thing.
>>> 
>>> Robby
>>> 
>>> 
>>>> On Fri, Jan 23, 2015 at 7:52 PM, Jordan Johnson  
>>>> wrote:
>>>> Hi all,
>>>> 
>>>> A student of mine noticed yesterday that part of an image was getting
>>>> truncated. Some further experimentation in BSL yielded this example:
>>>> 
>>>> (ellipse 5050 100 'solid 'blue) ; => image with 50 pixels missing at right
>>>> end
>>>> (ellipse 100 5050 'solid 'blue) ; => image with 50 pixels missing at bottom
>>>> 
>>>> For both images, the image-{width,height} functions produce 100 and 5050;
>>>> the library simply doesn't draw the entire ellipse, although click-and-drag
>>>> highlighting does show the image as having 50 extra blank pixels at the 
>>>> end.
>>>> 
>>>> I can't find documentation of the size limits. Is this intended behavior? 
>>>> If
>>>> so, an error might be more student-friendly.
>>>> 
>>>> Cheers,
>>>> Jordan
>>>> 
>>>> 
>>>> 
>>>> Racket Users list:
>>>> http://lists.racket-lang.org/users
>> 
>> Racket Users list:
>> http://lists.racket-lang.org/users
> 


  Racket Users list:
  http://lists.racket-lang.org/users


[racket] 2htdp/image: Silent cropping?

2015-01-23 Thread Jordan Johnson
Hi all,

A student of mine noticed yesterday that part of an image was getting
truncated. Some further experimentation in BSL yielded this example:

*(ellipse 5050 100 'solid 'blue)* ; => image with 50 pixels missing at
right end
*(ellipse 100 5050 'solid 'blue)* ; => image with 50 pixels missing at
bottom

For both images, the *image-{width,height}* functions produce 100 and 5050;
the library simply doesn't draw the entire ellipse, although click-and-drag
highlighting does show the image as having 50 extra blank pixels at the end.

I can't find documentation of the size limits. Is this intended behavior?
If so, an error might be more student-friendly.

Cheers,
Jordan

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] JSExprs and hashtables

2015-01-19 Thread Jordan Johnson
Great! Thanks for the discussion.

Best,
Jordan

> On Jan 19, 2015, at 5:41 AM, Alexander D. Knauth  wrote:
> 
> I managed to fix this for your example by inserting these 3 lines into 
> typed-racket/types/remove-intersect.rkt after line 67:
>  [(list-no-order (Value: (not (? hash?)))
>  (or (? Hashtable?) (? HashtableTop?)))
>   #f]
> There is probably a better solution though.
> 
>> On Jan 19, 2015, at 7:36 AM, Alexander D. Knauth  
>> wrote:
>> 
>> Since hash-tables can be mutable as far as TR knows, (HashTable Symbol 
>> String) is not a subtype of (HashTable Symbol JSExpr).
>> To work around this, you can do this:
>> #lang typed/racket/base
>> (require typed/json)
>> (: jsx JSExpr)   ; <-- jsx is what I ultimately want.
>> (define jsx (ann #hasheq((a . "val1") (b . "val2") (c . "val3")) (HashTable 
>> Symbol JSExpr)))
>> 
>> Or this would work too:
>> #lang typed/racket/base
>> (require typed/json)
>> (: jsx (HashTable Symbol JSExpr))   ; <-- jsx is what I ultimately want.
>> (define jsx #hasheq((a . "val1") (b . "val2") (c . "val3")))
>> 
>> Or you could use (inst make-immutable-hasheq Symbol JSExpr) instead of using 
>> #hasheq, and it would do the same thing.
>> 
>> 
>>> On Jan 19, 2015, at 1:28 AM, Jordan Johnson  wrote:
>>> 
>>> Hi all,
>>> 
>>> I’ve been trying to create JSExprs, as defined in the typed/json library. 
>>> This is one of those instances where it seems like I must be making things 
>>> harder than they should be, but I’m still feeling like a duck on 
>>> rollerskates in TR, so I want to make sure I’m not missing an easier way to 
>>> do it.
>>> 
>>> Would you please confirm if this is indeed a smallest-possible solution?
>>> 
>>>  begin
>>> #lang typed/racket/base
>>> 
>>> (require typed/json)
>>> 
>>> (: jsx JSExpr)   ; <-- jsx is what I ultimately want.
>>> 
>>> ;; Attempt #1:
>>> #;
>>> (define jsx #hasheq((a . "val1") (b . "val2") (c . "val3")))
>>> 
>>> #| Resulting error:
>>> Type Checker: type mismatch
>>>   expected: JSExpr
>>>   given: (HashTable Symbol String)
>>> 
>>> [This seems weird, since it seems like (HashTable Symbol String) should be
>>>  a subtype of JSExpr. Is the problem that the typechecker can’t recognize
>>>  the Strings as JSExprs?]
>>> |#
>>> 
>>> ;; Attempt #N (shortest successful version I’ve found):
>>> (define jsx
>>>   (for/hasheq : (HashTable Symbol JSExpr) ([k '(a b c)]
>>>[v '("val1" "val2" "val3")])
>>> (values k v)))
>>>  end
>>> 
>>> Regards,
>>> Jordan
>>> 
>>> 
>>>  Racket Users list:
>>>  http://lists.racket-lang.org/users
>> 
>> 
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
> 

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] TR: JSExprs and hashtables

2015-01-18 Thread Jordan Johnson
Hi all,

I’ve been trying to create JSExprs, as defined in the typed/json library. This 
is one of those instances where it seems like I must be making things harder 
than they should be, but I’m still feeling like a duck on rollerskates in TR, 
so I want to make sure I’m not missing an easier way to do it.

Would you please confirm if this is indeed a smallest-possible solution?

 begin
#lang typed/racket/base

(require typed/json)

(: jsx JSExpr)   ; <-- jsx is what I ultimately want.

;; Attempt #1:
#;
(define jsx #hasheq((a . "val1") (b . "val2") (c . "val3")))

#| Resulting error:
Type Checker: type mismatch
  expected: JSExpr
  given: (HashTable Symbol String)

[This seems weird, since it seems like (HashTable Symbol String) should be
 a subtype of JSExpr. Is the problem that the typechecker can’t recognize
 the Strings as JSExprs?]
|#

;; Attempt #N (shortest successful version I’ve found):
(define jsx
  (for/hasheq : (HashTable Symbol JSExpr) ([k '(a b c)]
   [v '("val1" "val2" "val3")])
(values k v)))
 end

Regards,
Jordan


  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] TR: Polymorphic types

2015-01-18 Thread Jordan Johnson
Hi Sam & Matthias,

Thanks for the clarification.

And thanks to Alexander for pointing out the typed/json module — been a while 
since I’ve pulled down a nightly build.

Speaking of that: with the splitting of the repos, if I want to contribute code 
to the TR repository, is there a quick reference doc yet for running that 
repo’s code against an existing Racket installation (or a clone of the main 
racket repo)? (The first time I wrote a TR wrapper lib, I found Greg 
Hendershott’s “Guide for Infrequent Contributors 
”
 tremendously helpful in getting over the initial hump in the Racket+Git 
learning curve — so I suppose I’m hoping the procedure will be similarly 
straightforward, post-split.)

Thanks again,
jmj

> On Jan 18, 2015, at 12:16 PM, Sam Tobin-Hochstadt  
> wrote:
> 
> I've added an example of this to the documentation.
> 
> Sam
> On Sat Jan 17 2015 at 9:48:36 PM Matthias Felleisen  > wrote:
> 
> On Jan 17, 2015, at 9:32 PM, Sam Tobin-Hochstadt wrote:
> 
> > No, it can't be adapted. That error message is an instance of this
> > caveat: 
> > http://docs.racket-lang.org/ts-guide/caveats.html#%28part._.Typed-untyped_interaction_and_contract_generation%29
> >  
> > 
> > which applies to `define-predicate` as well. There's no way to check
> > if something is a `Foo`, because Typed Racket wouldn't know what you
> > meant for `A` to be.
> 
> 
> I think the section [title] is misleading here. You need to know
> TR's ideas well to see that the generation of a run-time object
> is the same thing as moving from the typed to the untyped world
> (and vice versa).
> 
> Perhaps an example like Jordan's could be included in the docs.
> 
> -- Matthias
> 
> 
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users 
> 
>  Racket Users list:
>  http://lists.racket-lang.org/users


  Racket Users list:
  http://lists.racket-lang.org/users


[racket] TR: Polymorphic types

2015-01-17 Thread Jordan Johnson
Hi all,

In playing with TR this evening, I found

> (define-type (Foo A)
>   (U A
>  (List 'foo (Foo A
> 
> (define-predicate foo? Foo)

generates the error “Type Foo could not be converted to a contract: cannot 
generate contract for non-function polymorphic type”. I’ve read the page with 
caveats about inference and polymorphic types, but since the example is about 
using a function rather than defining a predicate, I’m not clear on how (if at 
all) the technique could be adapted for this.

(What I was actually doing, by the way, was seeing if I could port the JSON 
library to TR. I ran into the problem of the null element being of arbitrary 
type.)

Best,
jmj



  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Prefs -> Editing -> Indenting: Definition of keyword types

2014-11-09 Thread Jordan Johnson
Hi all,

A totally non-urgent question, out of pure curiosity: The part of DrRacket’s 
preferences devoted to indentation classifies keywords as “Begin-like”, 
“Define-like”, and “Lambda-like”. What are the definitions of those terms’ 
indentation behavior, and where are they documented?

(I’ve found it useful to add some of the db library's query-* functions to my 
“Lambda-like” list, though AFAICT it would’ve worked just as well to add them 
to “Define-like”. I see lambda’s argument list is indented further than its 
body-exprs if placed on a separate line, and define & begin don’t; I don’t see 
where begin differs from procedure application, however.)

Thanks,
jmj


  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Font selection in DrRacket

2014-11-08 Thread Jordan Johnson

On Nov 8, 2014, at 1:41 PM, Robby Findler  wrote:
> I have some fonts also only in that category, like Triplicate. I see
> it in DrRacket, but only if I choose "Other..." in the font selection
> dialog. Does your font show up there?
> 
> Relatedly, does it show up in the output of this program?
> 
> #lang racket/gui
> (get-face-list)

Interesting: No, and no.

However, I just restarted DrRacket, and it did show up in both lists (which is 
a bit strange, because I’d definitely installed the font prior to the last time 
I launched DrRacket). So my immediate problem is solved.

Thanks,
jmj



  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Font selection in DrRacket

2014-11-08 Thread Jordan Johnson

On Nov 8, 2014, at 1:19 PM, Robby Findler  wrote:
> Do you see them in Font Book?

Yes; they show up in the “User” collection but not the “Computer” collection, 
which is what led me to the hypothesis I offered.

Best,
jmj

> On Sat, Nov 8, 2014 at 3:16 PM, Jordan Johnson  wrote:
>> Hi all,
>> 
>> How can I tell where DrRacket looks for fonts, or tell it where to look? 
>> (I’m running it on OS X.)
>> 
>> I ask because there are a few fonts I’ve installed that aren’t showing up as 
>> options in DrRacket’s font menus. I believe this is because I’ve installed 
>> them as user fonts — not system-wide fonts — and DrRacket is installed in 
>> the system’s Applications folder...but I’m not sure. I don’t see much info 
>> about font choice in the DrR docs (aside from the documentation on font%, 
>> font-list%, etc. — which seems off base and overcomplicated for this 
>> question).
>> 
>> Thanks,
>> jmj



  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Font selection in DrRacket

2014-11-08 Thread Jordan Johnson
Hi all,

How can I tell where DrRacket looks for fonts, or tell it where to look? (I’m 
running it on OS X.)

I ask because there are a few fonts I’ve installed that aren’t showing up as 
options in DrRacket’s font menus. I believe this is because I’ve installed them 
as user fonts — not system-wide fonts — and DrRacket is installed in the 
system’s Applications folder...but I’m not sure. I don’t see much info about 
font choice in the DrR docs (aside from the documentation on font%, font-list%, 
etc. — which seems off base and overcomplicated for this question).

Thanks,
jmj



  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Web authentication tutorials?

2014-10-07 Thread Jordan Johnson
OK. Thanks, Jay.

Best,
jmj

On Oct 7, 2014, at 8:09 AM, Jay McCarthy  wrote:

> As far as I know, a library similar to what you describe does not
> exist. As far as using authentication generally, there's nothing
> special that you should do differently in a Racket app... just follow
> any advice out there on the Internet but generate the HTML and check
> the request with Racket. There are some libraries for reading and
> writing common digest formats:
> 
> web-server/http/id-cookie
> web-server/http/basic-auth
> web-server/http/digest-auth
> 
> Jay
> 
> On Mon, Oct 6, 2014 at 8:05 PM, Jordan Johnson  wrote:
>> Dear Racketeers,
>> 
>> [tl;dr: I’m wondering what is the current state of the art for 
>> authentication in Racket Web apps. What would be a good starting point for 
>> learning how to do authentication with options to authenticate via password 
>> DB and via OAuth with a common authorization service such as those from 
>> Google and Facebook?]
>> 
>> I haven’t done much Web programming in recent years, so I’m not familiar 
>> with standard practice for authentication and authorization, and the sheer 
>> quantity of info out there is daunting. One of my students was demoing a 
>> Meteor app he wrote, and I was impressed by the apparent simplicity: just 
>> adding something like “{{login_buttons}}” to the page template got him HTML 
>> login buttons, Google/FB login (once he obtained an app key), and a session 
>> object he could use for checking authorization in his DB queries. I’m 
>> wondering if anybody’s written a similar library in Racket. The closest I 
>> seem to be able to find are Ryan Culpepper’s webapi/oauth2 and Ray Racine’s 
>> gut/oauth packages. Any further suggestions?
>> 
>> Thanks,
>> Jordan
>> 
>> 
>> 
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
> 
> 
> 
> -- 
> Jay McCarthy
> http://jeapostrophe.github.io
> 
>   "Wherefore, be not weary in well-doing,
>  for ye are laying the foundation of a great work.
> And out of small things proceedeth that which is great."
>  - D&C 64:33



  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Web authentication tutorials?

2014-10-06 Thread Jordan Johnson
Dear Racketeers,

[tl;dr: I’m wondering what is the current state of the art for authentication 
in Racket Web apps. What would be a good starting point for learning how to do 
authentication with options to authenticate via password DB and via OAuth with 
a common authorization service such as those from Google and Facebook?]

I haven’t done much Web programming in recent years, so I’m not familiar with 
standard practice for authentication and authorization, and the sheer quantity 
of info out there is daunting. One of my students was demoing a Meteor app he 
wrote, and I was impressed by the apparent simplicity: just adding something 
like “{{login_buttons}}” to the page template got him HTML login buttons, 
Google/FB login (once he obtained an app key), and a session object he could 
use for checking authorization in his DB queries. I’m wondering if anybody’s 
written a similar library in Racket. The closest I seem to be able to find are 
Ryan Culpepper’s webapi/oauth2 and Ray Racine’s gut/oauth packages. Any further 
suggestions?

Thanks,
Jordan



  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] onfocus like functionality in Racket

2014-10-04 Thread Jordan Johnson
1. One cause of confusion: world-after-button-down and world-after-button-up 
are under-specified in your purpose statements (i.e. "RETURNS:" comments): 
rather than "the world following a button-up event", which is vague and open to 
multiple interpretations, say what behavior you wish to observe (and then 
codify that behavior in your test cases). Get specific: what happens when the 
button is pressed while the cursor is in one ball? multiple balls? no balls?

This vagueness is in some of your other functions, too.

2. The "structural decomposition on w : World" isn't what's going on. Your 
function is really a structural decomposition of the list of balls, and this is 
obscured by the way you are recurring on a World.

Rule of thumb: never rebuild something just so you can recur on a smaller 
version of one of its parts.

Best,
Jordan

> On Oct 4, 2014, at 7:50 PM, Animesh Pandey  
> wrote:
> 
> Hi,
> I have designed the program. You can see this here. It is a basic GUI program 
> where I generate figures using a key event. The figures can be dragged but I 
> noticed one thing which was if any of the figures overlap then when the 
> figure which is on top is dragged the one below is also dragged. You run it 
> with (run 0) and then press 'n' to generate new figures on the center of the 
> canvas.
> 
> 
>> On Sat, Oct 4, 2014 at 9:50 PM, Matthias Felleisen  
>> wrote:
>> 
>> Yes, it's your choice whether one circle moves or both.
>> 
>> If this is related to a course, you need to design the program so that this 
>> mailing list can help you with where you're stuck.
>> 
>> If you're trying to find a good GUI toolbox, then I'd recommend using the 
>> underlying one instead. The big-bang construct is used for teaching design.
>> 
>> 
>> On Oct 4, 2014, at 9:47 PM, Animesh Pandey wrote:
>> 
>> > Hi,
>> > I am using big-bang to create a simple GUI application where I am dragging 
>> > two solid circles.
>> > Suppose I drag one circle on top of another and release the mouse button 
>> > and then when I click both circles move together. Is there away I can 
>> > avoid this? I want the circle on the top to move and not the one under it.
>> >
>> > Thanks
>> > 
>> >  Racket Users list:
>> >  http://lists.racket-lang.org/users
> 
> 
>  Racket Users list:
>  http://lists.racket-lang.org/users

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] TR and ports (in two senses)

2014-05-18 Thread Jordan Johnson
Okay. Thanks! --jmj

On May 18, 2014, at 1:52 PM, Asumu Takikawa wrote:

> On 2014-05-16 10:04:17 -0700, Jordan Johnson wrote:
>>   As part of familiarizing myself with Typed Racket I thought I'd port one
>>   or two of the untyped Racket libraries to TR. This raised a few questions:
>>   1) Looking at the TR docs and GitHub repo, AFAICT new library ports go
>>   in pkgs/typed-racket-pkgs/typed-racket-more/typed -- is that right?
> 
> Yes, that's right. Though in the long term with packages, I wonder if we
> should have separate packages for the typed versions of libraries.
> 
>>   2) I don't see documentation or tests for other ported libraries in
>>   general, presumably because they're just wrappers; so, does it suffice to
>>   submit only one file -- the library itself -- or are there more files I'm
>>   not noticing, that go with each library? (Seems I should be documenting
>>   the types I define, but I don't see where those docs would go.)
> 
> You're right, we don't currently have docs or tests in place for those
> wrappers. If you'd like to add some tests, it would probably make sense
> to put them under `typed//tests` or `typed/tests/`
> perhaps.
> 
>>   3) One of the libs I looked at porting, openssl, raised a question about
>>   subtyping: SSL ports. It appears to me that internally these are standard
>>   Racket input/output ports tagged as special by the openssl library. It
>>   seems straightforward enough to create an opaque type like
>> 
>> (require/opaque-type SSL-Port ssl-port? openssl)
>> 
>>   but that doesn't capture the idea that every ssl-port should also be of
>>   type Input-Port or Output-Port (as defined in TR already). First, is that
>>   idea correct? And if so, what piece am I missing, to make that happen?
> 
> Unfortunately, there isn't currently a good way to specify that a
> datatype implements an "interface" like being a port, a synchronizable
> event, etc. in Typed Racket.
> 
> For this case, it probably makes sense to just use the built-in Port
> types, which makes the types less precise but it'll work. So you'd give
> `ssl-abandon-port` a type like `(-> Port Void)`. Similarly, the
> `tcp-abandon-port` function has that same type even though it's supposed
> to only take tcp-ports.
> 
> Cheers,
> Asumu



  Racket Users list:
  http://lists.racket-lang.org/users


[racket] TR and ports (in two senses)

2014-05-16 Thread Jordan Johnson
Hi all,

As part of familiarizing myself with Typed Racket I thought I'd port one or
two of the untyped Racket libraries to TR. This raised a few questions:

1) Looking at the TR docs and GitHub repo, AFAICT new library ports go
in pkgs/typed-racket-pkgs/typed-racket-more/typed -- is that right?

2) I don't see documentation or tests for other ported libraries in
general, presumably because they're just wrappers; so, does it suffice to
submit only one file -- the library itself -- or are there more files I'm
not noticing, that go with each library? (Seems I should be documenting the
types I define, but I don't see where those docs would go.)

3) One of the libs I looked at porting, openssl, raised a question about
subtyping: SSL ports. It appears to me that internally these are standard
Racket input/output ports tagged as special by the openssl library. It
seems straightforward enough to create an opaque type like

(require/opaque-type SSL-Port ssl-port? openssl)

but that doesn't capture the idea that every ssl-port should also be of
type Input-Port or Output-Port (as defined in TR already). First, is that
idea correct? And if so, what piece am I missing, to make that happen?

Best,
jmj

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Memory usage stat?

2014-03-05 Thread Jordan Johnson
Hi all,

This seems like it should be stupidly obvious, but I've been looking
through the DrRacket manual and can't find an answer to this question:

In the DrRacket status bar, what exactly does the memory quantity (to the
immediate left of the GC icon box) represent? It doesn't seem to correlate
to (current-memory-use) or anything else I can confidently discern.

(Needless to say, this seems like it should be in the manual...)

Best,
jmj

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] converting GRacket editor file to HTML or PDF?

2013-09-29 Thread Jordan Johnson
I'm working on some little conveniences like that, and already have some code 
that I'm using for writing student assignments to PDFs:
 http://jjohnson.kirby.org/tmp/handin-pdfs.rkt

I call that code from a checker that generates a report on which of the 
assigned functions/constants are defined and so on; it writes the report to a 
text%, which gets inserted at the top of the text% that contains the student's 
submission. Then I give most of my feedback by marking up the PDFs on my 
tablet. Overall, this has been about as pleasant a workflow as I've found for 
grading programs.

Best,
Jordan

> On Sep 17, 2013, at 11:22 AM, n...@cs.tufts.edu (Norman Ramsey) wrote:
> 
> I've just received a stack of forty homework submissions which
> I'd like to page through quickly *en masse*.  But they are in
> GRacket editor format, which means that using my usual pager
> is not profitable.Is there a way to take a file in this
> format and turn it into relatively readable PDF, or even HTML?
> I am willing to write code to do this, and I'm willing to skip
> the images.  But I don't know where to begin.
> 
> 
> Norman
> 
> 
>  Racket Users list:
>  http://lists.racket-lang.org/users


  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Handin server checker scripts

2013-08-27 Thread Jordan Johnson
Not recently, but I'd like to do so as a part of this, and once I've started to 
address my major motivations for undertaking this work, I expect the style 
guide will give me some more ideas.  Thanks for the suggestion.

Best,
Jordan

On Aug 26, 2013, at 3:43 PM, Matthias Felleisen  wrote:

> 
> Have you considered mining the style guide for such rules? -- Matthias
> 
> 
> 
> 
> On Aug 26, 2013, at 2:03 PM, Jordan Johnson wrote:
> 
>> Hi all,
>> 
>> This fall I'm planning to be doing some further work towards a framework for 
>> writing briefer checker scripts for Eli's handin server, including 
>> assessment of indentation and common poor idioms like (if X true false), for 
>> which Eli has provided me a script (code-ayatollah.rkt) that he's used in 
>> the past.
>> 
>> If any of you have done any work recently on this that you'd be willing to 
>> share, would you please send me a note?  I plan to share the results of my 
>> work with the Racket community when I've got some reliable code I'm 
>> satisfied with.
>> 
>> Thanks,
>> Jordan Johnson
>> 
>> 
>> 
>> Racket Users list:
>> http://lists.racket-lang.org/users
> 


  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Handin server checker scripts

2013-08-26 Thread Jordan Johnson
Hi all,

This fall I'm planning to be doing some further work towards a framework for 
writing briefer checker scripts for Eli's handin server, including assessment 
of indentation and common poor idioms like (if X true false), for which Eli has 
provided me a script (code-ayatollah.rkt) that he's used in the past.

If any of you have done any work recently on this that you'd be willing to 
share, would you please send me a note?  I plan to share the results of my work 
with the Racket community when I've got some reliable code I'm satisfied with.

Thanks,
Jordan Johnson



  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Some guidance and help for Section 4.5.1

2013-04-27 Thread Jordan Johnson

On Apr 27, 2013, at 10:35 PM, Da Gamer wrote:

> First, I'm working on problem: How To Design Programs, 2nd Edition (Chapter 
> 4, Section 4.5.1).
> [...]
> However, the code feels  wrong. As if I didn't do it the Scheme way. It's 
> like writing C with classes and not idiomatic C++. It works, but it's wrong.
> 
> So any tips, hints, pointing in the right direction, would be greatly 
> appreciated.

[In the following, I'm using text from your first solution, but what I'm saying 
applies equally well to your second solution.]

It looks like the problem you're up against is that, beyond 
insert-everywhere/in-one-word, the function specifications are vague:

; 1-str list-of-word -> list-of-word
; create combinations of word in list-of-word
(define (create-combinations ins-ltr a-low) ...)

One of the questions we ask in the Design Recipes is, "What is the result of 
the recursive call producing?"  Here, for example, the recursive call is

(create-combinations ins-ltr (rest a-low))

and according to the purpose statement, it could be said to produce 
"combinations of word in (rest a-low)".  But what does that mean?  The purpose 
statement speaks as though word is a parameter, but it's not -- you have 
ins-ltr and a-low.  Also, what does it mean by "combinations"?  This is not 
clear, and so you can clarify both by rewriting the purpose statement and 
choosing a more descriptive function name.

So, here is what I would recommend:  Ask yourself what the function must 
produce from (first a-word) and (insert-everywhere/in-one-word a-1str (rest 
a-word)) in insert-everywhere/in-one-word.  And don't be satisifed until you 
have an answer that contains no vagueness at all.

Now, answering that question is probably not easy, and this is where the rest 
of the Design Recipe is useful:

1) Write a couple of test cases for insert-everywhere/in-one-word.  Specific 
data is almost always easier to think about than abstract names.  At very 
least, make a test case for a 1-letter word w1 and another for a 2-letter word 
w2, such that w1 is (rest w2).

2) In those test cases, identify what (first a-word) and 
(insert-everywhere/in-one-word a-1str (rest a-word)) are.  Compare those data 
to your test cases' desired results, since those results are what 
create-combinations must produce from those two pieces of data.  Use these data 
to make a test case for create combinations.

3) If you can come up with a plain-English description of what 
create-combinations must do, then great! write a purpose statement for it (and 
perhaps change the name to something nicely descriptive of what you want).  If 
not, try making a larger test case (e.g., a word w such that (rest w) is your 
two-letter word from earlier), and repeat the process.  Eventually you will 
most likely see a pattern you can describe.

This is a tough problem, but taking the time to find the simple solution is 
worth it IMO.  Your intuition is good.  Keep at it.

Best,
jmj


  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Game-pad support

2013-04-26 Thread Jordan Johnson
Hi all,

Idle curiosity: does the relatively recent addition of on-pad to the 
2htdp/image library actually add support for plugging in a gamepad and using it 
as a controller?  The use of the word "simulation" in the docs suggests 
otherwise, but (not owning game hardware to test it myself) I can't tell for 
sure without digging through the source.

Best,
Jordan
  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] File name case when saving in Win 7

2013-03-04 Thread Jordan Johnson
Thanks to all for the replies, and to Robby for the fix.

Best,
jmj 
-- 
Sent from my Android phone with K-9 Mail.

Robby Findler  wrote:

>I've pushed a change that simply removes the call to normal-case-path.
>I
>expected to be able to break DrRacket after making that change, but I
>wasn't able to. Still, since this kind of change can lead to all kinds
>of
>bad behavior in surprising places, I'd be most grateful if others got
>that
>commit and started using things and let me know if goes wrong ...
>
>Thanks for the help / reminders of this problem, too
>
>Robby
>
>
>On Sat, Mar 2, 2013 at 2:10 PM, David T. Pierson 
>wrote:
>
>> On Fri, Mar 01, 2013 at 10:59:06PM -0700, Danny Yoo wrote:
>> > In "framework", the implementation does use normal-case-path in its
>> > implementation for put-file:
>> >
>> >
>>
>http://git.racket-lang.org/plt/blob/HEAD:/collects/framework/private/finder.rkt#l50
>>
>> So that explains the cause, but what is the motivation behind this
>> behavior?  I tested saving a new file in the following apps on
>Windows:
>>
>> DrRacket
>> Firefox
>> Notepad
>> WordPad
>> Adobe Reader
>> gVim
>>
>> Only DrRacket changes the case of the file name that the user
>specifies.
>>
>> Searching the bug database I see there is an open case for this:
>>
>>
>>
>http://bugs.racket-lang.org/query/?cmd=view%20audit-trail&database=default&pr=6086
>>
>> ... from 2003!
>>
>> Maybe a solution is more readily available now?
>>
>> David
>> 
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] File name case when saving in Win 7

2013-03-01 Thread Jordan Johnson
Just realized I should clarify something about the following:

On Feb 25, 2013, at 5:51 PM, Jordan Johnson wrote:
> I have noticed that in Windows, DrRacket seems to be normalizing all file 
> names to lowercase when I save.  Is it possible to alter this behavior? (I.e. 
> is there some preference or setting I'm missing that would make it preserve 
> case?  I've searched the docs and Web for terms such as "file name case", but 
> come up dry.)

I'm referring specifically to the behavior when saving a file under a new name 
for the first time.  I.e., if a file is already named "MyRacketProgram.rkt", 
DrRacket preserves the name, but if I choose "Save As" and type in a similarly 
mixed-case (or all-uppercase) name that results in creating a new file, 
DrRacket lowercases all the letters in the filename I request.

I hope this is a clear enough explanation of what I'm asking about.

Thanks,
jmj



  Racket Users list:
  http://lists.racket-lang.org/users


[racket] File name case when saving in Win 7

2013-02-25 Thread Jordan Johnson
Hi all,

I have noticed that in Windows, DrRacket seems to be normalizing all file names 
to lowercase when I save.  Is it possible to alter this behavior? (I.e. is 
there some preference or setting I'm missing that would make it preserve case?  
I've searched the docs and Web for terms such as "file name case", but come up 
dry.)

Best,
Jordan

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] what's wrong with my code?

2013-01-20 Thread Jordan Johnson
For one thing, the question you are asking in the code,
(> i 4)  ;; i.e., i > 4
is not the same question you ask in your equations,
n < 4
so, for starters, it would seem you need the two questions to be in agreement.

Best,
jmj 
-- 
Sent from my Android phone with K-9 Mail.

Robert Hume  wrote:

>I'm really stuck trying to figure this out.  Any pointers are useful!
>Here's the problem:
>
>f(n) = n if n<4
>and
>f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) + 4f(n - 4) if n>= 4
>
>Here's my solution so far -- any one know what I'm doing wrong?
>
>(define (f n)
>
>  (define (f-iter result i)
>(if (> i 4)
>result
>(f-iter (+ result (* i (- n i))) (+ i 1))
>)
>  )
>
>  (if (< n 4)
>  n
>  (f-iter 0 1)
>  )
>
>)
>
>(f 4) ;; should produce 10, produces 10
>(f 5) ;; should produce 26, produces 20
>(f 6) ;; should produce 63, produces 30
>
>
>
>
>
>  Racket Users list:
>  http://lists.racket-lang.org/users

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] FIXED Re: Setting font for drawing to dc%

2012-12-07 Thread Jordan Johnson
Ah, that could work nicely since I may eventually want to be inserting some 
other stuff in the editor for printing, anyway. (Currently I'm inserting a 
simple rubric -- which I generate using web-server/templates -- at the top, but 
it will be nice to have a checker that inserts some comments at the site where 
they're relevant, too.)  So I may indeed switch over to that method.

Thanks again!

Best,
jmj 
-- 
Sent from my Android phone with K-9 Mail.

Robby Findler  wrote:

>It looks like unpack-submission creates only text% objects, not
>text:racket% objects. But I think you can iterate over the snips in
>teh editor (find-first-snip method on the text% and next on teh snip%)
>and use the copy method of the snip to create new ones to insert into
>a text:racket% object. Then if you just call freeze-colorer, you'll
>get the fixed width font (without explicitly setting the style) and
>you'll get the syntax highlighting.
>
>Robby
>
>On Fri, Dec 7, 2012 at 3:14 PM, Jordan Johnson 
>wrote:
>> Hi Robby, Matthew,
>>
>> Thanks for the replies.  Robby, that was exactly what I needed, since
>I hadn't thought to look at the text% hierarchy recently for style
>changes.  (Even knowing that, it took a while to work it out; owing to
>my not having a full understanding of what triggers a reload of files
>the checker depends on, I didn't get the version below to work until I
>manually restarted the server. But it's all good now.  Also of
>interest: I learned that even if I set the style correctly as below, if
>I subsequently set the font to fixed-width in the dc as I'd erroneously
>been doing, the text reverted to the non-fixed sans serif.  That was
>surprising!)
>>
>> Here is my corrected, working code:
>>
>> #lang s-exp handin-server/checker
>>
>> (require racket/gui/base racket/class  ;; for PDF rendering
>>  racket/draw)
>>
>>
>> (define fixed-width
>>   (send (new style-delta%) set-delta 'change-family 'modern))
>>
>> ;; make-pdf : String text% -> any
>> ;; Generates a PDF of the given Definitions window, saved in
>> ;; /tmp/test-pdf-writing.pdf:
>> (define (make-pdf file defs)
>>   (define dc (new pdf-dc%
>>   [interactive #f]
>>   [output "/tmp/test-pdf-writing.pdf"]))
>>   (send defs select-all)
>>   (send defs change-style fixed-width)
>>   (send dc start-doc "")
>>   (send defs print-to-dc dc -1)
>>   (send dc end-doc))
>>
>> (check: :language '(special beginner)
>> :textualize? #t
>> (define user-string
>>   (if (list? users) (apply string-append users) users))
>> (define-values (defs ints) (unpack-submission submission))
>> (make-pdf user-string defs))
>>
>> ;; end
>>
>> I suppose there are two remaining questions: does freeze-colorer need
>to be called even if the text% in question is not displayed, and where
>is the latest it can be called in the sequence above?
>>
>> Best,
>> Jordan
>>
>> On Dec 7, 2012, at 4:21 AM, Robby Findler
> wrote:
>>
>>> Code would help understand, but setting the font in the dc isn't the
>>> way to go: you want the styles to be right (which is what
>racket:text%
>>> does). And you'd need to call freeze-colorer to wait for the
>coloring
>>> to finish, too, but that would affect only the colors, not the
>fonts.
>>>
>>> Robby
>>>
>>> On Fri, Dec 7, 2012 at 5:56 AM, Matthew Flatt 
>wrote:
>>>> I'm not sure. Can you provide a small program that illustrates the
>problem?
>>>>
>>>> At Fri, 7 Dec 2012 00:26:47 -0800, Jordan Johnson wrote:
>>>>> Hi all,
>>>>>
>>>>> I was delighted to find awhile back that it's pretty easy to
>obtain a PDF of
>>>>> syntax-colored code that looks more or less like what I see in my
>DrRacket
>>>>> window, by drawing the text% to a PDF-dc%.  I am now using that in
>conjunction
>>>>> with the handin server to grade and mark up student work on my
>iPad (annotating
>>>>> the PDFs via GoodReader and emailing them straight back to
>students), and it
>>>>> works beautifully. (I am happy to share the code for this with
>anyone who is
>>>>> interested; email me if so.)
>>>>>
>>>>> One glitch: I can't get Racket to give me a fixed-width font in
>the PDF.  I
>>>>> have tried inserting
>>>>>  (send dc set-font (make-object 

[racket] FIXED Re: Setting font for drawing to dc%

2012-12-07 Thread Jordan Johnson
Hi Robby, Matthew,

Thanks for the replies.  Robby, that was exactly what I needed, since I hadn't 
thought to look at the text% hierarchy recently for style changes.  (Even 
knowing that, it took a while to work it out; owing to my not having a full 
understanding of what triggers a reload of files the checker depends on, I 
didn't get the version below to work until I manually restarted the server. But 
it's all good now.  Also of interest: I learned that even if I set the style 
correctly as below, if I subsequently set the font to fixed-width in the dc as 
I'd erroneously been doing, the text reverted to the non-fixed sans serif.  
That was surprising!)

Here is my corrected, working code:

#lang s-exp handin-server/checker

(require racket/gui/base racket/class  ;; for PDF rendering
 racket/draw)


(define fixed-width
  (send (new style-delta%) set-delta 'change-family 'modern))

;; make-pdf : String text% -> any
;; Generates a PDF of the given Definitions window, saved in
;; /tmp/test-pdf-writing.pdf:
(define (make-pdf file defs)
  (define dc (new pdf-dc%
  [interactive #f]
  [output "/tmp/test-pdf-writing.pdf"]))
  (send defs select-all)
  (send defs change-style fixed-width)
  (send dc start-doc "")
  (send defs print-to-dc dc -1)
  (send dc end-doc))

(check: :language '(special beginner)
:textualize? #t
(define user-string
  (if (list? users) (apply string-append users) users))
(define-values (defs ints) (unpack-submission submission))
(make-pdf user-string defs))

;; end

I suppose there are two remaining questions: does freeze-colorer need to be 
called even if the text% in question is not displayed, and where is the latest 
it can be called in the sequence above?

Best,
Jordan

On Dec 7, 2012, at 4:21 AM, Robby Findler  wrote:

> Code would help understand, but setting the font in the dc isn't the
> way to go: you want the styles to be right (which is what racket:text%
> does). And you'd need to call freeze-colorer to wait for the coloring
> to finish, too, but that would affect only the colors, not the fonts.
> 
> Robby
> 
> On Fri, Dec 7, 2012 at 5:56 AM, Matthew Flatt  wrote:
>> I'm not sure. Can you provide a small program that illustrates the problem?
>> 
>> At Fri, 7 Dec 2012 00:26:47 -0800, Jordan Johnson wrote:
>>> Hi all,
>>> 
>>> I was delighted to find awhile back that it's pretty easy to obtain a PDF of
>>> syntax-colored code that looks more or less like what I see in my DrRacket
>>> window, by drawing the text% to a PDF-dc%.  I am now using that in 
>>> conjunction
>>> with the handin server to grade and mark up student work on my iPad 
>>> (annotating
>>> the PDFs via GoodReader and emailing them straight back to students), and it
>>> works beautifully. (I am happy to share the code for this with anyone who is
>>> interested; email me if so.)
>>> 
>>> One glitch: I can't get Racket to give me a fixed-width font in the PDF.  I
>>> have tried inserting
>>>  (send dc set-font (make-object font% 12 'modern))
>>> where dc is my pdf-dc%, and alternately
>>>  (send dc set-font (send the-font-list find-or-create-font 12 'modern 
>>> 'normal
>>> 'normal))
>>> but in both cases the generated PDF is still in a sans-serif non-fixed-width
>>> font.  It does not seem to matter whether I put the above lines before or 
>>> after
>>> the
>>>  (send dc start-doc "")
>>> that begins the drawing process.
>>> 
>>> Interestingly, in a test I ran just now, if I generate a PDF by directly
>>> creating a racket:text% object, putting some Racket program text in it, and
>>> calling the same make-PDF function I use in the handin-server (calling 
>>> set-font
>>> using the-font-list, as described above), it gives me fixed-width text as 
>>> I'd
>>> expect.  That's regardless of whether I set the font before or after the
>>> start-doc command. (racket:text% is just a guess at the text% subclass that 
>>> the
>>> handin server is providing, based on it being a representation of the
>>> Definitions window.)
>>> 
>>> Any ideas how to solve this, or further tests I could run to determine the
>>> cause?
>>> 
>>> Thanks for your consideration,
>>> Jordan
>>> 
>>>  Racket Users list:
>>>  http://lists.racket-lang.org/users
>> 
>>  Racket Users list:
>>  http://lists.racket-lang.org/users


  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Setting font for drawing to dc%

2012-12-07 Thread Jordan Johnson
Hi all,

I was delighted to find awhile back that it's pretty easy to obtain a PDF of 
syntax-colored code that looks more or less like what I see in my DrRacket 
window, by drawing the text% to a PDF-dc%.  I am now using that in conjunction 
with the handin server to grade and mark up student work on my iPad (annotating 
the PDFs via GoodReader and emailing them straight back to students), and it 
works beautifully. (I am happy to share the code for this with anyone who is 
interested; email me if so.)

One glitch: I can't get Racket to give me a fixed-width font in the PDF.  I 
have tried inserting
  (send dc set-font (make-object font% 12 'modern))
where dc is my pdf-dc%, and alternately
  (send dc set-font (send the-font-list find-or-create-font 12 'modern 'normal 
'normal))
but in both cases the generated PDF is still in a sans-serif non-fixed-width 
font.  It does not seem to matter whether I put the above lines before or after 
the
  (send dc start-doc "")
that begins the drawing process.

Interestingly, in a test I ran just now, if I generate a PDF by directly 
creating a racket:text% object, putting some Racket program text in it, and 
calling the same make-PDF function I use in the handin-server (calling set-font 
using the-font-list, as described above), it gives me fixed-width text as I'd 
expect.  That's regardless of whether I set the font before or after the 
start-doc command. (racket:text% is just a guess at the text% subclass that the 
handin server is providing, based on it being a representation of the 
Definitions window.)

Any ideas how to solve this, or further tests I could run to determine the 
cause?

Thanks for your consideration,
Jordan

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Where to hook into handin-server for sandbox-network-guard

2012-12-03 Thread Jordan Johnson
Hi all,

My immediate need for a response to the message below has passed, but I'd still 
like to know for next time, at least if my idea of a solution was accurate.  
Anybody?

Thanks,
jmj 
-- 
Sent from my Android phone with K-9 Mail.

Jordan Johnson  wrote:

>Hi all,
>
>I have my students handing in an assignment via the handin server, in
>which
>I've asked them to use bitmap/url to load a particular image from my
>Web
>server.  This obviously runs afoul of the sandbox  rules, so I looked
>into
>the sandbox configuration docs and believe that what I need to do is
>something like
>
>> (sandbox-network-guard
>>   (lambda (caller host port cli/srv)
>> (unless (and (equal? host "my-server.com")
>>  (= port 80)
>>  (eq? cli/srv 'client))
>>   (error caller
>>  "network permissions denied; failed to contact ~a:~a"
>>  host port
>
>(I would restrict it further to allow only fetching the one particular
>file, but don't see how.)  The question I have is, how should I install
>this lambda in the sandbox-network-guard parameter so that it works
>properly?  The problems I see are:
>
>1. If I simply include the above code before the (check: ...)
>expression,
>it seems to work correctly for  the first assignment handed in, and
>none
>thereafter.
>
>2. Writing (parameterize ([sandbox-network-guard (lambda ...)]) (check:
>...)) doesn't work, because (check: ...) must be at top-level to
>provide
>the checker function.
>
>Thanks,
>jmj
>
>
>
>
>
>  Racket Users list:
>  http://lists.racket-lang.org/users

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Where to hook into handin-server for sandbox-network-guard

2012-11-27 Thread Jordan Johnson
Hi all,

I have my students handing in an assignment via the handin server, in which
I've asked them to use bitmap/url to load a particular image from my Web
server.  This obviously runs afoul of the sandbox  rules, so I looked into
the sandbox configuration docs and believe that what I need to do is
something like

> (sandbox-network-guard
>   (lambda (caller host port cli/srv)
> (unless (and (equal? host "my-server.com")
>  (= port 80)
>  (eq? cli/srv 'client))
>   (error caller
>  "network permissions denied; failed to contact ~a:~a"
>  host port

(I would restrict it further to allow only fetching the one particular
file, but don't see how.)  The question I have is, how should I install
this lambda in the sandbox-network-guard parameter so that it works
properly?  The problems I see are:

1. If I simply include the above code before the (check: ...) expression,
it seems to work correctly for  the first assignment handed in, and none
thereafter.

2. Writing (parameterize ([sandbox-network-guard (lambda ...)]) (check:
...)) doesn't work, because (check: ...) must be at top-level to provide
the checker function.

Thanks,
jmj

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] What is a good way to learn about functions "like" in this case?

2012-11-22 Thread Jordan Johnson
Argmin is a standard math term, but if it's one you haven't encountered, I'm 
not sure how easily you could turn it up in the Racket docs. This is a problem 
I've thought it might be nice to find somebody in a library program to work on; 
they study indexing in depth, and choosing terms to index is a very different 
specialty than programming and language design. (This is to say, I've 
encountered the same difficulties at times, but it's a problem that I think 
Racket shares with most other languages...because the audience for the docs 
contains both subject matter experts who know the terms for what they're 
looking for, and folks who have an idea of what they want to do but don't know 
the (perhaps language-specific) name for it. But then, this is a problem that 
apprentices in all kinds of trades have faced for centuries...)

Best,
Jordan

On Nov 21, 2012, at 2:09 PM, Grant Rettke  wrote:

> Hi,
> 
> Today I saw someone use the 'argmin' function.
> 
> I wondered how I might learn about it from search results. For example
> you know you want the minimum, and you might broadly get back a result
> for example if there was a page on "functions that give you minimums
> generally".
> 
> I tried 'min' and combinations with asterisks before and after and
> never got argmin as a result.
> 
> What might I do to achieve something like this?
> 
> For example, I used AgentRansack and searched the html for 'minimize'
> and that was one way to do it after digging around.
> 
> Best wishes,
> 
> --
> Grant Rettke | ACM, AMA, COG, IEEE
> gret...@acm.org | http://www.wisdomandwonder.com/
> Wisdom begins in wonder.
> ((λ (x) (x x)) (λ (x) (x x)))
> 
> 
>  Racket Users list:
>  http://lists.racket-lang.org/users


  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] DrRacket for the Truly Impatient V02, need help, beta testers

2012-11-21 Thread Jordan Johnson
I'm curious what the objectionable distraction is: the mere presence of the 
arrow, or the action of the arrow's window with contract info popping in and 
out as you mouse over identifiers?

If it's the latter, than perhaps it would help to just put more of a delay (as 
tooltips have) in before exposing the contract info.  (I'm trying to figure out 
why *I* haven't found it a distraction, and maybe it's just because I don't use 
the mouse very much.)

Best,
jmj 
-- 
Sent from my Android phone with K-9 Mail.

Grant Rettke  wrote:

>On Wed, Nov 21, 2012 at 6:29 PM, Nadeem Abdul Hamid 
>wrote:
>> On Wed, Nov 21, 2012 at 7:21 PM, Grant Rettke 
>wrote:
>>> You are an accomplished programmer that got this far without online
>>> compilation that was added this year?
>> Well, I don't know about others, but prior to that becoming
>available, I
>> would often have to keep hitting the "Check syntax" button or key
>command
>> manually. Online compilation is just DrRacket continuously running
>"Check
>> Syntax" for you so you don't have to manually do that - and it *is*
>very
>> convenient and smoothes out the development process, reducing a
>distraction
>> that is otherwise present.
>
>Maybe this would help, I have only used Check Syntax two or three
>times ever when I wanted to rename a variable because it was used in
>more than 5 places. What other problems does it solve?
>
>> Other industrial-strength IDEs (e.g. Eclipse, MS
>> VS, IBM's Java Visual-something- I forget the name) all provide this
>feature
>> of continuous background syntax analysis to enable various types of
>> refactorings and code navigation.
>
>Yea that is nice. My original question was about how to remove the
>arrows and the thing in the upper right hand corner, and the solution
>was to disable online compilation. Is there way just to remove that
>stuff but keep the online compilation stuff?
>
>> Another nice thing about online
>> compilation is the additional feature of being able to view snippets
>of
>> function signatures (i.e. help) right in the corner of the editor.
>
>That arrow is so distracting. Can we move it into the status line on
>the bottom?
>
>Thanks for explaining why you value it.
>
>  Racket Users list:
>  http://lists.racket-lang.org/users

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Scheme's place in the world

2012-11-21 Thread Jordan Johnson

On Nov 20, 2012, at 9:19 PM, Hugh Aguilar wrote:
> The only way to make money is by selling circuit-boards that do something 
> useful --- and those boards have to be programmed somehow, which is where 
> Straight Forth comes in. Boards are a product that can be sold. Software is 
> not a product ---

Notwithstanding everything else you've said, the above isn't seriously 
defensible, given all the software that runs on servers that we interact with 
daily and all the apps that we purchase and download to run on smartphones and 
tablets.  Somebody writes that, and somebody's making money off it.  Yes, the 
80s/90s model of shrinkwrapped off-the-shelf software is mostly gone, but it's 
an absurd leap to claim that that means the software business is gone.

Regards,
jmj



  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] handin server bugs? (was Re: handin server error)

2012-11-20 Thread Jordan Johnson
Many thanks for the response, Matthew.  When I realized (after posting) that 
v5.3 changed the server's behavior, I just started running the server under the 
5.2 installation I still had on my Mac, but I will pull down the new version 
with your fixes sometime soon, so thanks a bunch!

Working with the handin server has been teaching me plenty about eval, the 
sandbox, namespaces, and various other bits of Racket functionality, btw.  Fun 
stuff, in spite of the occasional frustrations.

Best,
Jordan

On Nov 19, 2012, at 7:26 AM, Matthew Flatt  wrote:

> At Sat, 17 Nov 2012 16:31:23 -0800, Jordan Johnson wrote:
>> -- 1 --
>> 
>> Starting a checker file with "#lang handin-server/checker" (as the 
>> handin-server/checker docs suggest) does not work; the log file indicates 
>> the 
>> server is failing to load the checker, with this error:
>> 
>> standard-module-name-resolver: collection not found
>> collection: "handin-server/checker/lang"
>> 
>> Using "#lang s-exp handin-server/checker" seems to work, but I can't tell if 
>> there are other related problems that this fix is merely hiding.
> 
> I'm inclined to call that a documentation bug, but I will also make
> `#lang handin-server/checker' work.
> 
>> -- 2 --
>> 
>> I can create and run checker files that define a trivial checker function 
>> explicitly (i.e., without using the "check:" form from 
>> handin-server/checker), 
>> but it appears that if I do anything that creates an evaluator -- be it 
>> using 
>> make-evaluator/submission (or the other make-evaluator* functions, whether 
>> I'm 
>> require'ing them from handin-server/sandbox or directly from racket/sandbox) 
>> or 
>> using "check:" -- when the client attempts to hand in, I get an error from 
>> namespace-attach-module, quoted below in my original message. For example, 
>> this 
>> triggers the error:
>> 
>>#lang racket
>> 
>>(require racket/sandbox)
>>(provide checker)
>> 
>>(define (checker users submission)
>>  (define e (make-evaluator '(special beginner)))
>>  "save-it-here.rkt")
> 
> I finally tracked this down to an assumption that `racket/base' was
> reachable from `mred/private/mred' (which ceased to be true at some
> point in the never-ending `scheme' to `racket' conversion) along with a
> mismatch between `gui-require-dynamic' and its documentation. I've
> pushed a repair to both of those problems.
> 
> I think we could work around the problem in v5.3.1, but it sounds like
> you're using the latest via git to get the handin server, anyway.
> 
> 
>> By the way, is it possible to write automated tests for a checker script 
>> that 
>> uses #lang handin-server/checker -- as opposed to testing it interactively 
>> using the client?
> 
> I'm pretty sure that I've `require'd the `checker' function from a
> `handin-server/checker' module to call it directly, but I don't
> remember the details.
> 


  Racket Users list:
  http://lists.racket-lang.org/users


  1   2   >