[racket-users] [HtDP/2e & ISL+] Stepper and "seeming" accidental name capture

2016-01-28 Thread Paolo Giarrusso
Hi again everybody!

My supervisor (Prof. Klaus Ostermann) noticed an issue with DrRacket's stepper 
in ISL+ (with Racket 6.2.1) and name capture. One could argue there's a 
straightforward name capture bug, but I think this is more confusing. For extra 
fun, as far as I can tell from quickly skimming, the beta rule described by 
HTDP/2e for ISL+ does not mention renaming (though renaming seems mentioned 
instead for `local`).

Concretely, consider this snippet and note the two bindings for `y`:

(define y 5)
(((lambda (g) (lambda (y) (g y))) (lambda (x) (+ x y))) 8)

The stepper applies the beta rule to `lambda (g)` without renaming:

(define y 5)
((lambda (y)
   ((lambda (x) (+ x y)) y))
 8)

By just looking at this snippet, one would say that accidental capture 
occurred: the occurrence of `y` that was bound by the outer definition is now 
bound by the inner binding for `y`.

However, the next evaluation step shows that the binding structure was not 
corrupted:

(define y 5)
((lambda (x) (+ x y)) 8)

I interpret this as "there are two distinct variables that both render to `y`", 
but this possibility does break lots of assumptions — and there's no way to 
guess the intended semantics of the second step, since no arrows are shown.*

Is the intended semantics of variable names the standard one? If so, I guess 
the stepper should actually alpha-rename abstractions at some step, and HtDP 
should be adapted. Probably the alpha-renaming should be done right before the 
offending beta-reduction.

*Which reminds me: why can't the stepper reuse the existing code for this 
functionality? You might need to use two separate editors, but that might be 
anyway an usability improvement (frankly, I didn't expect selection to work 
correctly in the stepper window).

Cheers,
Paolo

-- 
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] Re: [HtDP/2e & ISL+] Stepper and "seeming" accidental name capture

2016-01-28 Thread Paolo Giarrusso
On Thursday, January 28, 2016 at 4:51:54 PM UTC+1, Paolo Giarrusso wrote:
> My supervisor (Prof. Klaus Ostermann) noticed an issue with DrRacket's 
> stepper in ISL+ (with Racket 6.2.1) and name capture.

Update: My supervisor also filed a ticket on this: 
http://bugs.racket-lang.org/query/?cmd=view=15231

Cheers,
Paolo

-- 
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: [racket-dev] Re: Happy Module Day!

2015-12-21 Thread Paolo Giarrusso
On Friday, December 11, 2015 at 3:22:59 PM UTC+1, Brian Adkins wrote:
> On Friday, December 11, 2015 at 9:06:16 AM UTC-5, Matthew Flatt wrote:

> I think maybe an xargs limit is being reached or something - when I scroll 
> up, I see another total line is displayed for .rkt, so it's:

Yes, that's the specified semantics for xargs — since POSIX allows the OS to 
bound the command line length, foo | xargs bar might call bar multiple times, 
while bar $(foo) will call bar only once or fail when the implementation 
restriction triggers.

-- 
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] Typed Racket: Is (- 1 1) equivalent to (- 2 2)?

2015-12-11 Thread Paolo Giarrusso
On Friday, December 11, 2015 at 1:21:04 AM UTC+1, Matthias Felleisen wrote:
> On Dec 10, 2015, at 3:04 PM, Klaus Ostermann wrote:
> 
> > Thanks for the clarification, Sam. What you write makes sense.
> > 
> > However, since the default case (without explicit annotations) is that I 
> > get these very (too?) precise singleton types, I have the impression that 
> > reasoning about (typed) program equivalence is more difficult in TR than in 
> > standard statically typed languages. 
> > 
> > Aren't types supposed to be a device for abstraction and for supporting 
> > information hiding? Singleton types seem to be against that spirit by 
> > exposing "implementation details" of the terms, such as the difference 
> > between (- 1 1) and (- 2 2).
> 
> 
> I don't think gradual/incremental type systems play this role. But it is an 
> open question how we can enrich such type systems with types as abstraction 
> barriers. -- Matthias

What is the problem there? We've discussed singleton types, but arguably they 
don't really impede abstraction *in the large* — you just need to upcast your 
implementation to the intended interface. Ignoring performance problems, TR 
supports even abstract types — so what's left?

I'm not sure that *letting your interface be type-infererred* is safe in any 
language, though it might work in practice to some extent in some (Haskell?). 
For Scala, we know from experience it's unsafe even in practice.

I agree that upcasting to fix the original example would look silly, but the 
major point of abstraction is for use in the large anyway, isn't it?

-- 
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] Typed Racket: Is (- 1 1) equivalent to (- 2 2)?

2015-12-10 Thread Paolo Giarrusso

On Thursday, December 10, 2015 at 8:26:02 PM UTC+1, Klaus Ostermann wrote:
> > I don't think any typed language respects this. For example:
> > 
> >(if (= 1 1) #f "not a boolean")
> > 
> > is equal to #f, but many type systems do not let you replace #f with
> > that expression. 
> 
> But in statically typed languages you usually have a typed equivalence 
> relation like
> 
> \Gamma |- t1 == t2 : T
> 
> Your example would not be well-typed in standard statically typed languages, 
> hence one would not reason that it is equal to #f.
> 
> So I think my argument that usually you can replace "equals by equals" 
> according to the typed equivalence relation holds.
> 
> Presumably the property still holds in Typed Racket, but with regard to a 
> much smaller equality relation in which many equations that one would 
> intuitively expect to be true are not true.

> > In general, if you define "equals" in "replacing equals for equals" by
> > reference to underlying observable equivalence relation induced by an
> > untyped semantics, then you certainly cannot have this design
> > principle.
> 
> I agree that that's not true, but usually I would expect a statically typed 
> language to have a typed equivalence relation |- t1 == t2 : T such that if E 
> is an evaluation context, then E[t1] is welltyped iff E[t2] is welltyped.
> 
> I think you can also define that equivalence relation for Typed Racket, but 
> it would be rather small. 

I guess that typed equivalence is in fact bigger; what's different is a 
different relation. (Please prepend "I guess" to _all_ my claims in this email).

1. I think the results you're quoting (especially the second) are corollaries 
of the substitution lemma; to show that, get E[t1] and E[T2] through 
substitution from E[x], where x is fresh with type T. While Typed Racket is not 
standard, I'm going to assume it has a traditional substitution lemma.

2. Typed Racket has subtyping, so `|- (- 1 1) = (- 2 2) : Number` holds, as it 
would in a usual language. But we can't substitute a Number in the context of 
the original example:

E[x] = (+ 1 (if (= 0 x) 1 "x"))

There we need an instance of Zero, and `|- (- 1 1) = (- 2 2) : Zero` indeed 
fails.

The equivalence which holds usually but not in TR is another one.

Let's define relation R as `e_1 R e_2` iff expressions e_1 and e_2 receive the 
same strongest type (before evaluation) and evaluate to the same value. This 
relation isn't part of the usual presentation of typical type systems, unlike 
typed equivalence; I'm thinking of both Martin-Löf type theory and Barendregt's 
Pure Type Systems (and unlike the rest of this mail, I'm rather confident of 
this). To be fair, typed equivalence is often only introduced for type systems 
with a conversion rule (like dependent ones).

Then (- 1 1) R (- 2 2) holds in most languages and fails in Typed Racket, 
because TR refines the type of (- 1 1) but not the type of (- 2 2).

Cheers,
Paolo

-- 
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: Typed Racket: Is (- 1 1) equivalent to (- 2 2)?

2015-12-10 Thread Paolo Giarrusso
On Thursday, December 10, 2015 at 6:55:28 PM UTC+1, johnbclements wrote:
> > On Dec 10, 2015, at 9:50 AM, George Neuner  wrote:
> > 
> > On Thu, 10 Dec 2015 12:35:34 -0500, Alex Knauth wrote:
> > 
> >> In typed racket (- 1 1) and (- 2 2) are equal at runtime, but the type
> >> checker doesn't necessarily know that at compile time. It knows that
> >> (- 1 1) is zero because that's a special case in the type system. But it
> >> doesn't have a special case for (- 2 2), so it only knows that that's a
> >> Fixnum. 
> > 
> > But in this case the type checker isn't dealing with variables.  Which
> > begs the question why is (- 1 1) special cased?  Shouldn't there be a
> > general rule: (- C C) where C is a numeric constant?

Or conversely, why was the special case added? Maybe there's an interesting 
reason, but this seems _very_ ad-hoc. And this thread IMHO shows why some 
dislike "ad-hoc" solutions: they solve some problem magically, but it's rather 
hard to know when you can rely on them.

Somebody might object that you just need to look at the definition of `Number` 
and at the type of `-`. I think they'd be making my point for me. Especially if 
you care for types for their documentation value.

But I appreciate some of this is inevitable for occurrence typing — if you go 
for regularity, you end up with the typing rules of type theory, which aren't 
adequate.

> The natural extension to all numbers (each number has its own type) leads 
> (IIUC) to a totally intractable type system.

You're right in the end, but for a subtler reason. Singleton types aren't a 
problem per se — but expecting (- C C) to have type Zero with the current 
approach, on the other hand, would add to the signature of - an entry per 
number.

OTOH, there are decision procedures for Presburger arithmetic and they've been 
used in experimental programming languages in the past for bound checking; I'm 
not familiar enough with them to say whether using them would be too crazy or 
just as crazy as a good research project.

Static analysis researchers have used much fancier stuff, but that's even less 
predictable.

Cheers,
Paolo

-- 
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: Typed Racket: Is (- 1 1) equivalent to (- 2 2)?

2015-12-10 Thread Paolo Giarrusso
On Thursday, December 10, 2015 at 9:11:00 PM UTC+1, Vincent St-Amour wrote:
> Right. That's why we've built tools to get information about these types
> more digestible:
> 
> http://docs.racket-lang.org/ts-reference/Exploring_Types.html

Thanks, I'd seen those but forgot the non-verbose option.

> You may be interested in:
> 
> 
> http://andmkent.com/blog/2015/11/22/new-draft-paper-occurrence-typing-modulo-theories/

Thanks, I had forgot SMT altogether. What's good about Presburger arithmetic is 
that it's predictable — it doesn't get multiplication. But that's indeed very 
restrictive.
I've bookmarked that paper and already skimmed the PADL one.

Cheers,
Paolo

-- 
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] Re: [Racket] Bug with Abstraction Teachpack, posn and BSL with List Abbreviations

2015-12-10 Thread Paolo Giarrusso
On Thursday, December 10, 2015 at 7:15:07 PM UTC+1, Jonathan Brachthäuser wrote:
> In DrRacket 6.2.1 when using the `match` construct as defined in the 
> abstraction teachpack together with posn a strange problem appears.
> 
> When choosing BSL as language the following code just works as expected:
> 
> ```
> (require 2htdp/abstraction)
> (match (make-posn 1 2) [(posn x y) (+ x y)])
> ```
> 
> yields `3`.
> 
> However when choosing "BSL with list abbreviation" the above code gives:
> 
> ```
> ... (posn x y) ...
> function call: expected a function after the open parenthesis, but found a 
> part
> ```
> 
> We can work around the error by using `my-posn` instead (defined below)
> 
> ```
> (define-struct my-posn (x y))
> ```
> 
> Is there any explanation why this happens? Is the abstraction teachpack not 
> designed to work with "BSL with list abbrv" ?

The issue is a missing export in BSL+.

Last time this came up, I submitted a pull request which is still open, so I 
suspect this isn't fixed yet: https://github.com/racket/htdp/pull/16. 
Apparently I only made a pull request and didn't open a thread on this ML, 
which might be part of the problem.

-- 
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] "bad variable linkage" after restarting handin server under load

2015-12-01 Thread Paolo Giarrusso
Hi!
After a new deadline, I got good news and bad news.

# Good news

