Re: [racket-users] Is this running in DrRacket or as a script?

2020-09-02 Thread Stefan Schmiedl
Title: Re: [racket-users] Is this running in DrRacket or as a script?


Hello Laurent and Sorawee,

this is exactly what I was looking for and it works like a charm.

I never realised that "Submodules to run" was an active UI element.
Probably one of the places where I should have RTExcellentM a bit more.

Thanks a lot,
s.


Wednesday, September 2, 2020, 10:48:32 AM, you wrote:





Using Laurent’s suggestion, you can also create a global variable / parameter that will be set by the drracket submodule. That way, you can create running-in-drracket? and use it inside functions.

On Wed, Sep 2, 2020 at 12:54 AM Laurent <laurent.ors...@gmail.com> wrote:




You can use a `drracket` submodule:

(module+ drracket
 (foo)
 (bar))

but you need to configure DrRacket to recognize it: Click on the bottom-left button about languages, and at the bottom of "Dynamic Properties", click on "Submodules to run", then "Add submodule option" and add "drracket".

After this, when you run a module from within DrRacket, it will automatically run the `drracket` submodule, but this submodule will *not* be run from the command line (by default).

(I also uncheck the "main" submodule as I use this one only for the command line.)

HTH,
Laurent




On Wed, Sep 2, 2020 at 8:44 AM Stefan Schmiedl <stefan.schmi...@gmail.com> wrote:




Greetings,

I find myself coding some more in DrRacket on my local Win10 PC.
The finished program is to be run on a remote linux server.

I like to keep the code set up for the production environment
but to test it locally I need to configure some things differently.

Currently I'm doing this manually by commenting/uncommenting a sexp
with the required modifications.

Is there a function around that allows me to do something like

(when (running-in-dr-racket?)
  (foo)
  (bar))

Thanks,
s.

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/26327196.20200902094324%40gmail.com.


--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CABNTSaHRMNb8_efegWNC4x68tgo3Q96-ja7ZKHTgSi0Ap86K1g%40mail.gmail.com.







--
Best regards,
Stefan Schmiedl



-- 
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/361439838.20200902135614%40gmail.com.


[racket-users] Is this running in DrRacket or as a script?

2020-09-02 Thread Stefan Schmiedl
Greetings,

I find myself coding some more in DrRacket on my local Win10 PC.
The finished program is to be run on a remote linux server.

I like to keep the code set up for the production environment
but to test it locally I need to configure some things differently.

Currently I'm doing this manually by commenting/uncommenting a sexp
with the required modifications.

Is there a function around that allows me to do something like

(when (running-in-dr-racket?)
  (foo)
  (bar))

Thanks,
s.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/26327196.20200902094324%40gmail.com.


Re: [racket-users] Question regarding the function printBoard board

2019-04-23 Thread Stefan Schmiedl


"orenpa11" , 23.04.2019, 20:53:

> Hi
> I am using  the functionprintBoard board  (DrRacket  Pretty Big) 
>
> (printBoard  '((0 0 2 0) (0 0 0 0) (0 0 8 0) (0 0 0 0)))
> and the result is 
>
> (0 0 2 0)
> (0 0 0 0)
> (0 0 8 0)
> (0 0 0 0)
> "" 

No, it is not. The *print output* is
(0 0 2 0)
(0 0 0 0)
(0 0 8 0)
(0 0 0 0)
while the *return value* is the empty string "" as
implemented in your code.

> How do I delete the "" ?

How would you change your question given the information above?

s.

> I would like the output to be  
> (0 0 2 0)
> (0 0 0 0)
> (0 0 8 0)
> (0 0 0 0)
>
> P.S. the code is 
>
> (define (buildBoard n)   ;build the started board  
>(cond ((= n 0) '())
>  (else (cons '(0 0 0 0) (buildBoard (sub1 n))
>
> (define (printBoard board) ;print the board
>   (cond ((empty? board) "" ) 
> (else (writeln(first board))
>  (printBoard (rest board)


-- 
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] Places and many cores? (File descriptor limit?)

2018-11-04 Thread Stefan Schmiedl
Hello Matt,


"Matt Jadud" , 04.11.2018, 22:47:

> I won't be able to investigate more until tomorrow or Tuesday,
> given my schedule. I might start by asking for a bump in the file descriptor 
> from the sysadmins.


You  could  also  try  to  _reduce_  one of the limits of the current 
session  at  at  time  and see if that makes a difference. No need to 
bother the sysadmins for that.

s.

-- 
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] Searching for packages

2018-08-12 Thread Stefan Schmiedl
"Andrew J" , 12.08.2018, 02:09:

> I typically use either threading or composition...

> (require threading)
> (define (foo x)
>   (~> x 
> f g h bar))

"threading" is not included in the default racket installer, so
how do I get it?

The package manager tells me that there is a "threading" package,
but I'm not sure if it is the correct one.

Browsing over to https://pkgs.racket-lang.org and searching for
"threading" offers me a few more options, the three "threading"
packages amongst them. But now there is a link to "Documentation"
(yay, well-written documentation) and I see that the "threading"
package indeed provides the threding macro quoted above.


Wouldn't it be nice to have a link to https://pkgs.racket-lang.org 
in the "Related Web Sites" submenu of DrRacket's "Help" menu?

Reasons:
1. I started looking there instead of under File, Package Manager,
   and expected to find the "official" package site listed there.
2. The web site allows me to browse the documentation before
   installing anything, which I can't do from the PM window

Regards,
s.

-- 
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] opinions on YAML as communication tool

2016-10-22 Thread Stefan Schmiedl
'John Clements' via Racket Users (21.10. 16:32):

> 
> > On Oct 21, 2016, at 12:42 PM, Tony Garnock-Jones  wrote:
> > 
> > You know how Excel guesses whether things are dates or not and messes
> > things up as a consequence? YAML does that too.

YAML does not guess, the processor does. Just like "undefined"
behavior in C, where decisions are left to the compiler. Still,
some people manage to get some use out of it.

> Interesting. I’m trying to wiggle out of your argument, but it’s
> fairly persuasive. Many thanks for your info. Sigh.

If you know what the contents in the file are going to be and that the
processor handles them to your satisfaction, YAML is a convenient
choice. Yes, like whipping up a quick Excel spreadsheet instead of
doing the right thing and separating the data from the evaluation from
the presentation.

---
billing_id: some number
paid: no
address: |
  Company
  Address
  Location
email: some...@some.tld
billing_date: a date
due_date: another date
vat_percent: some number
items:
- title: words
  effort: number of hours
  rate: hourly rate
- title: words
  effort: number of hours
  rate: hourly rate

I've been using this low-ceremony description for invoices for over a
decade and it works reliably with just the right amount of flexibility.

If you want a "natural" looking text-based description of simple data
structures, YAML is not the worst tool to use. Especially if you're
aware of the limitations.

s.

-- 
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] opinions on YAML as communication tool

2016-10-21 Thread Stefan Schmiedl
'John Clements' via Racket Users (21.10. 01:21):

> I thought hard about scribble and JSON (and xml, yecch), but I think
> that YAML and sexps are the two viable candidates, and I’m guessing
> that if non-programmers have to edit it, they’ll be less likely to
> botch the YAML one.

My timesheet and invoice backend have been yaml files for 10 years now.
If you intend to let "non-programmers" work on it, I'd go for the
vertical layout:

---
alincoln:
  fall:
  - 304
  - 428
  winter:
  - 409
  - special
  spring: # maybe theater
gwashington:
  fall:
  - 224
  - 287
  - 110
  winter: sabbatical
  spring:
  - 789
# might be able to hire stuffy?
stuffy:
  fall:
  - 234
  - 234
  - 234
  winter:
  - 235
  - 235
  - 235

That being said, sexps have less "magic", which comes in handy if you
end up dealing with strings made of digits which promptly lose leading zeros due
to being converted to integers.

---
bond, james: 007

might well end up with the integer 7, like in the following ruby
example:

>> YAML.load("bond, james: 007")
=> {"bond, james"=>7}

So YAML "looks" easier, but sexps are more consistent.

s.

-- 
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] "Systematic Program Design" by Gregor Kiczales on edx.org

2015-05-20 Thread Stefan Schmiedl
Gregor Kiczales is offering a course on Systematic Program Design 
(https://www.edx.org/course/systematic-program-design-part-1-core-ubcx-spd1x) 
starting June 2. It promises to be an extended and improved reincarnation 
(three! parts) of the coursera offering.

Racket (with various Student Languages) is used in this course, but the ideas 
presented are transcending languages and generally useful, no matter if you're 
programming in Racket, Erlang, Ruby or VBA. Even if you are a seasoned 
programmer, you might find some refreshing new ways to look at the things 
you've been doing these past 30 years.

I participated in earlier incarnations of this course and found it to be one of 
the best courses teaching you how to program as opposed to just teaching you a 
language to program in. 

Stefan

-- 
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] Webserver, SSL, and intermediate certificates

2012-09-21 Thread Stefan Schmiedl
On Fri, 21 Sep 2012 11:24:39 -0600
Jordan Schatz  wrote:

> 
> I have an SSL certificate that depends on an intermediate certificate, but I
> cant find anything in the documentation on how to tell the web server that my
> cert needs the intermediate certificate... Are intermediate certificates
> supported? anyone know of a work around?

FWIW, for my nginx setup I just concatenated SSL cert and the intermediate
cert into a single file. Things seem to work out then.

s.

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


Re: [racket] sad user face?

2012-02-19 Thread Stefan Schmiedl
On Sat, 18 Feb 2012 23:31:03 -0500
David Van Horn  wrote:

> On 2/18/12 9:23 PM, J. Ian Johnson wrote:
> > More important than the word choice, the representative character of the 
> > book is male. Potential female readers will not see this book as for them 
> > because they don't identify with the icon. There should be a male/female 
> > team or an ambiguous space slug.
> 
> The book features at least one team comprised of both males and females: 
> the authors.  But I'll be sure to pass along what you guys think.

Have you read Knuth's "Surreal numbers" 
http://www-cs-staff.stanford.edu/~uno/sn.html ?

It does not have fencing, pirates or giants, but it does have
math, mystery and (hopefully) true love :-)

s.
-- 
"This is why Science and Mathematics are still much fun:
You discover things that seem impossible to be true
and then get to figure out why it's impossible for them not to be."

-- Vi Hart: Spirals, Fibonacci, and Being a Plant, Part 3

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


[racket] POP3 client

2012-02-01 Thread Stefan Schmiedl
Greetings,

is there a POP3 client module for racket somewhere out there?

Thanks,
s.

-- 
"This is why Science and Mathematics are still much fun:
You discover things that seem impossible to be true
and then get to figure out why it's impossible for them not to be."

-- Vi Hart: Spirals, Fibonacci, and Being a Plant, Part 3

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


Re: [racket] DrRacket needs work

2011-11-13 Thread Stefan Schmiedl
On Sat, 12 Nov 2011 23:11:15 -0500
Sam Tobin-Hochstadt  wrote:

> We, and in particular Robby, have put a lot of effort into making
> DrRacket a useful programming environment.  If you have specific ways
> of making it better, or even specific things that you found
> off-putting or difficult, that would be helpful.  

One thing that annoys me is that while stepping through code
the pane with the variables gets hard to use if you have a
collection of, say, a few dozen elements in there.

Try stepping through 

#lang racket

(let ((a (make-list 100 'x))
  (b (make-list 100 'y))
  (c (make-list 100 'z)))
  (+ (length a) (length b) (length c)))

and pretend you're interested in the beginning of a while walking
the +. If the printed representation of the collection is "wide"
enough, the variables pane will use a scroll bar, and scroll down
to the end on every single step.

Hiding the contents of uninteresting variables would be great, but
probably not that easy to implement. Restoring the relative position
of the scrollbar after updating the contents would alleviate the
problem, too.

That's the only thing to complain about that I can remember
right now.

Looking forward to playing around with 5.2,
s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] command-line racket with mred components

2011-03-04 Thread Stefan Schmiedl
On Fri, 4 Mar 2011 14:43:14 -0600
Don Blaheta  wrote:

> A few days later I tried it again and it was broken.  Huh?  After a
> certain amount of experimentation, I discovered that if I was ssh'ed
> into a machine from my office desktop machine, the racket script didn't
> work, but if I was ssh'ed into the same machine from my laptop, the
> script worked.  Same machine in both cases.

Assuming you're ssh-ing into a bash login shell, compare the output
of

set

for both origins. Depending on the client, you might have X11Forwarding
enabled from one machine.

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] tests/eli-tester feedback (Was: Racket unit testing)

2011-02-15 Thread Stefan Schmiedl
On Mon, 14 Feb 2011 17:10:13 -0500
Eli Barzilay  wrote:

> Not really.  Started as a private hack, grew to be a little more
> useful, but still not enough to be a proper library.  

I'm quite content with a single tool, I really don't require a
whole library for the kind of tests that my son and I will most
probably write.

> (And this thread is good evidence for that...)

I hear that ... sorry :-)

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] tests/eli-tester feedback (Was: Racket unit testing)

2011-02-13 Thread Stefan Schmiedl
On Sun, 13 Feb 2011 12:16:59 -0500
Eli Barzilay  wrote:

> Not documented, and not distributed by default (since it still lives
> as just a file in the `tests' collection).  

Hidden like an easter egg :-)

> The second issue is that currently it catches almost *all* errors,
> including syntax errors.  A good example for a bogus result that Robby
> got once is:
> 
>   (test (+ x 1) => x)
> 
> where `x' is unbound -- it will catch the syntax error on both sides,
> and since the error messages match, it will conclude that the test is
> successful.  The solution here is to avoid making it catch errors
> unless you use an explicit `=error>' arrow, and even then catch only
> runtime error and add another arrow for syntax errors (perhaps
> `=syntax=error>').

Naively speaking (and without reading any docs ;-), I'd expect =>
to handle "normal" operations. Using error-arrows is a good idea,
as it makes it clearly visible that there's something going on here
without clobbering the test descriptions.

In Robby's case (+ x 1) would raise an error, which would _not_
be caught by => but instead show up as normal exception.

I'm not convinced that you'd need more than one type of error arrow,
though.

> b. Add some way to wrap all evaluations, so, for example, you can
>create a sandbox and have all evaluations happen inside it, so you
>can do things like:
>  (test (some-loop) =error> "out of memory")
>which are only possible if the expressions are running inside a
>sandbox.

hm. Personally, I'm looking for a "small and easy" tester that I can
use while teaching my son some basic programming skills. Between
(check-expect whatever) and (assert-what's-it-called-again something or-other) 
your
(test expr => result) is a very good fit for this task. I can live
without that wrapper very comfortably :-)

> In any case, any feedback on those questions will be good -- feel free
> to mail me directly how you'd prefer this to look.

Heh... there's a good chance I'm saying something stupid, so I prefer
to do this in public, as then it is bound to be spotted more quickly.

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] tests/eli-tester feedback (Was: Racket unit testing)

2011-02-13 Thread Stefan Schmiedl
On Sun, 13 Feb 2011 13:35:48 -0500
Stephen Bloch  wrote:

> 
> On Feb 13, 2011, at 12:16 PM, Eli Barzilay wrote:
> 
> >>> the `=>' is going to be required
> > -or- there's a single expression to test for a non-#f result, and
> > you'll use a nested `test' expression for those non-#f things.  This
> > still makes things less convenient for using random predicates, but
> > not much.  For example, a `fib' test suite that can currently look
> > like this:
> >
> >   (test (exact-nonnegative-integer? (fib 10))
> > (fib 10) => 55)
> >
> > would instead be written as:
> >
> >   (test (test (exact-nonnegative-integer? (fib 10)))
> > (fib 10) => 55)
> 
> How is this an improvement on
> (test (exact-nonnegative-integer? (fib 10)) => #t
>  (fib 10) => 55)
> which doesn't require any special cases at all?
> 

+1 on that.

(test
 (foo) => #t
 (bar) => 'baz)

would be very easy to type and quick to read and also force
you to make explicit if you expect something specific or
just anything not-#f.

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] Racket unit testing, was Re: date format conversion

2011-02-13 Thread Stefan Schmiedl
On Sun, 13 Feb 2011 07:27:35 -0600
Robby Findler  wrote:

> On Sun, Feb 13, 2011 at 3:20 AM, Stefan Schmiedl  wrote:
> >
> > Are there specific reasons or situations when using
> >
> >        (require test-engine/racket-tests)
> >
> > is "superior" to using the test framework provided in
> >
> >        (require rackunit) ?
> 
> No apriori reason, no. The two evolved independently,
> test-engine/racket-tests was originally designed as part of the
> teaching languages and so makes design decisions that are better
> suited there (specifically for showing the results of test case
> failures). rackunit was designed for the full languages and I believe
> it has more features for putting tests together into test suites and
> support for adding your own kind of test cases and extending existing
> ones.
> 
> And there is also a third unit test framework that Eli wrote that
> takes the position that it should be minimal, punting things like test
> suites into Racket itself (by using functions, say). I'm not sure if
> that last one is included in the documentation.

I went and looked around a bit. Is this what you're referring to?

(require tests/eli-tester)

(test
 #t
 (< 1 2)
 (+ 1 2) => 3
 (quotient/remainder 10 3) => (values 3 1)
 (car '()) =error> "expects argument of type")

Very compact and avoids the problem of "what comes first" that I usually
have with other frameworks :-)

Thanks for pointing that one out.

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

[racket] Racket unit testing, was Re: date format conversion

2011-02-13 Thread Stefan Schmiedl
On Sat, 12 Feb 2011 21:40:48 -0500
Neil Van Dyke  wrote:

> prad wrote at 02/12/2011 08:54 PM:
> > my son helped me understand what it was doing after we looked check-expect 
> > up.  so this runs a function for you and checks to see that the result is 
> > really what you say it is going to be!
> >
> > that's pretty useful, so a second thx!
> >   
> 
> This use of "check-expect" is what's known as *unit testing*, and is a 
> very popular practice for good software development nowadays.

Are there specific reasons or situations when using

(require test-engine/racket-tests)

is "superior" to using the test framework provided in

(require rackunit) ?

Curious,
s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] Support for MS SQL in Racket?

2011-02-06 Thread Stefan Schmiedl
On Sat, 5 Feb 2011 20:28:27 -0800
Dave Yrueta  wrote:

> is there anyway
> to write MS SQL Server scripts in Racket that work in a MS SQL server
> environment?

Hi Dave,

creating SQL scripts is just a matter of building the right string
for the job at hand. If nobody comes up with a smarter idea, you
could write this string to a file and pass it to the SQLServer command
line utility sqlcmd.

The fun starts when you want to work on the output of sqlcmd. You'll
notice such niceties as cutting off of the data at 1 MB for no good
reason at all.

I'd be very happy if somebody found an ODBC connector gathering
dust in the corner.

HTH,
s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] recent server outage

2011-01-26 Thread Stefan Schmiedl
On Wed, 26 Jan 2011 07:12:32 -0600
Robby Findler  wrote:

> Most of the downtime was
> dealing with little changes compared to the old version of the OS and
> sorting out selinux permissions.  

As I went through these pains myself during the last 36 hours,
I want to offer a big THANK YOU for doing this.

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] [racket-dev] server availability

2011-01-21 Thread Stefan Schmiedl
Racketeers,

how much effort would it be to keep a rsync'ed copy of the files
relevant for the end-user on another machine? Then you could
make (require (planet...)) a bit smarter to check a list of server
(mirrors) for the packages and the impact on racket users would
be minimized.

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] racket http server, major GC: -216 bytes collected

2011-01-11 Thread Stefan Schmiedl
On Tue, 11 Jan 2011 16:28:50 -0600
Robby Findler  wrote:

> I don't quite understand if you're showing us the full output or if
> we're seeing something that's abridged somehow (I thought you were
> saying that we're seeing only one line for every 20 seconds, but that
> would mean that the webserver took several minutes to start up which
> doesn't seem right) but, in any case, that pattern of memory use would
> indicate to me that nothing is wrong. Specifically, the memory total
> is not growing (beyond some epsilons that don't mean much).
> 
> Am I misreading something somehow?

Yes, sorry for not being clear.

- The results are quoted as they appeared between the command I entered
  and when I stopped the process.
- The startup takes about a second or so, those are _minor_ GCs, which
  are not triggered by my code.
- "My" GCs are (most of) the _major_ GCs appearing below the line reporting the
  creation of the thread. The LRU collect procedure calls collect-garbage
  twice itself.
- The first two clean up the debris after getting the server to run
- The "0 bytes" GCs happen every two seconds and can't collect anything
  since "nothing happens".
- Every 20 secs (10 "0 bytes" GCs) the LRU manager does its thing
  which causes some memory to be tagged as "in use".

While the amount _is_ quite small, I am still concerned by it. I am
currently looking for a platform to develop and deploy one or two
web apps on, and a memory leak would mean that I either can't use
racket or would have to work around it in some way. Memory leaks tend
to become serious, as soon as I take a vacation...

Hey, I _can_ look into the future by speeding things up even further.
Let's look at what happens if I let the LRU manager look once per second.

Ah, ok. The memory usage does level. I just takes longer to reach
the plateau than I thought it would. About 400 iterations through
the LRU loop, if I read my diagram correctly.

Wow. Good to be on the wrong track :-)

Relieved,
s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] racket http server, major GC: -216 bytes collected

2011-01-11 Thread Stefan Schmiedl
Dear readers,

I have some more experimental data on this issue.

On Mon, 10 Jan 2011 18:00:35 +0100
Stefan Schmiedl  wrote:

> On Mon, 10 Jan 2011 06:53:36 -0700
> Matthew Flatt  wrote:
> 
> > Meanwhile, I'm not sure why you're seeing GCs at all when the server is
> > idle. The GCs unexpected, right? But if you're using the LRU manager,
> > it seems to call `collect-garbage' along with its collection routine.
> 
> ... except having around the LRU manager. Good point. I'll try using
> another manager and see if it makes a difference. But right now it looks
> as if the act of GC is causing a tiny leak.

It seems to be the LRU manager, as the following (gctest7.rkt) indicates:

  #lang racket

  (require web-server/web-server
   web-server/servlet-dispatch
   web-server/managers/lru)

  (serve
   #:dispatch (dispatch/servlet
   (lambda (request) '(html (head (title "hello world")) (body 
"hello world")))
   #:manager (create-LRU-manager
  ;; Called when an instance has expired.
  #f
  ;; The condition below is checked every 20 seconds
  20
  ;; One 'life point' is deducted every 10 minutes
  600
  ;; If this condition is true a 'life point' is 
deducted
  ;; from the continuation
  (lambda () #t)
  ;; The number of 'life points' an continuation starts 
with
  #:initial-count 4
  ;; Logging done whenever an continuation is collected
  #:inform-p (lambda args (void
   #:port 8080)

  (define (loop)
(collect-garbage)
(sleep 2)
(loop))

  (thread loop)
  (read-line)

Checking every 20 seconds gives the following pattern with a GC forced at 2 
seconds:

  ste...@g128 racket % ~/racket/bin/racket -W debug gctest7.rkt
  GC [minor] at 1485080 bytes; 647736 collected in 2 msec
  GC [minor] at 2132912 bytes; 647104 collected in 1 msec
  GC [minor] at 4266336 bytes; 1335376 collected in 2 msec
  GC [minor] at 5496832 bytes; 1236464 collected in 4 msec
  GC [minor] at 7322056 bytes; 987600 collected in 5 msec
  GC [minor] at 11401128 bytes; 2517656 collected in 7 msec
  GC [minor] at 15155408 bytes; 3241472 collected in 12 msec
  GC [minor] at 19746560 bytes; 3983888 collected in 14 msec
  GC [minor] at 25194528 bytes; 4238080 collected in 16 msec
  GC [minor] at 32454320 bytes; 6018064 collected in 15 msec
  GC [minor] at 41958720 bytes; 8058944 collected in 25 msec
  GC [minor] at 53566320 bytes; 11580760 collected in 39 msec
  #
  #
  GC [major] at 58657600 bytes; 16634104 collected in 71 msec
  GC [major] at 42060360 bytes; 3611240 collected in 66 msec
  GC [major] at 38449120 bytes; 0 collected in 60 msec
  GC [major] at 38449120 bytes; 4176 collected in 60 msec
  GC [major] at 38444944 bytes; 0 collected in 61 msec
  GC [major] at 38444944 bytes; 0 collected in 60 msec
  GC [major] at 38444944 bytes; 0 collected in 61 msec
  GC [major] at 38444944 bytes; 0 collected in 61 msec
  GC [major] at 38444944 bytes; 0 collected in 60 msec
  GC [major] at 38444944 bytes; 0 collected in 60 msec
  GC [major] at 38444944 bytes; -9768 collected in 60 msec
  GC [major] at 38454712 bytes; 0 collected in 61 msec
  GC [major] at 38454712 bytes; 0 collected in 61 msec
  GC [major] at 38454712 bytes; 0 collected in 60 msec
  GC [major] at 38454712 bytes; 0 collected in 60 msec
  GC [major] at 38454712 bytes; 0 collected in 60 msec
  GC [major] at 38454712 bytes; 0 collected in 61 msec
  GC [major] at 38454712 bytes; 0 collected in 60 msec
  GC [major] at 38454712 bytes; 0 collected in 60 msec
  GC [major] at 38454712 bytes; 0 collected in 60 msec
  GC [major] at 38454712 bytes; -3800 collected in 60 msec
  GC [major] at 38458512 bytes; 0 collected in 60 msec
  GC [major] at 38458512 bytes; 0 collected in 60 msec
  GC [major] at 38458512 bytes; 0 collected in 60 msec
  GC [major] at 38458512 bytes; 0 collected in 60 msec
  GC [major] at 38458512 bytes; 0 collected in 60 msec
  GC [major] at 38458512 bytes; 0 collected in 62 msec
  GC [major] at 38458512 bytes; 0 collected in 60 msec
  GC [major] at 38458512 bytes; 0 collected in 60 msec
  GC [major] at 38458512 bytes; 0 collected in 61 msec
  GC [major] at 38458512 bytes; -2984 collected in 61 msec
  GC [major] at 38461496 bytes; 0 collected in 60 msec
  GC [major] at 38461496 bytes; 0 collected in 61 msec
  GC [major] at 38461496 bytes; 0 collected in 60 msec
  GC [major] at 38461496 bytes; 0 collected in 61 msec
  GC [major] at 38461496 bytes; 0 collected in 60 msec
  GC [major] at 38461496 bytes; 0 collected in 60 msec
  GC [major] at 38461496 bytes; 0 collected in 60 msec
  GC [major] at 38461496 byt

Re: [racket] Scribble experience

2011-01-10 Thread Stefan Schmiedl
On Mon, 10 Jan 2011 15:20:34 +0100
Jens Axel Søgaard  wrote:

> Can Internet Explorer 9 show inline pdfs?

Hint: Do not equate inline display of non-image objects with modern
browsers.

Most of my browsers on most of my machines store the pdf and open
it using the "canonical" viewer. Actually, I have set up both Firefox
and Chromium (both quite new) to only save the pdf and wait for me
to click on it. 

On my 64-bit Linux box, Chromium displays the "broken image" icon
for your  elements.

Good job on the book, though, makes me wonder if I could use it
to learn reading Danish :-)

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Re: [racket] racket http server, major GC: -216 bytes collected

2011-01-10 Thread Stefan Schmiedl
On Mon, 10 Jan 2011 06:53:36 -0700
Matthew Flatt  wrote:

> At Sun, 9 Jan 2011 20:19:23 +0100, Stefan Schmiedl wrote:
> > Well, that was about two hours ago. The reference GC instance is
> > still idling away at 18330232 bytes, just as before, but the web server
> > instance has "grown" from 47923392 (first GC of -672 bytes) to 47957512
> > (first GC of -672 bytes after last "real" GC), that's about 32kB.
> > 
> > Somebody's snacking on my RAM here.
> 
> There are many reasons that small amounts of memory may accumulate in
> the short run --- especially caches and data structures that
> periodically compact themselves.

What I find interesting is that there are no such complex structures
in the reference session I ran, but crop up in the web server session,
even while it is not doing anything...

> 
> Meanwhile, I'm not sure why you're seeing GCs at all when the server is
> idle. The GCs unexpected, right? But if you're using the LRU manager,
> it seems to call `collect-garbage' along with its collection routine.
> 

... except having around the LRU manager. Good point. I'll try using
another manager and see if it makes a difference. But right now it looks
as if the act of GC is causing a tiny leak.

> For example, if I start Racket and just run `(collect-garbage)' in the
> REPL, then after a while, I see a cycle of about 20 numbers around
> -1000 and then one number around 15000. That effect seems to be from
> the REPL allocating parameters that create weak boxes that are
> referenced by a chain of records that are periodically compacted into a
> hash table. The negative numbers don't quite balance the positive
> numbers for the first many iterations of the cycle, because there's
> another effect relate to rehashing (that will eventually compact a hash
> table of weak boxes); I expect I'd see a larger positive number if I
> had enough patience to go hundreds of times.

Heh, that's why I asked earlier how to speed things up. If you look back
at my (loop), you'll see that I'm calling collect-garbage every 10 s.

> 
> It's always possible that you're seeing a real leak, but I think it's
> at least as likely that you're just seeing the effects of complex data
> structures in the run-time system.
> 

It looks like it might be a while before I can spare some time for further
investigations, but I'll keep in on top of my list.

Thanks for the LRU idea.

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] racket http server, major GC: -216 bytes collected

2011-01-09 Thread Stefan Schmiedl
On Sun, 9 Jan 2011 09:48:12 -0600
Robby Findler  wrote:

> You can call collect-garbage (from a separate thread with a sleep or 
> something).

As reference, lets run racket with 10 sec GC loop waiting for input:

  $ racket -W debug -e '(define (loop) (collect-garbage) (sleep 10) (loop)) 
(thread loop) (read-line)'
  GC [minor] at 1570768 bytes; 651544 collected in 1 msec
  GC [minor] at 2490256 bytes; 604144 collected in 2 msec
  GC [minor] at 4309040 bytes; 1002704 collected in 5 msec
  GC [minor] at 7330768 bytes; 1825096 collected in 6 msec
  GC [minor] at 9692088 bytes; 1701600 collected in 8 msec
  GC [minor] at 14009936 bytes; 3175584 collected in 8 msec
  GC [minor] at 17096296 bytes; 3089144 collected in 9 msec
  GC [minor] at 22530656 bytes; 3957832 collected in 17 msec
  #
  GC [major] at 22007032 bytes; 3129816 collected in 31 msec
  GC [major] at 18877216 bytes; 546984 collected in 29 msec
  GC [major] at 18330232 bytes; 0 collected in 28 msec
  GC [major] at 18330232 bytes; 0 collected in 27 msec
  GC [major] at 18330232 bytes; 0 collected in 28 msec
  GC [major] at 18330232 bytes; 0 collected in 28 msec
  GC [major] at 18330232 bytes; 0 collected in 27 msec
... and so on. No surprises here.

Now I'm starting the web server, and let it sit there without
generating any requests to it:

  ste...@g128 racket % racket -W debug -t vacation-loop.rkt
  GC [minor] at 1484776 bytes; 644936 collected in 1 msec
  GC [minor] at 2219576 bytes; 650160 collected in 1 msec
  GC [minor] at 4256104 bytes; 1282136 collected in 4 msec
  GC [minor] at 5536496 bytes; 1266784 collected in 4 msec
  GC [minor] at 8425248 bytes; 2002960 collected in 6 msec
  GC [minor] at 11294320 bytes; 2558752 collected in 7 msec
  GC [minor] at 14979616 bytes; 3081168 collected in 10 msec
  GC [minor] at 19654248 bytes; 3687032 collected in 11 msec
  GC [minor] at 26847384 bytes; 4950544 collected in 26 msec
  GC [minor] at 33869392 bytes; 6128176 collected in 21 msec
  GC [minor] at 42415792 bytes; 7560040 collected in 25 msec
  GC [minor] at 54037080 bytes; 8777192 collected in 40 msec
  GC [major] at 69781368 bytes; 15175760 collected in 111 msec
  GC [minor] at 84524448 bytes; 19013992 collected in 56 msec
  GC [minor] at 99325872 bytes; 20791280 collected in 77 msec
  okGC [major] at 108694496 bytes; 60594336 collected in 111 msec
  GC [major] at 48137024 bytes; 107072 collected in 87 msec
  GC [major] at 48029952 bytes; 113016 collected in 84 msec
  GC [major] at 47916936 bytes; -3968 collected in 85 msec
  GC [major] at 47920904 bytes; -672 collected in 84 msec
  ... 17 times repeated, then
  GC [major] at 47933000 bytes; 9608 collected in 83 msec
  GC [major] at 47923392 bytes; -672 collected in 84 msec
  ... 30 times repeated, then
  GC [major] at 47944224 bytes; 15704 collected in 84 msec
  GC [major] at 47928520 bytes; -672 collected in 84 msec
  ... 4 times repeated, then
  GC [major] at 47931880 bytes; -1200 collected in 85 msec
  GC [major] at 47933080 bytes; 0 collected in 85 msec
  GC [major] at 47933080 bytes; 2936 collected in 85 msec
  GC [major] at 47930144 bytes; -1984 collected in 83 msec
  GC [major] at 47932128 bytes; -672 collected in 84 msec
  ... 17 times repeated, then
  GC [major] at 47944224 bytes; 12960 collected in 84 msec
  GC [major] at 47931264 bytes; -672 collected in 83 msec
  ... 31 times repeated, then
  GC [major] at 47952768 bytes; 15696 collected in 83 msec
  GC [major] at 47937072 bytes; -672 collected in 84 msec
  ... 4 times repeated, then
  GC [major] at 47940432 bytes; -3512 collected in 84 msec
  GC [major] at 47943944 bytes; 20480 collected in 86 msec
  GC [major] at 47923464 bytes; -4552 collected in 83 msec
  GC [major] at 47928016 bytes; -672 collected in 83 msec
  ... 30 times repeated, then
  GC [major] at 47948848 bytes; 15624 collected in 83 msec
  GC [major] at 47933224 bytes; -672 collected in 83 msec
  ... and so on and so on and so on.

Well, that was about two hours ago. The reference GC instance is
still idling away at 18330232 bytes, just as before, but the web server
instance has "grown" from 47923392 (first GC of -672 bytes) to 47957512
(first GC of -672 bytes after last "real" GC), that's about 32kB.

Somebody's snacking on my RAM here.

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] racket http server, major GC: -216 bytes collected

2011-01-09 Thread Stefan Schmiedl
On Sun, 9 Jan 2011 07:20:03 -0700
Jay McCarthy  wrote:

> FWIW, I have no clue.

Good, that means it is interesting :-)

Is there a way to increase the major GC frequency? It would make
investigating this a lot faster if it occurred every few seconds
instead of the default setting that it has now.

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


[racket] racket http server, major GC: -216 bytes collected

2011-01-08 Thread Stefan Schmiedl
Hi,

today I was dabbling around with my servlet study, and switched
on debugging output for racket. 

  ste...@g128 racket % racket -W debug -u vacation-loop.rkt
  GC [minor] at 1484840 bytes; 644984 collected in 1 msec
  GC [minor] at 2219568 bytes; 650160 collected in 1 msec
  GC [minor] at 4256376 bytes; 1282232 collected in 4 msec
  GC [minor] at 5544024 bytes; 1268200 collected in 4 msec
  GC [minor] at 8433888 bytes; 2004064 collected in 7 msec
  GC [minor] at 11301992 bytes; 2566680 collected in 9 msec
  GC [minor] at 14976456 bytes; 3075320 collected in 12 msec
  GC [minor] at 19656896 bytes; 3690896 collected in 12 msec
  GC [minor] at 26845544 bytes; 4950472 collected in 26 msec
  GC [minor] at 33867744 bytes; 6128456 collected in 21 msec
  GC [minor] at 42413848 bytes; 7560344 collected in 26 msec
  GC [minor] at 54035040 bytes; 8792384 collected in 40 msec
  GC [major] at 69836240 bytes; 15243240 collected in 112 msec
  GC [minor] at 84420144 bytes; 18721472 collected in 56 msec
  GC [minor] at 99513800 bytes; 21027008 collected in 75 msec
  debug: I'm here
  GC [minor] at 113078792 bytes; 24509152 collected in 71 msec
  debug: now I'm there

At this point I went away for a few hours and this is what I found
when I came back:

  GC [major] at 89671472 bytes; 40452096 collected in 103 msec
  GC [major] at 49219376 bytes; 0 collected in 91 msec
  GC [major] at 49219376 bytes; 38520 collected in 88 msec
  GC [major] at 49180856 bytes; 0 collected in 88 msec
  GC [major] at 49180856 bytes; -2768 collected in 89 msec
  GC [major] at 49183624 bytes; 0 collected in 88 msec
  GC [major] at 49183624 bytes; -5768 collected in 87 msec
  GC [major] at 49189392 bytes; 0 collected in 89 msec
  GC [major] at 49189392 bytes; -1968 collected in 89 msec
  GC [major] at 49191360 bytes; 0 collected in 88 msec
  GC [major] at 49191360 bytes; -384 collected in 88 msec
  GC [major] at 49191744 bytes; 0 collected in 89 msec
  GC [major] at 49191744 bytes; -216 collected in 88 msec
  GC [major] at 49191960 bytes; 0 collected in 89 msec
  GC [major] at 49191960 bytes; -216 collected in 88 msec
  GC [major] at 49192176 bytes; 0 collected in 88 msec
  GC [major] at 49192176 bytes; -384 collected in 88 msec
  GC [major] at 49192560 bytes; 0 collected in 88 msec
  GC [major] at 49192560 bytes; -216 collected in 88 msec
  GC [major] at 49192776 bytes; 0 collected in 88 msec
  GC [major] at 49192776 bytes; -216 collected in 89 msec
  GC [major] at 49192992 bytes; 0 collected in 87 msec
  GC [major] at 49192992 bytes; -384 collected in 88 msec
  GC [major] at 49193376 bytes; 0 collected in 88 msec
  GC [major] at 49193376 bytes; -216 collected in 88 msec
  GC [major] at 49193592 bytes; 0 collected in 89 msec
  GC [major] at 49193592 bytes; -216 collected in 88 msec
  GC [major] at 49193808 bytes; 0 collected in 88 msec
  GC [major] at 49193808 bytes; -216 collected in 88 msec
  GC [major] at 49194024 bytes; 0 collected in 89 msec
  GC [major] at 49194024 bytes; -384 collected in 88 msec
  GC [major] at 49194408 bytes; 0 collected in 89 msec
  GC [major] at 49194408 bytes; -216 collected in 88 msec
  GC [major] at 49194624 bytes; 0 collected in 89 msec
  GC [major] at 49194624 bytes; -216 collected in 88 msec
  GC [major] at 49194840 bytes; 0 collected in 88 msec
  GC [major] at 49194840 bytes; -384 collected in 91 msec
  GC [major] at 49195224 bytes; 0 collected in 92 msec
  GC [major] at 49195224 bytes; -216 collected in 88 msec
  GC [major] at 49195440 bytes; 0 collected in 89 msec

During this time no requests should have been reaching this
server (running on localhost on a box behind a firewall).

I don't know at what points in time these major GCs occured,
but I am a bit worried about those negative numbers that are
"collected" while the server is sitting idle.

Does anybody have an idea where this is coming from? Or
how I could go about locating the source of this misbehavior?
Or is it just much ado about nothing?

Curious,
s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


[racket] clean up after stateless servlets

2011-01-03 Thread Stefan Schmiedl
Final question for today:

Are stateless servlets supposed to be "forgettable"?

Using stateful servlets I can use e.g. redirect/get/forget
to render a concluded "session" (relatively) inaccessible.
Is there a similar mechanism for stateless servlets that I
am just not seeing?

Thanks,
s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] to local or not to local

2011-01-03 Thread Stefan Schmiedl
On Mon, 3 Jan 2011 12:20:51 -0500
Matthias Felleisen  wrote:

> 
> On Jan 3, 2011, at 12:18 PM, Stefan Schmiedl wrote:
> 
> > Is there a coding style guideline for racket? A place where
> > questions like this one are answered already?
> 
> 
> I have had five pages for two months now ... Next time I come up for air I'll 
> air it on 'dev' 

/me subscribes to dev while frantically fanning in your direction

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] stateless servlets problem

2011-01-03 Thread Stefan Schmiedl
On Mon, 3 Jan 2011 16:14:01 +
Noel Welsh  wrote:

> On Mon, Jan 3, 2011 at 3:13 PM, Stefan Schmiedl  wrote:
> > Is there a public (readonly) repository somewhere
> > that I could tap into?
> 
> https://github.com/plt/racket
> 

Thanks,
s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] to local or not to local