I think *this* bug is fixed. Evidence: instead of crashing at the
first reboot under load, the server survived to 10-20 automated
reboots with the students submitting en masse without never showing
the bug. So not only the patch makes sense, but it seems to be for the
same bug.

# Bad news

The setup still didn't scale, though this wasn't as bad, and part of
it was due to my setup. One student compared it to new releases from
Blizzard. While our beefy server isn't even remotely sweating O_O.

So I'd like to understand Racket threads and the handin server, to
plan accordingly:

- Does the whole handin server actually run on *one* processor,
because of Racket multithreading?
- What's your largest deployment with active checkers?
- Do you actually use this for HtDP courses, or only for advanced
classes (as a number of signs suggest)?

1. Under load, requesting the home page takes more than 20 seconds, so
my watchdog scripts restarts the server. We have a watchdog script
because when we didn't, the server just hung sometimes, so for our
previous lecture (smaller, only ~100 students instead of 500, and no
checkers) this watchdog script did wonders.
2. Here's the watchdog:
curl --max-time 20 -s
https://handin-ps.informatik.uni-tuebingen.de:7979/ > /dev/null || {
docker restart handin-server-production; }
That's even running every minute :-(

Usually that request takes 20 ms, so (naive me thought) how on Earth
could this balloon to 20 seconds?
Now that I know of Racket threads, I understand: that includes both
the web server and the checkers, together with an unspecified number
of big-bang instances from students. For extra fun, one students
called animate with big-bang as step function — essentially, a sweet
HtDP fork bomb.

I don't expect a patch for this, I'm just trying to understand things
and contemplating workarounds, beyond a more lenient watchdog (or
disabling it altogether and acting by hand), which I guess won't be
enough.

Cheers,
Paolo

On 29 November 2015 at 16:12, Robby Findler <ro...@eecs.northwestern.edu> wrote:
>
>
> On Sunday, November 29, 2015, Paolo Giarrusso <p.giarru...@gmail.com> wrote:
>>
>> On Friday, November 27, 2015 at 3:44:20 AM UTC+1, Robby Findler wrote:
>> > Yes, I think you're right. I originally wrote that because I was
>> > thinking that this code might be involved in evaluating the user's
>> > submission, but I am not pretty sure I was wrong about that.
>>
>> "not pretty sure"?
>
>
> Sorry. No "not".
>
>
>>
>>
>> AFAICS, `auto-reload-value` is used to extract the `checker` binding from
>> the various checker.rkt. but the lock will not be held while running
>> `checker`. (Luckily we're not using hooks, I haven't studied that code).
>
>
> Yes that's also what I noticed and why I sent a second diff. Or did I miss
> another place?

Was just rechecking because of the above confusion. We agree.

-- 
Paolo G. Giarrusso - Ph.D. Student, Tübingen University
http://ps.informatik.uni-tuebingen.de/team/giarrusso/

-- 
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] "bad variable linkage" after restarting handin server under load

2015-11-29 Thread Paolo Giarrusso
On Friday, November 27, 2015 at 3:44:20 AM UTC+1, Robby Findler wrote:
> Yes, I think you're right. I originally wrote that because I was
> thinking that this code might be involved in evaluating the user's
> submission, but I am not pretty sure I was wrong about that.

"not pretty sure"?

AFAICS, `auto-reload-value` is used to extract the `checker` binding from the 
various checker.rkt. but the lock will not be held while running `checker`. 
(Luckily we're not using hooks, I haven't studied that code).

> So, yes I
> agree that putting this into the production server may be worth a try
> (depending on how severe the problem you're having is I suppose).
> 
> It may make sense to try it out yourself a little bit between due
> dates or something. I did some testing, but more is better.

Yes, we have a staging server for that, I think these courses were my first 
time :-).

As a side note, having proper unit tests is somewhat hard though, many 
interfaces seem not designed for testability. (Many side effects get in the 
way; fixing this is easyish but tedious).
I'm almost ready to "unit test" checkers, but haven't looked into automatic 
submissions.

> Also, while I was reading the code again, however, I noticed that my
> diff didn't have enough syncronization. Here's an improved one.

>  (reload-module modspec path)
>  (set! proc (dynamic-require modspec procname))
>  (reload)
> -(lambda xs (reload) (apply proc xs
> +(lambda xs (protect (reload)) (apply proc xs



> diff --git a/info.rkt b/info.rkt
> index 00a42f9..a5686d5 100644
> --- a/info.rkt
> +++ b/info.rkt
> @@ -11,6 +11,7 @@
> "net-lib"
> "pconvert-lib"
> "sandbox-lib"
> +   "rackunit-lib"
>     "web-server-lib"))
>  (define build-deps '("gui-doc"
>   "racket-doc"
> 
> 
> On Thu, Nov 26, 2015 at 6:23 PM, Paolo Giarrusso wrote:
> > On 25 November 2015 at 14:54, Robby Findler wrote:
> >> I'm still not completely
> >> sure, but since you seem to be able to provoke the error, that
> >> emboldens me to suggest you apply the diff below and see if it goes
> >> away.
> >
> > I'm doing this. Annoyingly, I can't force the crash at will yet, and
> > an automated handin-server stress-tester is not in our plans yet :-|.
> >
> >> That diff is probably not what we'd want in the end, since it is too
> >> much locking (we would want a namespace-specific lock not a global
> >> one) but if the error does go away, that means that this is probably
> >> the right place to put the lock in.
> >
> > Makes sense.
> >
> > But for my production environment, I guess that this patch won't
> > overly restrict concurrency: I guess namespaces correspond to checkers
> > in the handin-server, right? So, since I only ever open one
> > assignment, I should only have one namespace anyway?
> >
> > Cheers,
> > Paolo

-- 
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] Contracts vs Signatures for HtDP?

2015-11-28 Thread Paolo Giarrusso
While pointing students at teachpacks for HtDP/2e, one of our tutors correctly 
pointed out that they're not documented using HtDP signatures, but using 
standard Racket contracts. For instance, in big-bang's docs:

> (to-draw render-expr) 
> render-expr: (-> WorldState scene?)

http://docs.racket-lang.org/teachpack/2htdpuniverse.html?q=posn#%28form._world._%28%28lib._2htdp%2Funiverse..rkt%29._big-bang%29%29

Instead, the beginner language seems to use a mixture, alternating between 
"class" `number` and predicate `boolean?`:

http://docs.racket-lang.org/htdp-langs/beginner.html

And in fact, `number` is the style of HtDP/1e, while HtDP/2e uses `Number`.

The differences aren't huge, but I'd guess that sometimes they're noticeable or 
problematic for beginners.

0. Am I mistaking something?
1. Is this intended or are changes planned?
2. How do you deal with this in your courses? Do you teach both signature 
styles? Will this not confuse students?

Cheers,
Paolo

-- 
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] DrRacket fights `racket` on print behavior in `#lang racket/base`

2015-11-27 Thread Paolo Giarrusso
Here's an example showing that this test will not behave consistently in 
DrRacket and Racket, because `print` won't.

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

```
#lang racket/base

(require rackunit
 racket/format)

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

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

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

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

FAILURE
actual: "(list (game-state #0=(posn 150 100) #0# #0#))"
expected:   "(list (game-state (posn 150 100) (posn 150 100) (posn 150 100)))"
name:   check-equal?
location:   
(#
 13 0 279 112)
expression: (check-equal? (~v (list (game-state p p p))) "(list (game-state 
(posn 150 100) (posn 150 100) (posn 150 100)))")

Check failure

```

I thought this boiled down to `print-graph`, but it's already false. I also 
looked into `(current-print)`, thanks Benjamin Greenman's suggestion, but that 
seems to only affect the REPL behavior, not print's.

Cheers,
Paolo

-- 
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] Value printing in REPL and for students

2015-11-27 Thread Paolo Giarrusso
On 27 November 2015 at 03:48, Robby Findler <ro...@eecs.northwestern.edu> wrote:
> DrRacket pulls some shenanigans with the language dialog-based
> teaching languages and it needs some adjust to make things work the
> way you want with printing in 'raco test' and 'racket'.

I fear I've seen that — but this goes beyond teaching languages. I've
opened a separate thread for that.

> Probably there
> isn't a simple path to that precise goal, but maybe there is a way to
> another goal?

> Is it the case that you're trying to get things set up so that output
> that you produce running inside the handin server is suitable to be
> presented to students so that you can tell them that their submission
> failed somehow?

Yeah. With the complication that I'm also running tests of my own. And
that we're perfectionist PhD students, so we're trying to have
checkers with the same quality as the other HtDP material, without
being Racket experts. Mid-semester.

> (In which case, I might just prefix the error message
> with "This is not exactly the error that you will see in DrRacket,
> where you'll get a clearer message. Please run your program there.")

Yeah, I'm afraid we'll have to do something like that. But then, I
also need to reimplement `!test` because of different requirements:
our checkers have tests that users don't have, and must pretty-print
results to report errso

Luckily, I can still copy more of it :-). Meanwhile, I've rediscovered
the libraries in the handin-server which try to do that. There's code
using mzlib/pconvert which gives me more hope, however legacy that
library is declared.

> My hope is to find time to get the #lang htdp/bsl (etc) languages up
> to stuff so that my advice would switch to "use #lang htdp/bsl and all
> will be fine" but I'm not there yet.