2011-01-03 Thread Stefan Schmiedl
On Mon, 3 Jan 2011 11:33:19 -0500
Matthias Felleisen  wrote:

> There is. An experienced programmer (*) should go with the second form. 
> 
> (*) someone who can handle error messages and subtle changes to them. 

hehe ... sounds like a challenge :-)

I'll be a good boy then, and use local from now on.

Is there a coding style guideline for racket? A place where
questions like this one are answered already?

The documentation is very good at describing what is there, 
and the introductory texts (pictures and web servers) are a good
way to get started, but although I know that the thing on the
outer rim is the salad fork, I'm a bit stumped on when to use
it. 

Heh ... "Racket - makes the 40-year beard feel like Pretty Woman"
s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


[racket] to local or not to local

2011-01-03 Thread Stefan Schmiedl
Hi.

In the web-server related documentation, I see the preferred way to
create local procedures as

  (define (start request)
(local ((define (response-generator...))
(define (some-handler...)))
  (do-something-with-these)))

Another way to create local procedures is

  (define (start request)
(define (response-generator...))
(define (some-handler...))
(do-something-with-these)))

Is there some (subtle?) difference between these approaches?
Which way is appropriate in what conditions?

Thanks,
s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] stateless servlets problem

2011-01-03 Thread Stefan Schmiedl
On Mon, 3 Jan 2011 07:04:23 -0700
Jay McCarthy  wrote:

> I've dug into this deeper and it turns out that it is an error in the
> Web Server. 

Yay, I've still got it :-)

I am good at stumbling upon errors whenever I try something new ...

> The code that sets up servlets abuses the fact that the
> servlet dispatcher sets the exit-handler in a particular way (that is
> actually a violation of its unchecked contract.)
> 
> I've made a fix and will push it shortly.

Is there a public (readonly) repository somewhere
that I could tap into?

> Thanks for finding the problem,

Just a tiny drop in the ocean, still I'm glad that I could help.

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] stateless servlets problem

2011-01-02 Thread Stefan Schmiedl
On Sun, 2 Jan 2011 19:23:42 +0100
Stefan Schmiedl  wrote:

For now I'm content with having a web server that can serve
> static files, call functions to handle requests or dispatch to different
> (kinds of) servlets. Not sure that having such a beast run in the wild
> is such a great idea, though.
> 

FWIW, would this solution be the "correct" way to implement this kind of thing?
For suitable definitions of hello et al., of course.

  (require (prefix-in ds: web-server/dispatchers/dispatch-sequencer)
   (prefix-in df: web-server/dispatchers/dispatch-filter)
   (prefix-in dl: web-server/dispatchers/dispatch-lift))

  (define dispatch (ds:make 
(df:make #rx"^/a.rkt" (dl:make hello))
(df:make #rx"^/servlets" (ds:make 
  (dispatch/servlet 
hello-servlet-start #:regexp #rx"a.rkt" #:stateless? #t)
  (dispatch/servlet 
world-servlet-start #:regexp #rx"b.rkt" #:stateless? #f)

Way more elegant than what I had before, and works without
raising exceptions.

Thanks,
s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] stateless servlets problem

2011-01-02 Thread Stefan Schmiedl
On Sun, 2 Jan 2011 16:30:09 +0100
Stefan Schmiedl  wrote:

> I'm especially curious now, why racket complains about my code,
> which is quite similar to what dispatch/servlet 
> (web-server/servlet-dispatch.rkt)
> is doing:
> 
>   (if stateless?
>  (make-stateless.servlet servlet-current-directory stuffer manager start)
>  (make-v2.servlet servlet-current-directory manager start))
> 
> Why can this library function get away with using the same manager
> for both stateful and stateless servlets, and I can't?
> 
> Must be a case of "quod licet Iovi, non licet newbie" (argh).

And indeed it is. Obviously I need to read some more about servlets and
namespaces. For now I'm content with having a web server that can serve
static files, call functions to handle requests or dispatch to different
(kinds of) servlets. Not sure that having such a beast run in the wild
is such a great idea, though.

This is fun :-)

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


Re: [racket] stateless servlets problem

2011-01-02 Thread Stefan Schmiedl
On Sun, 2 Jan 2011 07:45:53 -0700
Jay McCarthy  wrote:

> The make*servlet functions are internal APIs of the Web Server that
> create data structures to represent servlets. You don't want to use
> those. You want to use #lang racket (for stateful) or #lang web-server
> (for stateless) and using serve/servlet [or create a module servlet]

Hello Jay,

thank you for responding right now and about five years ago, when
you wrote "Automatically RESTful Web Applications", which gave me
the same idea right now :-)

I ran into this problem because I wanted to build a small file
showing how to use the different kinds of handling web requests
(files, function lifting, two kinds of servlets) on one page.

What is kind of puzzling to me, though, is that it looks like I'm
providing "good enough" arguments to fulfill the required contracts,
and it still does not work. I've probably not read enough of the manual
to really know what I'm doing.

I'm especially curious now, why racket complains about my code,
which is quite similar to what dispatch/servlet 
(web-server/servlet-dispatch.rkt)
is doing:

  (if stateless?
 (make-stateless.servlet servlet-current-directory stuffer manager start)
 (make-v2.servlet servlet-current-directory manager start))

Why can this library function get away with using the same manager
for both stateful and stateless servlets, and I can't?

Must be a case of "quod licet Iovi, non licet newbie" (argh).

s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users


[racket] stateless servlets problem

2011-01-02 Thread Stefan Schmiedl
Greetings.

I can't create a stateless servlet in racket 5.0.2 (gentoo amd64).

I _can_ create a stateful servlet with

  (define (default-lru-manager)
(make-threshold-LRU-manager
  (lambda (request)
`(html (head (title "Page Has Expired."))
   (body (p "Sorry, this page has expired. Please 
go back."
  (* 16 1024 1024)))

  (define hello-servlet
(make-v2.servlet (current-directory)
 (default-lru-manager)
 hello-servlet-start))


If I understand the docs correctly, the following code should then create
a stateless servlet

  (define world-servlet
(make-stateless.servlet (current-directory)
default-stuffer
(default-lru-manager)
world-servlet-start))

as (default-lru-manager) was fulfilling the contract requirements in the
stateful case.

But when I run the buffer (Ctrl-T), I get the following error message:

  /web-server/managers/manager.rkt:5.15: 
(file
 /usr/lib64/racket/collects/web-server/servlet/setup.rkt)
   broke the contract 
(-> manager? (-> (-> void) number?))
   on manager-create-instance; expected a procedure that accepts no mandatory 
arguments without any keywords, given: #

I also tried substituting the LRU-manager with (create-none-manager #f),
but this did not change the error message. I don't quite get where the
# comes from at all.

What am I doing wrong here?

Thanks,
s.
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users