That'd be... cool! At least Racket-generated errors would be better.
Still, that doesn't help when implementing `!test` — unless I managed
to do (!eval `(print ,v)). Should try that.

Cheers,
Paolo

> On Thu, Nov 26, 2015 at 6:16 PM, Paolo Giarrusso <p.giarru...@gmail.com> 
> wrote:
>> Hi all!
>>
>> How does the REPL print values? In some circumstances I see graph printing 
>> markers, even though `(print-graph)` is disabled. Because these are error 
>> messages for students using teaching languages, cycle printing is not an 
>> option.
>>
>> messages.rkt> (print-graph)
>> #f
>> messages.rkt> (list (game-state p p p))
>> (list (game-state (posn 150 100) (posn 150 100) (posn 150 100)))
>> messages.rkt> (~v (list (game-state p p p)))
>> "(list (game-state #0=(posn 150 100) #0# #0#))"
>>
>> Funnily, that doesn't happen in DrRacket, but it does happen both in 
>> racket-mode, in my actual production environment, and under raco test. In 
>> particular, test results in DrRacket are the ones I'd want, but are 
>> inconsistent with the ones everywhere else.
>>
>> Apart from being frustrated at parameters, how do I gain control over this?
>>
>> PS: I've just found that `global-port-print-handler` is customized by 
>> DrRacket. That seems incompatible with using `print` and relying on it 
>> producing certain results. I understand that's the point of `print`, but 
>> neither `write` nor `display` does what I want.
>>
>> HTDP code itself uses `~e` (also in htdp/error), but finding the appropriate 
>> handler to install isn't trivial either; and that's not enough, because 
>> sometimes I need to show the source code we evaluated.
>>
>> Sorry for how chaotic is this message — I guess that reflects my confusion 
>> at Racket printing. (I've taken some looks at the relevant documentation, 
>> but not at all of it).
>>
>> Cheers,
>> Paolo
>>
>> --
>> 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.



-- 
Paolo G. Giarrusso - Ph.D. Student, Tübingen University
http://ps.informatik.uni-tuebingen.de/team/giarrusso/

-- 
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] "bad variable linkage" after restarting handin server under load

2015-11-26 Thread Paolo Giarrusso
On 25 November 2015 at 14:54, Robby Findler  wrote:
> I'm still not completely
> sure, but since you seem to be able to provoke the error, that
> emboldens me to suggest you apply the diff below and see if it goes
> away.

I'm doing this. Annoyingly, I can't force the crash at will yet, and
an automated handin-server stress-tester is not in our plans yet :-|.

> That diff is probably not what we'd want in the end, since it is too
> much locking (we would want a namespace-specific lock not a global
> one) but if the error does go away, that means that this is probably
> the right place to put the lock in.

Makes sense.

But for my production environment, I guess that this patch won't
overly restrict concurrency: I guess namespaces correspond to checkers
in the handin-server, right? So, since I only ever open one
assignment, I should only have one namespace anyway?

Cheers,
Paolo

-- 
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] Value printing in REPL and for students

2015-11-26 Thread Paolo Giarrusso
Hi all!

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

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

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

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

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

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

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

Cheers,
Paolo

-- 
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] "bad variable linkage" after restarting handin server under load

2015-11-25 Thread Paolo Giarrusso
Hi all,
it's me, handin server guy again. Sorry to bother.

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

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

==

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

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

Other info:
- Restarting the server does fix the error. Somehow.
- For those unfamiliar with the handin server: it has code which automatically 
reloads checkers, as witnessed by the log above 
(https://github.com/ps-tuebingen/handin/blob/master/handin-server/private/reloadable.rkt).
 But that code doesn't fix the problem.
- Googling suggests that stale compiled code might be there. But the source 
code hadn't changed. (Also, I found no description of how this arises).
- Since the server gets sometimes "stuck", I built a trivial watchdog (a 
cronjob) that restarts the server if the status server becomes too slow. The 
above happened after the server was restarted by the watchdog.

One set of hypothesis:
is it possible that stopping the server at the wrong moment corrupts compiled 
files? (But then, why does the first restart not fix the problem?)
Do you take care to make compilation atomic with `rename`?

However, according to docs, the server is designed to survive brutal restarts.

One non-standard thing I do is that I have a `checker-extras.rkt` module with 
some utilities shared across checkers*, and that's not deployed as part of the 
server (for various reasons), but together with the checkers, so it's loaded 
with (require "../checker-extras.rkt"), and seems to be compiled, probably when 
starting the server. Could this interfere badly with the reloading code or with 
restarting?

*I'm aware of your checker utilities, but here we have slightly different 
requirements.

-- 
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] "bad variable linkage" after restarting handin server under load

2015-11-25 Thread Paolo Giarrusso
Hi and thanks for reacting promptly!

On 25 November 2015 at 13:52, Robby Findler <ro...@eecs.northwestern.edu> wrote:
> I don't know what's going on here, but could it be that two threads
> are, in parallel, trying to load the same implementation of an
> unloaded checker and then stomping on each other?

Interesting! Sounds consistent with the logs:

[2|2015-11-23T14:51:31] (re)loading module from (file
/var/handin_config/info1-teaching-material/checkers/06-Datentypen/REDACTED-USER-NAME/checker.rkt)
[1|2015-11-23T14:51:31] (re)loading module from (file
/var/handin_config/info1-teaching-material/checkers/06-Datentypen/REDACTED-USER-NAME/checker.rkt)

[... error from thread 1, then error from thread 2...]

> The file handin-server/private/reloadable has some dynamic-requires
> without appropriate syncronization around them, at least that I see,
> which seems suspicious.

I don't know if that's *the* problem, but I've probably built a
testcase for it. (I also wonder about the set!, but hopefully they
don't modify global variables).

And unlike I thought, no compiled files get written on the server
(only when testing checkers locally).

Is it still plausible that avoiding checker-extras (or precompiling
it) would help?

BTW, docs don't seem to mention synchronization:
http://docs.racket-lang.org/reference/Module_Names_and_Loading.html?q=dynamic-require#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29
Should I file an issue on those docs? (I'm afraid I couldn't say much though).

Cheers,
Paolo

> On Wed, Nov 25, 2015 at 6:35 AM, Paolo Giarrusso <p.giarru...@gmail.com> 
> wrote:
>> Hi all,
>> it's me, handin server guy again. Sorry to bother.
>>
>> Our handin server started "crashing" with "bad variable linkage" errors at 
>> deadline time (presumably under somewhat high load), and since it happened 
>> twice, I thought I'd report it. Any ideas on what's causing this?
>>
>> After this "crash", the server keeps running, but rejects all submissions 
>> because the same checker keeps not loading.
>>
>> ==
>>
>> [1|2015-11-23T14:51:31] (re)loading module from (file 
>> /var/handin_config/info1-teaching-material/checkers/06-Datentypen/REDACTED-USER-NAME/../checker.rkt)
>> [1|2015-11-23T14:51:33] ERROR: link: bad variable linkage;
>> [1|2015-11-23T14:51:33]  reference to a variable that is uninitialized
>> [1|2015-11-23T14:51:33]   reference phase level: 0
>> [1|2015-11-23T14:51:33]   variable module: 
>> "/var/handin_home/handin/handin-server/checker.rkt"
>> [1|2015-11-23T14:51:33]   variable phase: 0
>> [1|2015-11-23T14:51:33]   reference in module: 
>> "/var/handin_config/info1-teaching-material/checkers/checker-extras.rkt"
>> [1|2015-11-23T14:51:33]   in: submission-eval
>>
>> Bigger log fragment available at 
>> https://gist.github.com/Blaisorblade/7f9c6e7f4f456b588a8a
>>
>> Other info:
>> - Restarting the server does fix the error. Somehow.
>> - For those unfamiliar with the handin server: it has code which 
>> automatically reloads checkers, as witnessed by the log above 
>> (https://github.com/ps-tuebingen/handin/blob/master/handin-server/private/reloadable.rkt).
>>  But that code doesn't fix the problem.
>> - Googling suggests that stale compiled code might be there. But the source 
>> code hadn't changed. (Also, I found no description of how this arises).
>> - Since the server gets sometimes "stuck", I built a trivial watchdog (a 
>> cronjob) that restarts the server if the status server becomes too slow. The 
>> above happened after the server was restarted by the watchdog.
>>
>> One set of hypothesis:
>> is it possible that stopping the server at the wrong moment corrupts 
>> compiled files? (But then, why does the first restart not fix the problem?)
>> Do you take care to make compilation atomic with `rename`?
>>
>> However, according to docs, the server is designed to survive brutal 
>> restarts.
>>
>> One non-standard thing I do is that I have a `checker-extras.rkt` module 
>> with some utilities shared across checkers*, and that's not deployed as part 
>> of the server (for various reasons), but together with the checkers, so it's 
>> loaded with (require "../checker-extras.rkt"), and seems to be compiled, 
>> probably when starting the server. Could this interfere badly with the 
>> reloading code or with restarting?
>>
>> *I'm aware of your checker utilities, but here we have slightly different 
>> requirements.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" gr

[racket-users] list? not in HtDP's BSL

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

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

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

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


[racket-users] DrRacket indentation adds spaces to empty non-top-level lines?

2015-10-21 Thread Paolo Giarrusso
Hi all!

Every time I reindent a file with DrRacket in a Git repository, DrRacket and 
Git fight over whitespace. Git assumes that spaces at the end of lines are 
whitespace errors, while DrRacket indentation will add spaces to empty lines 
(including existing ones), if they are inside parens (that is, not at the 
outermost level).

What's more, the official coding style says "Don’t pollute your code with 
spaces at the end of lines", suggesting DrRacket is not behaving well even 
according to Racket guidelines:
http://docs.racket-lang.org/style/Textual_Matters.html#%28part._.Spaces%29

> Don’t pollute your code with spaces at the end of lines.

I suspect most people don't have these issue because their empty lines are at 
the outermost level, so they don't need to be indented anyway. But I'm writing 
module statements, namely (module checker handin-server/checker ...), and 
switching to `#lang handin-server/checker` fails for me, apparently because 
that language is defined in a package and not a collection, so I'm stuck.

==

What's more, the style guide continues confusingly:

> If you find yourself breaking long blocks of code with blank lines to aid 
> readability, consider refactoring your program to introduce auxiliary 
> functions so that you can shorten these long blocks of code. If nothing else 
> helps, consider using (potentially) empty comment lines.

But I find the discussion confusing: are empty lines at the outermost level 
fine (as I'd guess), or does the text discourage empty lines everywhere (as the 
actual text suggests)?
And what are "(potentially) empty comment lines"? Do you actually mean

;

? Why's that better?

Finally, does DrRacket not indent empty lines well because they're discouraged?

-- 
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] Opening .rktd files in DrRacket

2015-10-21 Thread Paolo Giarrusso
Every time I open a .rktd file in DrRacket 6.2.1, I get an error shown, because 
rktd files don't contain #lang. Googling found nothing, and I didn't find a 
#lang data. At best, I can add #lang s-exp syntax/module-reader, but those 
.rktd files won't work unless I change the reading applications.

How can I fix this situation?

Sample error:
config.rktd:1:0: Module Language: only a module expression is allowed, either 
#lang ...menu-name "Info1 WS 2015 Homepage") (web-address 
"http://ps.informatik.uni-tuebingen.de/teachin...
  #(1 834)

the confusing text is taken from the .rktd files — two lines there read:
 [web-menu-name "Info1 WS 2015 Homepage"]
 [web-address "http://ps.informatik.uni-tuebingen.de/teaching/ws15/info1/;]


Cheers,
Paolo

-- 
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] DrRacket indentation adds spaces to empty non-top-level lines?

2015-10-21 Thread Paolo Giarrusso
On 22 October 2015 at 01:59, Robby Findler <ro...@eecs.northwestern.edu> wrote:
> Just for the record, what Vincent describes below is what DrRacket
> does (by default). The problem is that not everyone then hits return a
> second time.

Thanks, I had never figured!
Each programmer editor I know has different amounts of magic for this
kind of scenario (I think that simply leaving the newly created line
often erases the whitespace). That's tricky to maintain, but seems
worthwhile.

***But adding spaces in the whole file when *reindenting* (Ctrl-I /
Cmd-I) is a bigger pain, and what I tried to focus on. That makes
Cmd-I painful to use for me. ***

While IMHO that should be fixed, DrWhitespace appears a sufficient
solution for my immediate problem. Thanks a lot!

Also thanks for all other replies; I missed the earlier thread.

Cheers,
Paolo

> On Wed, Oct 21, 2015 at 3:45 PM, Vincent St-Amour
> <stamo...@eecs.northwestern.edu> wrote:
>> FWIW, I believe what emacs does (or maybe it's configurable?) is to
>> delete trailing whitespace when a newline is inserted.
>>
>> That way, if you start a new line, it will be indented as it should, and
>> if you press enter again to leave the line blank, that indentation just
>> goes away and you get a true blank line.
>>
>> Vincent
>>
>>
>>
>> On Wed, 21 Oct 2015 15:17:43 -0500,
>> Robby Findler wrote:
>>>
>>> Well, one part of the answer is that DrRacket indents empty lines so
>>> when type something like "(define (f x)x" the second "x" is in
>>> a reasonable place. Perhaps it could behave differently, but
>>> auto-indent-on-return seems less surprising than
>>> auto-indent-when-typing-a-character-on-a-whitespace-line.
>>>
>>> Also, Max made some improvements to how DrRacket treats newlines
>>> whitespace at the end of lines (that I think are in a release by now,
>>> but I'm not sure). So if you're seeing bad behavior there, more
>>> specific info would be helpful.
>>>
>>> Robby
>>>
>>>
>>> On Wed, Oct 21, 2015 at 2:47 PM, Paolo Giarrusso <p.giarru...@gmail.com> 
>>> wrote:
>>> > Hi all!
>>> >
>>> > Every time I reindent a file with DrRacket in a Git repository, DrRacket 
>>> > and Git fight over whitespace. Git assumes that spaces at the end of 
>>> > lines are whitespace errors, while DrRacket indentation will add spaces 
>>> > to empty lines (including existing ones), if they are inside parens (that 
>>> > is, not at the outermost level).
>>> >
>>> > What's more, the official coding style says "Don’t pollute your code with 
>>> > spaces at the end of lines", suggesting DrRacket is not behaving well 
>>> > even according to Racket guidelines:
>>> > http://docs.racket-lang.org/style/Textual_Matters.html#%28part._.Spaces%29
>>> >
>>> >> Don’t pollute your code with spaces at the end of lines.
>>> >
>>> > I suspect most people don't have these issue because their empty lines 
>>> > are at the outermost level, so they don't need to be indented anyway. But 
>>> > I'm writing module statements, namely (module checker 
>>> > handin-server/checker ...), and switching to `#lang 
>>> > handin-server/checker` fails for me, apparently because that language is 
>>> > defined in a package and not a collection, so I'm stuck.
>>> >
>>> > ==
>>> >
>>> > What's more, the style guide continues confusingly:
>>> >
>>> >> If you find yourself breaking long blocks of code with blank lines to 
>>> >> aid readability, consider refactoring your program to introduce 
>>> >> auxiliary functions so that you can shorten these long blocks of code. 
>>> >> If nothing else helps, consider using (potentially) empty comment lines.
>>> >
>>> > But I find the discussion confusing: are empty lines at the outermost 
>>> > level fine (as I'd guess), or does the text discourage empty lines 
>>> > everywhere (as the actual text suggests)?
>>> > And what are "(potentially) empty comment lines"? Do you actually mean
>>> >
>>> > ;
>>> >
>>> > ? Why's that better?
>>> >
>>> > Finally, does DrRacket not indent empty lines well because they're 
>>> > discouraged?
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google Groups 
>>> 

[racket-users] Re: Probabilities in log-space and rounding errors

2015-10-20 Thread Paolo Giarrusso
On Tuesday, October 20, 2015 at 12:15:21 PM UTC+2, Laurent Orseau wrote:
> The built-in log-space arithmetic operations are wonderful. (Thanks so much 
> Neil!)
> 
> 
> It sometimes happens that after some log-operations where the result is very 
> close to 0 that it actually goes slightly above 0 as a result of floating 
> point errors, and thus is not a log-probability anymore, which gave me a few 
> headaches.
> 
> 
> 
> One obvious approach is to surround the result with a check, and if it is 
> positive but not, say, above 1e-8 then round it down to 0, otherwise raise an 
> exception if positive.
> 
> 
> But this feels like a hack and I was wondering if there was any "good" way to 
> ensure that any correct log-space operation remains a log-probability  (i.e., 
> never goes above 0).
> 
> 
> Thanks,
> Laurent

If lg+ is involved, this discussion in the docs seems relevant — apologies if 
you've seen that already:
http://docs.racket-lang.org/math/flonum.html#%28def._%28%28lib._math%2Fflonum..rkt%29._lg-%29%29
 ?

After explaining that a good solution is an open research problem, docs state:
>  Further, catastrophic cancellation is unavoidable when logx and logy 
> themselves have error, which is by far the common case. [...] There are 
> currently no reasonably fast algorithms for computing lg+ and lg- with low 
> relative error. For now, if you need that kind of accuracy, use math/bigfloat.

Disclaimer: not an expert here, might well be missing something.

-- 
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: Case for net/url.rkt to read HTTP proxy servers from environment

2015-10-13 Thread Paolo Giarrusso
On Tuesday, October 13, 2015 at 9:21:08 PM UTC+2, William Hatch wrote:
> I would like to see it fall back on HTTP_PROXY if PLT_HTTP_PROXY is not found.
+1

> It is annoying that the cases vary (eg. wget uses http_proxy and https_proxy, 
> curl uses http_proxy and HTTPS_PROXY), but maybe we could prefer the one in 
> all caps and fall back on lowercase.

To be sure, for HTTP both wget and curl (and not only) agree on `http_proxy`.
Before today I had always only seen (on Linux) the lowercase variant, also for 
other ones (e.g. 
https://wiki.archlinux.org/index.php/Proxy_settings#Environment_variables, 
https://askubuntu.com/questions/228530/updating-http-proxy-environment-variable,
 http://www.cyberciti.biz/faq/linux-unix-set-proxy-environment-variable/).

On Tuesday, October 13, 2015 at 9:21:08 PM UTC+2, William Hatch wrote:
> It doesn’t use the standard HTTP_PROXY and NO_PROXY from the environment, 
> since
> I want to be able to control the proxies for Racket obviously and separately
> from the rest of the environment.

But (I'd guess, like William Hatch) most users would want to set those at once. 
If I were writing a patch and I wanted special proxies for Racket, I'd try to 
support well common use cases (reading `http_proxy`), and only add extra code 
for other cases if they're widespread enough.
Changing a variable before starting specific command is not hard per se, and 
it's not hard to have some alias for it:
`http_proxy=$PLT_HTTP_PROXY racket ...`

-- 
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] Re: [racket] developing tools

2015-10-06 Thread Paolo Giarrusso
For the record, a new solution has surfaced. I'm posting this here because this 
thread is highly ranked on Google, so I took it as a reference.

Quoting Laurent from later: 
https://groups.google.com/d/msg/racket-users/_XWopH-iMNw/DEYMBxqqAQAJ

> I'm using the script plugin [*]  to test things quickly. You get direct 
> access to the current editor, either the interactions or the definitions one. 
> Possibly it would be even more helpful to have an interaction window with 
> access to the same things for quick hacks. That could be either a standalone 
> plugin or I think that should also be easy with the script plugin. 

> [*]  http://pkgs.racket-lang.org/#[script-plugin] 
Disclaimer: I wrote this. I have no idea if anyone else is using it, but I 
personally use it all the time.

On Sunday, October 13, 2013 at 11:17:48 PM UTC+2, Robby Findler wrote:
> On Sun, Sep 1, 2013 at 8:22 AM, Laurent  wrote:
> 
> 
> 
> 
> 
> On Sun, Sep 1, 2013 at 2:54 AM, Robby Findler  
> wrote:
> 
> 
> 
> 
> Also, this might help with the dynamic-require approach:
> 
> 
> http://docs.racket-lang.org/tools/drracket_get_extend.html?q=drracket%3Aget/extend%3Adisallow-re-extension%21#%28def._%28%28lib._drracket%2Ftool-lib..rkt%29._drracket~3aget%2Fextend~3adisallow-re-extension%21%29%29
> 
> 
> 
> 
> 
> 
> Interesting! Looks like it could gain a lot of time.
> So I tried (but failed) to write a simple tool tester.
> 
> #lang racket/base
> (require drracket/tool
> 
> 
> 
>  drracket/private/drsig
>  drracket/tool-lib ; will open a new DrRacket frame at the end!
>  racket/unit)
> 
> 
> ; The magic line
> 
> 
> 
> 
> (drracket:get/extend:allow-re-extension!)
> 
> (define tool (dynamic-require "my-tool.rkt" 'tool@))
> (define-values/invoke-unit tool 
>   (import drracket:tool^))
> 
> where my-tool.rkt contains the example code at the bottom of:
> 
> 
> 
> http://docs.racket-lang.org/tools/implementing-tools.html
> 
> 
> But I'm very unsure about the unit stuff (first time with that, the Guide 
> didn't help a lot here) and I the following error:
> 
> 
> 
> drracket:debug:make-debug-eval-handler: unbound identifier in module in: 
> drracket:debug:make-debug-eval-handler
> 
> I don't know what to do about them (requiring some other files or adding 
> imports in the invoke-unit did not help).
> 
> 
> 
> 
> 
> What is weird is that if I remove the unit related stuff in my-tool.rkt, and 
> add:
> 
> (require drracket/tool-lib)
> 
> (drracket:get/extend:allow-re-extension!)
> 
> 
> 
> 
> 
> right before the drracket:get/extend:... lines, it works (opens a new frame 
> with the new tool installed).
> 
> 
> Robby, it seems that there is not much to do to make it work, right?
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> The probably you're seeing with the define-values/invoke-unit line has to do 
> with the fact that I've let the drracket:tool^ signature and the exports of 
> drracket/tool-lib get way out of sync. I've brought them mostly back in sync 
> with a recent push but there seems to be a small problem with units that 
> stands in the way of that line actually working. But at least some progress 
> happened here
> 
> 
> 
> Robby

-- 
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] Separate compilation vs macros in signatures and compiler stacktraces (crashes?)

2015-10-06 Thread Paolo Giarrusso
I feel I've found (and minimized) a perfectly repeatable bug in separate 
compilation in Racket 6.2.1, or at least a situation which is a pain to debug 
for related reasons. The example code is available at 
http://pasterack.org/pastes/25050 (or at the end of this email) with all 
modules in one file, but I've first obtained it with modules in separate files.

In module base-sig, I can use an identifier (here `thunk`) which is *not* in 
scope in a "macro" (?) inside define-signature. In module base (which requires 
module base-sig) I provide a unit implementing the signature. Then, if in 
module client I require module base, load the unit *and use the macro*, I get a 
compiler stacktrace mentioning `thunk`, even though `thunk` isn't mentioned 
(except after macro expansion). No error before.
To fix this, I must trace this to module 1 by trial and error — requires 
elsewhere won't help (because lexical scope is still respected).

The needed fix is not (require (for-syntax) but a plain (require). That seems 
to be as specified, but it seems unintuitive wrt. the phase distinction — I can 
imagine this makes sense for units, but it should IMHO be better explained. 
More importantly, undeclared identifiers should be flagged early.

> Each define-syntaxes form in a signature declaration introduces a macro that 
> is available for use in any unit that imports the signature. Free variables 
> in the definition’s expr refer to other identifiers in the signature first, 
> or the context of the define-signature form if the signature does not include 
> the identifier.

$ raco make all.rkt
all.rkt:11:24: thunk: unbound identifier in module
  in: thunk
  compilation context...:
   
/Users/pgiarrusso/AeroFS/Repos/racket-playground-bluevelvet/bug-with-signatures-and-macros/all.rkt
  context...:
   /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:341:0: compile-zo*
   /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:556:26
   /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:548:42
   /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:513:0: maybe-compile-zo
   /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:628:2: do-check
   /Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:708:4
   
/Users/pgiarrusso/opt/racket/share/pkgs/compiler-lib/compiler/commands/make.rkt:81:8:
 for-loop
   
/Users/pgiarrusso/opt/racket/share/pkgs/compiler-lib/compiler/commands/make.rkt:
 [running body]
   /Users/pgiarrusso/opt/racket/collects/raco/raco.rkt: [running body]
   /Users/pgiarrusso/opt/racket/collects/raco/main.rkt: [running body]

==

#lang racket
(module base-sig racket/base
  (require racket/unit)
  (require (only-in racket/function thunk)) ; Omitting this line crashes the 
compiler
  
  (define-signature reify^
(reify-thunk
 (define-syntaxes (reify)
   (syntax-rules ()
 [(_ e)
  (reify-thunk (thunk e))]))
 ))
  
  (provide reify^))

(module base racket/base
  (require racket/unit)
  (require racket/control)
  (require (submod ".." base-sig))
  
  (define-unit reify@
(import)
(export reify^)
(define (reify-thunk computation)
  (reset (computation)))
)
  (provide reify@))

(module client racket
  (require (submod ".." base))
  (define-values/invoke-unit/infer reify@)

  (reify 0) ; This call is needed to trigger the crash
)

-- 
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] Separate compilation vs macros in signatures and compiler stacktraces (crashes?)

2015-10-06 Thread Paolo Giarrusso
Thanks for the prompt answer and the clarifications! But there's a
third issue, which unfortunately I've hid when I combined the modules
in one file (sorry), and which is more important. Sorry I made this
unclear.

In the split version
(https://github.com/Blaisorblade/racket-playground/tree/master/bug-with-signatures-and-macros,
client.rkt and its 2 dependencies), for a bug in the first module I
get the error only in the third module (as detailed in the first
email). That's why I talked about separate compilation: maybe I'm
still confused, but I'd expect the error to be on the first module. If
this weren't separate compilation, I believe I'd still argue it's an
important guarantee.

In addition, I get an error it without any line number — which is
maybe a more subtle matter. Also DrRacket shows no line number.

$ raco make client.rkt
thunk: unbound identifier in module
  in: thunk
  compilation context...:
   
/Users/pgiarrusso/AeroFS/Repos/racket-playground-bluevelvet/bug-with-signatures-and-macros/client.rkt
  context...:
[ the same ]

Cheers,
Paolo

On 7 October 2015 at 01:28, Sam Tobin-Hochstadt <sa...@cs.indiana.edu> wrote:
> I think there are two issues here:
>
> 1. The stack trace in your email is just a result of `raco make`
> printing its current context when there's a syntax error. If you
> replace the whole body of the module with just `(lambda)`, you'll see
> the same stack trace. Probably `raco make` should be changed not to
> print that part of the stack.

I'm in favor. (Also because I'm used to the Scala compiler, where
stacktraces are bugs and bugs are plentiful).

> 2. `(require (for-syntax racket/function))` would be needed if you
> used `thunk` to compute the new syntax that your macro expanded into
> -- in other words, if `thunk` gets executed during expansion. However,
> your macro expands into a use of `thunk`, just like it expands into a
> use of `reify-thunk`.

Sorry, on this point I was plainly confused.

> If we rewrite your macro not using
> `syntax-rules, the distinction is perhaps clearer:
>
> (define-syntax reify (lambda (stx) (syntax-case stx () [(_ e)
> (syntax (reify-thunk (thunk e)))])))
>
> The things used in the computation of the new syntax are, here,
> `lambda`, `syntax-case`, and `syntax`. `reify-thunk` and `thunk`
> appear inside `syntax` -- they are part of the program that we expand
> into, and thus need to be available at phase 0.
>
> Hopefully that helps explain what's going on here.
>
> Sam
>
>
>
> On Tue, Oct 6, 2015 at 7:18 PM, Paolo Giarrusso <p.giarru...@gmail.com> wrote:
>> I feel I've found (and minimized) a perfectly repeatable bug in separate 
>> compilation in Racket 6.2.1, or at least a situation which is a pain to 
>> debug for related reasons. The example code is available at 
>> http://pasterack.org/pastes/25050 (or at the end of this email) with all 
>> modules in one file, but I've first obtained it with modules in separate 
>> files.
>>
>> In module base-sig, I can use an identifier (here `thunk`) which is *not* in 
>> scope in a "macro" (?) inside define-signature. In module base (which 
>> requires module base-sig) I provide a unit implementing the signature. Then, 
>> if in module client I require module base, load the unit *and use the 
>> macro*, I get a compiler stacktrace mentioning `thunk`, even though `thunk` 
>> isn't mentioned (except after macro expansion). No error before.
>> To fix this, I must trace this to module 1 by trial and error — requires 
>> elsewhere won't help (because lexical scope is still respected).
>>
>> The needed fix is not (require (for-syntax) but a plain (require). That 
>> seems to be as specified, but it seems unintuitive wrt. the phase 
>> distinction — I can imagine this makes sense for units, but it should IMHO 
>> be better explained. More importantly, undeclared identifiers should be 
>> flagged early.
>>
>>> Each define-syntaxes form in a signature declaration introduces a macro 
>>> that is available for use in any unit that imports the signature. Free 
>>> variables in the definition’s expr refer to other identifiers in the 
>>> signature first, or the context of the define-signature form if the 
>>> signature does not include the identifier.
>>
>> $ raco make all.rkt
>> all.rkt:11:24: thunk: unbound identifier in module
>>   in: thunk
>>   compilation context...:
>>
>> /Users/pgiarrusso/AeroFS/Repos/racket-playground-bluevelvet/bug-with-signatures-and-macros/all.rkt
>>   context...:
>>/Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:341:0: compile-zo*
>>/Users/pgiarrusso/opt/racket/collects/compiler/cm.rkt:556:26
>>/Users/

Re: [racket-users] 'clear' equivalent in DrRacket

2015-10-06 Thread Paolo Giarrusso
So, a skeleton calling insert, relying on `script-plugin`, is the following. It 
doesn't work yet, but it took like 1 minute, so it's a cool starting point. 
With script-plugin, you can just edit it and rerun it without restarting Racket:

```
#lang racket/base
(require racket/class)

; Sample identity function:
;; string? -> (or/c string? #f)
(provide item-callback)
(define (item-callback str #:interactions interactions)
  (send interactions insert "\n\n\n\n")
  str)
```

On Tuesday, October 6, 2015 at 11:36:55 AM UTC+2, Laurent Orseau wrote:
> I'm using the script plugin [*]  to test things quickly. You get direct 
> access to the current editor, either the interactions or the definitions one. 
> Possibly it would be even more helpful to have an interaction window with 
> access to the same things for quick hacks.

Yes, that would be even cooler (Emacs-style), but this tool is already really 
cool.

> That could be either a standalone plugin or I think that should also be easy 
> with the script plugin. 
> 
> 
> 
> [*]  http://pkgs.racket-lang.org/#[script-plugin] 
> Disclaimer: I wrote this. I have no idea if anyone else is using it, but I 
> personally use it all the time.

Don't take this the wrong way, but once you have a solution to such a big 
problem, I think you probably should to advertise it a bit to get it to your 
users — try to get a link in the plugin guide, make this an official plugin, 
... This takes much less effort than the work, and increases the positive 
impact on the community.

Furthermore, your plugin enables a the birth of *lots* of simple editor 
extensions — you empower your users to do much more work.
Here's an example of more people who would have needed it:
http://comments.gmane.org/gmane.comp.lang.racket.user/24630

I think the above would hold as soon as script-plugin was decent for you; in 
fact, I think it's already great.

Cheers,
Paolo

> On Tue, Oct 6, 2015 at 4:11 AM, Paolo Giarrusso <p.gia...@gmail.com> wrote:
> On 6 October 2015 at 01:45, Aman <amang...@gmail.com> wrote:
> 
> >
> 
> > Thanks Laurent and Paolo.  When you say (send a-text insert string), how 
> > are you getting a-text ?
> 
> 
> 
> > What I wanted was not to design a new editor window, but to modify or 
> > 'send' some command to current editor (the default one when we launch 
> > DrRacket) to clear some content or scroll down to hide the content, but I 
> > am not able to find a way to get handle for editor%, text% or anything else 
> > that can be helpful while executing 'send'
> 
> 
> 
> Yeah, a very good question, that's why I asked Laurent for his "quick
> 
> attempt" :-).
> 
> 
> 
> The two ways I can imagine are writing a plugin or modifying DrRacket,
> 
> and I expect the latter to be easier; my only experience is modifying
> 
> a DrRacket plugin, and I don't think this is quick, but it's possible.
> 
> 
> 
> For that, I think you want to look at
> 
> drracket:get/extend:extend-interactions-text. To be in the context to
> 
> do that, see http://docs.racket-lang.org/tools/implementing-tools.html
> 
> and the examples shown there using
> 
> drracket:get/extend:extend-definitions-text.
> 
> 
> 
> Below's I'll give an outline anyway of what I actually did, in case
> 
> it's helpful — though the docs are probably better.
> 
> ==
> 
> 
> 
> I've been hacking a DrRacket plugin (the handin client), where I use
> 
> something more complex because I assumed I only had a editor% (so I
> 
> used insert-port). My call is in
> 
> https://github.com/racket/handin/pull/27/files#diff-cf0f873382d5f6c351cee18d851376c3R734;
> 
> the code around it does a number of potentially useful things.
> 
> 
> 
> The starting point is the call drracket:get/extend:extend-unit-frame,
> 
> in the context of
> 
> 
> 
> (define tool@
> 
> (unit
> 
> (import drracket:tool^)
> 
> (export drracket:tool-exports^)
> 
> ...
> 
> 
> 
> drracket:get/extend:extend-unit-frame subclasses the unit-frame
> 
> DrRacket component, and inside it you can call get-definitions-text
> 
> and get-interactions-text to get access to the two text%.
> 
> 
> 
> For that, refer to the docs extensively, starting from
> 
> http://docs.racket-lang.org/tools/, its index, and the introduction
> 
> into how to do a plugin.
> 
> By doing that, I just found out about
> 
> drracket:get/extend:get-interactions-text, which allows you to
> 
> subclass the interactions-text directly.
> 
> 
> 
> While this is a lot, I've found I managed to get something done
> 
> without needing to understand every detail, also thanks to Racket
> 
> syntax-ch

Re: [racket-users] fail on http server response not actually a failure?

2015-10-06 Thread Paolo Giarrusso
On 6 October 2015 at 15:58, Jay McCarthy  wrote:
> I'm not sure if this answers the question...
>
> These errors are coming from the Web server response-outputing code
> failing when the other side closed the connection early. The exception
> would not be returned to your code, because your code is a function
> from "request -> response" rather than a "request -> void" function
> that ends with a call to "output this response". So, the exception is
> thrown on the Web server's side and will just get caught be the
> connection thread's handler, which just prints it out and cleans up
> for the connection.

In this scenario, I think we'd want the exception to not be printed at
all, since it's entirely harmless.
And it seems doing this is the job of the "Web server
response-outputing code" you mention.

> The only way you could grab this would be to make
> a different dispatcher that called your servlet and then ran its own
> "output this response" code from a context you controlled.
>
> In any case, what would you expect to do with such an exception? The
> connection is gone and you can't do anything about it?

Indeed. Since you're answering a client, nothing to do.
(A client getting a reset from a server during a POST is a much more
complicated matter, but thankfully we're not there).

Cheers,
Paolo

> On Tue, Oct 6, 2015 at 9:25 AM, Tony Garnock-Jones  wrote:
>> On 10/06/2015 12:43 AM, George Neuner wrote:
>>> I don't know where to put an error handler to deal with reset conditions
>>> at the end of a request.  Maybe Jay has an idea?
>>
>> It feels like exceptions are something that response/full,
>> response/xexpr and similar procedures could deal with, since they have a
>> "fire and forget" flavour to them.
>>
>> Raw response objects wouldn't trap the exceptions, and so neither would
>> response/output.
>>
>> The rule of thumb I have in mind is: if you're dealing with the response
>> port at all, catching network exceptions is your responsibility. If the
>> port is entirely hidden away from you, exception handlers would Do The
>> Right Thing For You.
>>
>> Perhaps something like that might help the situation?
>>
>> Tony
>>
>> --
>> 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.
>
>
>
> --
> 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 64:33



-- 
Paolo G. Giarrusso - Ph.D. Student, Tübingen University
http://ps.informatik.uni-tuebingen.de/team/giarrusso/

-- 
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] 'clear' equivalent in DrRacket

2015-10-06 Thread Paolo Giarrusso
After more playing around, I got to this — which scrolls down a bit but not 
enough. Now it's down to actually understanding `(send an-editor-canvas 
scroll-to ...)` docs — in particular, what are editor coordinates. I'm fearing 
it's in pixels.

#lang racket/base
(require racket/class)

;; string? -> (or/c string? #f)
(provide item-callback)
(define (item-callback str #:interactions interactions #:frame frame)
  ;(send interactions insert "\n\n\n\n(void)")
  (define interaction-canvas (send frame get-interactions-canvas))
  (send* interaction-canvas
(allow-scroll-to-last #t)
;(scroll-with-bottom-base #f)
(scroll-to 0 300 1 1 #t 'end))
  str)

On Tuesday, October 6, 2015 at 12:31:54 PM UTC+2, Paolo Giarrusso wrote:
> So, a skeleton calling insert, relying on `script-plugin`, is the following. 
> It doesn't work yet, but it took like 1 minute, so it's a cool starting 
> point. With script-plugin, you can just edit it and rerun it without 
> restarting Racket:
> 
> ```
> #lang racket/base
> (require racket/class)
> 
> ; Sample identity function:
> ;; string? -> (or/c string? #f)
> (provide item-callback)
> (define (item-callback str #:interactions interactions)
>   (send interactions insert "\n\n\n\n")
>   str)
> ```
> 
> On Tuesday, October 6, 2015 at 11:36:55 AM UTC+2, Laurent Orseau wrote:
> > I'm using the script plugin [*]  to test things quickly. You get direct 
> > access to the current editor, either the interactions or the definitions 
> > one. Possibly it would be even more helpful to have an interaction window 
> > with access to the same things for quick hacks.
> 
> Yes, that would be even cooler (Emacs-style), but this tool is already really 
> cool.
> 
> > That could be either a standalone plugin or I think that should also be 
> > easy with the script plugin. 
> > 
> > 
> > 
> > [*]  http://pkgs.racket-lang.org/#[script-plugin] 
> > Disclaimer: I wrote this. I have no idea if anyone else is using it, but I 
> > personally use it all the time.
> 
> Don't take this the wrong way, but once you have a solution to such a big 
> problem, I think you probably should to advertise it a bit to get it to your 
> users — try to get a link in the plugin guide, make this an official plugin, 
> ... This takes much less effort than the work, and increases the positive 
> impact on the community.
> 
> Furthermore, your plugin enables a the birth of *lots* of simple editor 
> extensions — you empower your users to do much more work.
> Here's an example of more people who would have needed it:
> http://comments.gmane.org/gmane.comp.lang.racket.user/24630
> 
> I think the above would hold as soon as script-plugin was decent for you; in 
> fact, I think it's already great.
> 
> Cheers,
> Paolo
> 
> > On Tue, Oct 6, 2015 at 4:11 AM, Paolo Giarrusso <p.gia...@gmail.com> wrote:
> > On 6 October 2015 at 01:45, Aman <amang...@gmail.com> wrote:
> > 
> > >
> > 
> > > Thanks Laurent and Paolo.  When you say (send a-text insert string), how 
> > > are you getting a-text ?
> > 
> > 
> > 
> > > What I wanted was not to design a new editor window, but to modify or 
> > > 'send' some command to current editor (the default one when we launch 
> > > DrRacket) to clear some content or scroll down to hide the content, but I 
> > > am not able to find a way to get handle for editor%, text% or anything 
> > > else that can be helpful while executing 'send'
> > 
> > 
> > 
> > Yeah, a very good question, that's why I asked Laurent for his "quick
> > 
> > attempt" :-).
> > 
> > 
> > 
> > The two ways I can imagine are writing a plugin or modifying DrRacket,
> > 
> > and I expect the latter to be easier; my only experience is modifying
> > 
> > a DrRacket plugin, and I don't think this is quick, but it's possible.
> > 
> > 
> > 
> > For that, I think you want to look at
> > 
> > drracket:get/extend:extend-interactions-text. To be in the context to
> > 
> > do that, see http://docs.racket-lang.org/tools/implementing-tools.html
> > 
> > and the examples shown there using
> > 
> > drracket:get/extend:extend-definitions-text.
> > 
> > 
> > 
> > Below's I'll give an outline anyway of what I actually did, in case
> > 
> > it's helpful — though the docs are probably better.
> > 
> > ==
> > 
> > 
> > 
> > I've been hacking a DrRacket plugin (the handin client), where I use
> > 
> > something more complex because I assumed I only had a editor% (so I

Re: [racket-users] 'clear' equivalent in DrRacket

2015-10-05 Thread Paolo Giarrusso
On Monday, October 5, 2015 at 10:56:50 AM UTC+2, Laurent Orseau wrote:
> I don't think there is anything like this right now, but in case anyone wants 
> to do that, my first impression is,  that such a command should not 
> completely erase the previous content but only hide it (by scrolling down for 
> example). I tried very quickly to do that using `set-position` of `text%` but 
> I couldn't make it leave a blank space after the cursor position when at the 
> end of the editor.

I'm guessing you (or who does this) will need to insert whitespace (newlines) 
with some insert method, after setting the position, probably with 
(send a-text insert string)

You'll also need to act on the editor-canvas% to scroll it down (text% can't do 
that because it's just a MVC Model, while editor-canvas% is the corresponding 
View). (It seems you'll have to call allow-scroll-to-last and scroll-to).

I can't do the rest myself because I haven't learned enough APIs to "try 
something quickly" — only hacked slowly a plugin. But if you share your attempt 
I might be able to try.

Cheers,
Paolo

> On Sun, Oct 4, 2015 at 6:28 PM, Aman  wrote:
> Hi all,
> 
> 
> 
> I am new to DrRacket. I am using swindle language and want to know a way so 
> that I can clear my evaluation window(interaction window) after I do some 
> direct runs there.
> 
> 
> 
> For example if i run following
> 
> 
> 
> > (define a 3)
> 
> > (define b 2)
> 
> 
> 
> Now i want something like
> 
> > clear
> 
> which could clear the window but still keep a and b in environment (memory). 
> Is it possible somehow?
> 
> 
> 
> After going through a lot of posts all I was able to figure out was to hit 
> "Run" and use "Esc:p" to again load the needed commands which seems to me a 
> very bad way.
> 
> 
> 
> Thanks!
> 
> 
> 
> --
> 
> 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...@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] fail on http server response not actually a failure?

2015-10-05 Thread Paolo Giarrusso
On Monday, October 5, 2015 at 10:21:38 PM UTC+2, Neil Van Dyke wrote:
> 'John Clements' via Racket Users wrote on 10/05/2015 03:26 PM:
> >   is this what I would expect to see if a client just gave up and closed 
> > the TCP connection before the response was written,
> 
> I've seen similar errors logged by people using my SCGI package.  I 
> believe you're correct that it almost always means that the HTTP client 
> dropped the connection.  This can happen in a variety of ordinary usage 
> scenarios, such as clicking a second link on the page (to load in the 
> same window and tab) after the HTTP request for first link has been 
> initiated by the response has not yet finished.
> 
> You might want to let the exception percolate up in the code to just 
> before it would be logged/reported as an error, and only then catch it.  
> Maybe have that exception handler use `log--debug` or 
> `log--warning`.

Could this be done by the web application framework? I imagine that's a bad 
idea when programming at a very low-level (and if that's the case here, ignore 
my point), but I'd certainly expect it to be automated in, say, the framework 
described here: http://docs.racket-lang.org/continue/index.html. (Can't judge 
the SCGI framework yet, though I'd consider the option).

-- 
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] DrRacket plugins: getting language of current editor

2015-10-05 Thread Paolo Giarrusso
On Sunday, October 4, 2015 at 9:00:17 PM UTC+2, Robby Findler wrote:
> Yes that is how you get it. 
> 
> 
> But I think that maybe instead you should use the save-port method of the 
> editor. That's how you get what drr puts into the files it saves. You should 
> get the metadata and the "only wxme format when there are images" behavior. 

For the record: Discussion moved into https://github.com/racket/handin/pull/27 
:-), and save-port turned out to not be the right approach.

-- 
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] Re: Writing text to a file with correct newlines

2015-10-05 Thread Paolo Giarrusso
On Monday, October 5, 2015 at 1:07:31 AM UTC+2, Josh English wrote:
> I am trying to learn Racket by creating a Todo manager based on the Todo.txt 
> format by Gina Trapani (http://todotxt.com/)
> 
> I also have an Android tablet that uses a todo.txt application. This 
> application uses "\n\r" at the end of each line. I'm on Windows 7, so I need 
> this newline to work as well, because if I open the file up in Notepad, it 
> messes up my lines and my todos (normally one per line) become one multi-line 
> todo.
> 
> The program reads the text file using file->lines and filters any blank lines.
> 
> The program writes the text file and I manually write the "\n\r" using write, 
> display, and print. That is to say, I've tried all three and ended up with 
> extra "\n" characters.
> 
> Here is a snippet from my do-task procedure:
> 
>  (with-output-to-file (task-file-path) #:mode 'text #:exists 'truncate/replace
> (lambda ()
> (write (string-join (drop-right uptos 1) "\n\r"))
> (write "\n\r")
> (write (complete-task (last uptos) (rest taskstuff)))
> (write "\n\r")
> (write (string-join afters "\n\r")  
> 
> When I open the file with SciTe, it shows the CR and LF characters at the end 
> of each line, plus a blank line with a CR character.
> 
> The complite-task procedure transforms a task and returns a trimmed string.
> 
> Where is this extra blank line coming from?
> 
> Full draft code at http://pastebin.com/z3C5BQJP
> 
> Thanks,
> 
> Josh

It's from #:mode 'text, that translates \n to \r\n: this way, programs can end 
the line with \n on all platforms, yet produce the right end-of-line on 
Windows. This behavior is copied from the C libraries. BTW, are you sure you 
want \n\r? That means LF CR, while on Windows you want \r\n.

To sum up: You can either use #:mode 'text and just use \n (which will produce 
native end-of-lines, hence will produce the format you want only on Windows) 
*or* specify #:mode 'binary and use \r\n (not \n\r), which will produce the 
same result on whatever platform.

Sources:
1. Following with-output-to-file docs shows that open-output-file
http://docs.racket-lang.org/reference/file-ports.html?q=open-output-file%09#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._open-output-file%29%29
2. For background on escape sequences and behavior on Windows, one starting 
point is here:
https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences
For the equivalent of the behavior above, see docs for fopen on Windows, in 
particular text and binary modes.

Cheers,
Paolo

-- 
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] Re: Writing text to a file with correct newlines

2015-10-05 Thread Paolo Giarrusso
On Monday, October 5, 2015 at 11:04:16 AM UTC+2, Paolo Giarrusso wrote:
> On Monday, October 5, 2015 at 1:07:31 AM UTC+2, Josh English wrote:
> > I am trying to learn Racket by creating a Todo manager based on the 
> > Todo.txt format by Gina Trapani (http://todotxt.com/)
> > 
> > I also have an Android tablet that uses a todo.txt application. This 
> > application uses "\n\r" at the end of each line. I'm on Windows 7, so I 
> > need this newline to work as well, because if I open the file up in 
> > Notepad, it messes up my lines and my todos (normally one per line) become 
> > one multi-line todo.
> > 
> > The program reads the text file using file->lines and filters any blank 
> > lines.
> > 
> > The program writes the text file and I manually write the "\n\r" using 
> > write, display, and print. That is to say, I've tried all three and ended 
> > up with extra "\n" characters.
> > 
> > Here is a snippet from my do-task procedure:
> > 
> >  (with-output-to-file (task-file-path) #:mode 'text #:exists 
> > 'truncate/replace
> > (lambda ()
> > (write (string-join (drop-right uptos 1) "\n\r"))
> > (write "\n\r")
> > (write (complete-task (last uptos) (rest taskstuff)))
> > (write "\n\r")
> > (write (string-join afters "\n\r")  
> > 
> > When I open the file with SciTe, it shows the CR and LF characters at the 
> > end of each line, plus a blank line with a CR character.
> > 
> > The complite-task procedure transforms a task and returns a trimmed string.
> > 
> > Where is this extra blank line coming from?
> > 
> > Full draft code at http://pastebin.com/z3C5BQJP
> > 
> > Thanks,
> > 
> > Josh
> 
> It's from #:mode 'text, that translates \n to \r\n: this way, programs can 
> end the line with \n on all platforms, yet produce the right end-of-line on 
> Windows. This behavior is copied from the C libraries.

> BTW, are you sure you want \n\r? That means LF CR, while on Windows you want 
> \r\n.

Ah, I've just realized you say you've tried all three, sorry for missing that.

> To sum up: You can either use #:mode 'text and just use \n (which will 
> produce native end-of-lines, hence will produce the format you want only on 
> Windows) *or* specify #:mode 'binary and use \r\n (not \n\r), which will 
> produce the same result on whatever platform.

To be clear: if the requirements you describe are accurate, I'd advise the 
second way for robustness.
But in 99% of racket programs (and, in fact, in most languages), it's most 
common (though not the most robust) to just use \n and open files in text mode, 
and produce whatever line ending is the right one on the platform. (Many apps, 
including good text editors for programmers, should refrain from that though.)

Cheers,
Paolo

> Sources:
> 1. Following with-output-to-file docs shows that open-output-file
> http://docs.racket-lang.org/reference/file-ports.html?q=open-output-file%09#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._open-output-file%29%29
> 2. For background on escape sequences and behavior on Windows, one starting 
> point is here:
> https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences
> For the equivalent of the behavior above, see docs for fopen on Windows, in 
> particular text and binary modes.
> 
> Cheers,
> Paolo

-- 
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] 'clear' equivalent in DrRacket

2015-10-05 Thread Paolo Giarrusso
On 6 October 2015 at 01:45, Aman <amangpt...@gmail.com> wrote:
>
> Thanks Laurent and Paolo.  When you say (send a-text insert string), how are 
> you getting a-text ?

> What I wanted was not to design a new editor window, but to modify or 'send' 
> some command to current editor (the default one when we launch DrRacket) to 
> clear some content or scroll down to hide the content, but I am not able to 
> find a way to get handle for editor%, text% or anything else that can be 
> helpful while executing 'send'

Yeah, a very good question, that's why I asked Laurent for his "quick
attempt" :-).

The two ways I can imagine are writing a plugin or modifying DrRacket,
and I expect the latter to be easier; my only experience is modifying
a DrRacket plugin, and I don't think this is quick, but it's possible.

For that, I think you want to look at
drracket:get/extend:extend-interactions-text. To be in the context to
do that, see http://docs.racket-lang.org/tools/implementing-tools.html
and the examples shown there using
drracket:get/extend:extend-definitions-text.

Below's I'll give an outline anyway of what I actually did, in case
it's helpful — though the docs are probably better.
==

I've been hacking a DrRacket plugin (the handin client), where I use
something more complex because I assumed I only had a editor% (so I
used insert-port). My call is in
https://github.com/racket/handin/pull/27/files#diff-cf0f873382d5f6c351cee18d851376c3R734;
the code around it does a number of potentially useful things.

The starting point is the call drracket:get/extend:extend-unit-frame,
in the context of

(define tool@
(unit
(import drracket:tool^)
(export drracket:tool-exports^)
...

drracket:get/extend:extend-unit-frame subclasses the unit-frame
DrRacket component, and inside it you can call get-definitions-text
and get-interactions-text to get access to the two text%.

For that, refer to the docs extensively, starting from
http://docs.racket-lang.org/tools/, its index, and the introduction
into how to do a plugin.
By doing that, I just found out about
drracket:get/extend:get-interactions-text, which allows you to
subclass the interactions-text directly.

While this is a lot, I've found I managed to get something done
without needing to understand every detail, also thanks to Racket
syntax-check. It's sad it doesn't understand units as well as the
rest.
(OTOH, I'm scared that I'm writing code without understanding every
single line around it. I usually never do that, but I'm new at
Racket).

Cheers,
Paolo


> On Monday, 5 October 2015 12:51:05 UTC-5, Paolo Giarrusso  wrote:
> > On Monday, October 5, 2015 at 10:56:50 AM UTC+2, Laurent Orseau wrote:
> > > I don't think there is anything like this right now, but in case anyone 
> > > wants to do that, my first impression is,  that such a command should not 
> > > completely erase the previous content but only hide it (by scrolling down 
> > > for example). I tried very quickly to do that using `set-position` of 
> > > `text%` but I couldn't make it leave a blank space after the cursor 
> > > position when at the end of the editor.
> >
> > I'm guessing you (or who does this) will need to insert whitespace 
> > (newlines) with some insert method, after setting the position, probably 
> > with
> > (send a-text insert string)
> >
> > You'll also need to act on the editor-canvas% to scroll it down (text% 
> > can't do that because it's just a MVC Model, while editor-canvas% is the 
> > corresponding View). (It seems you'll have to call allow-scroll-to-last and 
> > scroll-to).
> >
> > I can't do the rest myself because I haven't learned enough APIs to "try 
> > something quickly" — only hacked slowly a plugin. But if you share your 
> > attempt I might be able to try.
> >
> > Cheers,
> > Paolo
> >
> > > On Sun, Oct 4, 2015 at 6:28 PM, Aman <amang...@gmail.com> wrote:
> > > Hi all,
> > >
> > >
> > >
> > > I am new to DrRacket. I am using swindle language and want to know a way 
> > > so that I can clear my evaluation window(interaction window) after I do 
> > > some direct runs there.
> > >
> > >
> > >
> > > For example if i run following
> > >
> > >
> > >
> > > > (define a 3)
> > >
> > > > (define b 2)
> > >
> > >
> > >
> > > Now i want something like
> > >
> > > > clear
> > >
> > > which could clear the window but still keep a and b in environment 
> > > (memory). Is it possible somehow?
> > >
> > >
> > >
> > > After going through a lot of posts all I was able to figur

Re: [racket-users] fail on http server response not actually a failure?

2015-10-05 Thread Paolo Giarrusso
On 6 October 2015 at 03:42, George Neuner <gneun...@comcast.net> wrote:
> On 10/5/2015 4:40 PM, Paolo Giarrusso wrote:
>>
>> On Monday, October 5, 2015 at 10:21:38 PM UTC+2, Neil Van Dyke wrote:
>> > 'John Clements' via Racket Users wrote on 10/05/2015 03:26 PM:
>> > >   is this what I would expect to see if a client just gave up and
>> > > closed the TCP connection before the response was written,
>> >
>> > I've seen similar errors logged by people using my SCGI package.  I
>> > believe you're correct that it almost always means that the HTTP client
>> > dropped the connection.  This can happen in a variety of ordinary usage
>> > scenarios, such as clicking a second link on the page (to load in the
>> > same window and tab) after the HTTP request for first link has been
>> > initiated by the response has not yet finished.
>> >
>> > You might want to let the exception percolate up in the code to just
>> > before it would be logged/reported as an error, and only then catch it.
>> > Maybe have that exception handler use `log--debug` or
>> > `log--warning`.
>>
>> Could this be done by the web application framework? I imagine that's a
>> bad idea when programming at a very low-level (and if that's the case here,
>> ignore my point), but I'd certainly expect it to be automated in, say, the
>> framework described here: http://docs.racket-lang.org/continue/index.html.
>> (Can't judge the SCGI framework yet, though I'd consider the option).
>
>
> I've seen this sporadically in a particular situation.  YMMV.
>
> I have a good sized middleware database application serving AJAX requests
> (JSON in and out) to multiple web portals that were written at different
> times by different people.  One portal based on Dojo occasionally exhibits
> this behavior in IE clients on some active pages that have many AJAX calls
> in flight.  The same code running in Chrome or Firefox never causes the
> error.   Another portal based on jQuery causes no problems even where it
> overlaps function with the Dojo portal.
>
> On the browser side there are no errors/warnings - the server data is
> received and everything works.  On the server side, it's clear that the
> error occurs after the request handler has finished and the response has
> been sent.
>
> Because the error is trivially reproducible [client dropping connection],
> and because in my case it seemed to be specific to the IE/Dojo combination,
> I haven't pursued it much.  But if I had to put money on it, I wager on IE
> being the problem.

It sounded confusing that you could close a connection "too early"
after all data was sent. But it makes some sense for AJAX with some
sort of persistent connections.

Still, no reason for error output to appear — a server has to deal
with this, as it can certainly arise with network partitions, client
crashes... even buggy clients. But the presented facts don't convince
me there's a bug with IE here, even though I'm no IE user.

Cheers,
-- 
Paolo G. Giarrusso - Ph.D. Student, Tübingen University
http://ps.informatik.uni-tuebingen.de/team/giarrusso/

-- 
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] DrRacket plugins: getting language of current editor

2015-10-04 Thread Paolo Giarrusso
Hi all!

I'm trying to figure out how to get the language-settings for the current 
DrRacket editor, for use in an existing plugin.
My first attempt seemed to work for some time, but I've finally tracked down a 
bug with it; my new attempt seems to fix the bug, but I thought I'd try harder 
to get feedback.*

I'm now trying

(send (send a-drracket:unit:frame get-definitions-text) get-next-settings)

and getting a-drracket:unit:frame can be done through 
drracket:get/extend:extend-unit-frame (as already done by the plugin I'm 
modifying). This seems to work, but is it actually correct?

*If you wonder, my goal is actually fixing 
https://github.com/racket/handin/issues/17, and I already started in 
https://github.com/racket/handin/pull/22; I didn't mention that until now 
because there are more people familiar with DrRacket than with the handin 
server. The lack of people also explains why I'm attempting this fix without 
the necessary mastery.

Should you want to see the fix in context, see
https://github.com/racket/handin/commit/1348760243d9b989acb8a71d8a6f7a8f82652960

Cheers,
Paolo

-- 
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] Typed Racket: Does positive? have an invisible filter?

2015-10-03 Thread Paolo Giarrusso
Hi all!
It seems to me that positive? is handled somehow specially by occurrence 
typing, and that this is not documented but should be.

It appears to have a filter in practice, even the Typed Racket guide [1] claims 
so in passing, but this filter is not visible in its type annotation, compared 
e.g. to string?:

> string?
- : (-> Any Boolean : String) ; <--- Note the filter annotation `: String`
#
> positive?
- : (-> Real Boolean) ; <--- No filter annotation!
#

Therefore, I'm a bit confused by Sec. 5.3. I'm guessing that `positive?` has a 
more complicated filter (it refines Real to Positive-Real, and Integer to 
Positive-Integer), and that Sec. 5.2 is in fact oversimplified, but I failed to 
find mention of filter or `positive?` in the Typed Racket reference [2].

[1] http://docs.racket-lang.org/ts-guide/occurrence-typing.html
[2] http://docs.racket-lang.org/search/index.html?q=T:ts-reference%20filter
Also queried without results:
T:ts-guide positive?
T:ts-reference positive?

Instead, searching `T:ts-guide filter` leads me to the incomplete discussion 
above.

Cheers,
Paolo

-- 
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] Base Library Reference

2015-10-03 Thread Paolo Giarrusso
On Saturday, October 3, 2015 at 1:41:57 PM UTC+2, Neil Van Dyke wrote:
> I always use `#lang racket/base`, since I'm almost always writing 
> reusable modules, and I'd like for a hypothetical someone reusing the 
> module in the future to not have to pull in all the `#lang racket` 
> dependencies.

As a new programmer always using #lang racket: what's the overhead from using 
it instead of racket/base? Is name lookup during compilation slower? 
Documentation mentions "load time"... but if that's paid once (in DrRacket), I 
can live with that.
I'd bet program execution to be exactly as fast, but even this might be wrong 
if name lookups happen during compilation.

-- 
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] Typed Racket: Byte-Larger-Than-One is half-hidden half-exported

2015-10-03 Thread Paolo Giarrusso
Hi all!
While following Typed Racket's guide and learning about :type, I was confused 
by "private" types like Byte-Larger-Than-One showing up. This is especially 
confusing because it appears when learning about :type 
(http://docs.racket-lang.org/ts-reference/Exploring_Types.html).

Byte-Larger-Than-One appears when exploring types:
> (:type Positive-Byte)
(U One Byte-Larger-Than-One)

Since Byte-Larger-Than-One appears there, I assumed I could use :type on it:
> (:type Byte-Larger-Than-One)
. Type Checker: parse error in type;
 type name `Byte-Larger-Than-One' is unbound in: Byte-Larger-Than-One

However, it later turned out that you can explore most types appearing there, 
just not Byte-Larger-Than-One (and, in fact, some other types)
> (:type One)
1

I've found a comment in sources explaining why such types are not exposed 
(https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/types/numeric-tower.rkt#L36).
 However, in fact they are somewhat exposed when browsing types, which seems 
suboptimal.

Would it make sense to have and use opaque type synonyms for these cases?
Alternatively, Haskell automatically qualifies type identifiers which are not 
in scope, and maybe Racket could do something similar — although I know no 
syntax for module-qualified names in Racket.

Cheers,
Paolo

-- 
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] Typed Racket: Does positive? have an invisible filter?

2015-10-03 Thread Paolo Giarrusso
On Saturday, October 3, 2015 at 4:49:52 PM UTC+2, Alex Knauth wrote:
> On Oct 3, 2015, at 8:42 AM, Paolo Giarrusso <p.gia...@gmail.com> wrote:
> 
> Hi all!
> It seems to me that positive? is handled somehow specially by occurrence 
> typing, and that this is not documented but should be.
> 
> It appears to have a filter in practice, even the Typed Racket guide [1] 
> claims so in passing, but this filter is not visible in its type annotation, 
> compared e.g. to string?:
> 
> string?
> - : (-> Any Boolean : String) ; <--- Note the filter annotation `: String`
> #<procedure:string?>
> positive?
> - : (-> Real Boolean) ; <--- No filter annotation!
> #<procedure:positive?>
> 
> Therefore, I'm a bit confused by Sec. 5.3. I'm guessing that `positive?` has 
> a more complicated filter (it refines Real to Positive-Real, and Integer to 
> Positive-Integer), and that Sec. 5.2 is in fact oversimplified, but I failed 
> to find mention of filter or `positive?` in the Typed Racket reference [2].
> 
> 
> 
> It does have a filter, and it's slightly more complicated, but not too 
> complicated:
> https://github.com/racket/typed-racket/blob/aae17a0bc03de7c7aa2cfb3555838e456ad77e52/typed-racket-lib/typed-racket/base-env/base-env-numeric.rkt#L734
> It's the equivalent of (-> Real Boolean : #:+ Positive-Real #:- 
> Nonpositive-Real).

Thanks for the prompt answer, that's cooler than I thought — Racket figures out 
by itself that a positive? Integer is a Positive-Integer!

However, the hiding seems a bug to me 
(https://github.com/racket/typed-racket/issues/208). The following outputs 20 
lines, showing 21 wouldn't really hurt:

> (:type #:verbose (-> Real Boolean : #:+ Positive-Real #:- Nonpositive-Real))

I now also found docs for #:+ (under ->); the guide could have a forward 
pointer to it.

Cheers,
Paolo

> This hiding is not specific to positive?, because:
> (:type (-> Real Boolean : #:+ Positive-Real #:- Nonpositive-Real))
> prints out
> 
> (-> Real Boolean)
> [can expand further: Boolean Real]
> 
> [1] http://docs.racket-lang.org/ts-guide/occurrence-typing.html
> [2] http://docs.racket-lang.org/search/index.html?q=T:ts-reference%20filter
> Also queried without results:
> T:ts-guide positive?
> T:ts-reference positive?
> 
> Instead, searching `T:ts-guide filter` leads me to the incomplete discussion 
> above.
> 
> Cheers,
> Paolo

-- 
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] Does sandboxing actually restrict module loading?

2015-09-12 Thread Paolo Giarrusso
Hi! I’m confused by the behavior of the Racket sandbox — it doesn’t seem to 
actually restrict module loading as its docs seem to promise.

Alternatively, I'm misunderstanding the docs, and on my system (OS X) 
#:allow-for-require is unneeded altogether. But then, on what systems is it 
required?

> In particular, filesystem access is restricted, which may interfere with 
> using modules from the filesystem.

I observed this on the handin server (by accident), and minimized the problem 
down to this, so that people not involved with the handin server might take a 
look.

Here's the example (also posted as http://pasterack.org/pastes/81863).

; Tested with Racket 6.2.1, while investigating a problem with the handin 
server.

#lang racket
(require racket/sandbox)
(define evaler (make-module-evaluator '(module foo racket (require htdp/image) 
1) #:language 'racket #:allow-for-require '(2htdp/image)))

(evaler '(begin (require htdp/image) (require net/http-client) (circle 20 
"solid" "red")))


Note I'm using `(require htdp/image)`, which I'd expect to be forbidden — in 
both the code passed to make-module-evaluator, and in the code passed to the 
resulting evaluator.

-- 
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-client] `raco pkg install $URL` vs `raco setup -A $localPath`: getting lost with Racket packages

2015-09-06 Thread Paolo Giarrusso
Thanks a lot!
It sounds... amazingly simpler. It even supports branches!
Even readding support for auto-update sounds easy, to prevent human errors
by students. (It's certainly less work than I spent working around the
current system). I might even integrate this in the docs.

The "hard part" is just
`(git-checkout "github.com" "mflatt/uu-cs5510" #:dest-dir #f #:ref master)`
to get the topmost commit hash... if I can store that locally*, I have an
update check :-D, and the package system API does the rest.

*With my current knowledge, I'd (ab)use preferences for doing that without
writing around the system, but I'm open to better ways.

Cheers,
Paolo

On 6 September 2015 at 23:31, Matthew Flatt <mfl...@cs.utah.edu> wrote:

> An easier way is:
>
>  * Create a Git repo (e.g., at GitHub) for your handin client. It's a
>good idea to name the repo something specific to your class, as
>opposed to just "handin".
>
>For example, the one for my class is
>
>   https://github.com/mflatt/uu-cs5510.git
>
>  * Optionally, register a short name for that package at
>pkgs.racket-lang.org.
>
>For example, I have registered "uu-cs5510" to point to the above
>URL. (Actually, I used the older "git://..." form, but the new form
>should work fine.)
>
>  * Install and update via the "Install Package..." menu item in
>DrRacket.
>
>Since I've registered "uu-cs5510" as a package name at
>pkgs.racket-lang.org", students just install or update the
>"uu-cs5510" package. They could just as well paste the above URL
>into the dialog, though.
>
> If I need to update the package, I can just push changes to the repo,
> and students can get the new version using the same menu item in
> DrRacket to update their installations. No further automation tools are
> needed.
>
> Avoid `raco setup -A`. That approach has all the problems you describe
> and more, and it's much better to just use the package system.
>
> At Sun, 6 Sep 2015 13:42:28 -0700 (PDT), Paolo Giarrusso wrote:
> > Hi all,
> > my research group is going to teach using How to Design Programs (2nd
> ed.), and
> > I'm currently automating deployment of the handin-client with
> auto-update.
> > Since the handin-client (and the auto-updater) was written for the old
> "package
> > management system" (Planet), I'm having some trouble — the procedure seem
> > hackier than desirable, in part because I've not mastered Racket package
> > management yet, in part because it's less error-tolerant than I wish.
> (I'll
> > admit, things will be probably fine for students, just not for me).
> >
> > I believe a couple of things could be bugs (especially n. 3), but I'll
> just
> > tell my story and let you judge. (In the end, it finally seems to be
> working).
> >
> > Meanwhile, if there's enough interest, I could put some effort into
> sharing the
> > setup (beyond https://github.com/plt/handin/issues/19).
> >
> > 1. IIUC, since the autoupdater works with PLT files, students will have
> to
> > paste the plugin URL
> > (
> http://ps.informatik.uni-tuebingen.de/teaching/ws15/info1/handinplugin/utue-inf
> > o1-ws15.plt) into "Install .plt file". IIUC, that's equivalent to
> `racket setup
> > -A`, but the latter doesn't seem to accept URLs. Do I really have to
> download
> > the files beforehand to install them from the command line?
> >
> > Moreover, I haven't found a clean way to uninstall those packages from
> > `(find-user-collects-dir)`.
> >
> > Finally, we've discovered that if the files are renamed the wrong way
> after
> > downloading (say, to `utue-info1-ws15 (2).plt`), installation goes wrong
> —
> > which seems very fragile. For students, we're giving instructions to
> paste the
> > URL to work this around.
> >
> > 2. I discovered that `raco pkg install` seemed to accept URLs to PLT
> files, if
> > I produce sha1 checksums (but SHA1 is deprecated?!?). That seemed
> wonderful,
> > but lead to unacceptable problems.
> > So I could just type:
> >
> > $ raco pkg install $(for i in '' -local -staging; do echo
> >
> http://ps.informatik.uni-tuebingen.de/teaching/ws15/info1/handinplugin/utue-info
> > 1-ws15$i.plt; done)
> >
> > and later remove everything with `raco pkg`. However, files end up in
> > `(find-user-pkgs-dir)`, and that's very bad, because `raco setup -A` can
> > install the same package also in `(find-user-collects-dir)` — in
> particular,
> > that's what happens as soon as you do an auto-update (`raco pkg` r

[racket-users] [handin-client] `raco pkg install $URL` vs `raco setup -A $localPath`: getting lost with Racket packages

2015-09-06 Thread Paolo Giarrusso
Hi all,
my research group is going to teach using How to Design Programs (2nd ed.), and 
I'm currently automating deployment of the handin-client with auto-update. 
Since the handin-client (and the auto-updater) was written for the old "package 
management system" (Planet), I'm having some trouble — the procedure seem 
hackier than desirable, in part because I've not mastered Racket package 
management yet, in part because it's less error-tolerant than I wish. (I'll 
admit, things will be probably fine for students, just not for me).

I believe a couple of things could be bugs (especially n. 3), but I'll just 
tell my story and let you judge. (In the end, it finally seems to be working).

Meanwhile, if there's enough interest, I could put some effort into sharing the 
setup (beyond https://github.com/plt/handin/issues/19).

1. IIUC, since the autoupdater works with PLT files, students will have to 
paste the plugin URL 
(http://ps.informatik.uni-tuebingen.de/teaching/ws15/info1/handinplugin/utue-info1-ws15.plt)
 into "Install .plt file". IIUC, that's equivalent to `racket setup -A`, but 
the latter doesn't seem to accept URLs. Do I really have to download the files 
beforehand to install them from the command line?

Moreover, I haven't found a clean way to uninstall those packages from 
`(find-user-collects-dir)`.

Finally, we've discovered that if the files are renamed the wrong way after 
downloading (say, to `utue-info1-ws15 (2).plt`), installation goes wrong — 
which seems very fragile. For students, we're giving instructions to paste the 
URL to work this around.

2. I discovered that `raco pkg install` seemed to accept URLs to PLT files, if 
I produce sha1 checksums (but SHA1 is deprecated?!?). That seemed wonderful, 
but lead to unacceptable problems.
So I could just type:

$ raco pkg install $(for i in '' -local -staging; do echo 
http://ps.informatik.uni-tuebingen.de/teaching/ws15/info1/handinplugin/utue-info1-ws15$i.plt;
 done)

and later remove everything with `raco pkg`. However, files end up in 
`(find-user-pkgs-dir)`, and that's very bad, because `raco setup -A` can 
install the same package also in `(find-user-collects-dir)` — in particular, 
that's what happens as soon as you do an auto-update (`raco pkg` refuses 
instead to do that, after `raco setup` was run). Afterwards, DrRacket seems to 
try loading the plugin twice, resulting in:

```
Error invoking tool 
#;"client-gui.rkt"

preferences:set-default: preferences default already set for 
'handin:utue-info1-ws15:submit:username
  context...:
   
/Users/pgiarrusso/Library/Racket/6.2.1/pkgs/utue-info1-ws15/utue-info1-ws15/client-gui.rkt:
 [running body]
   /Applications/Racket 
v6.2.1/share/pkgs/drracket/drracket/private/tools.rkt:283:4
   loop
   /Applications/Racket 
v6.2.1/share/pkgs/drracket/drracket/private/tools.rkt:71:0: 
load/invoke-all-tools
   /Applications/Racket v6.2.1/share/pkgs/drracket/drracket/tool-lib.rkt: 
[running body]
   /Applications/Racket 
v6.2.1/share/pkgs/drracket/drracket/private/drracket-normal.rkt: [running body]
   /Applications/Racket v6.2.1/share/pkgs/drracket/drracket/drracket.rkt: 
[running body]
```

3. Earlier I was trying to automate `raco pack --collect --at-plt ++setup` 
using setup/pack, testing the result using `raco planet structure` and getting 
contract violations.
Then I got the same contract violations using `raco planet structure` on a 
valid .plt file.
Finally, I verified that `raco planet structure` understands the result of 
`raco planet create`, but not necessarily the result of `raco pack`. People on 
IRC suggested mentioning this here.

What do you think?

Cheers,
Paolo

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