Re: [racket] typed racket and SRFI 42 ?

2010-10-08 Thread Scott McLoughlin
Thanks for reminding me of Racket's native comprehensions. I totally forgot. Thanks! Scott On 10/8/2010 1:32 AM, Noel Welsh wrote: You know Typed Racket supports Racket's native comprehensions, right? N. On Fri, Oct 8, 2010 at 3:21 AM, Scott McLoughlin wrote: I'm wondering if SRFI 42 (e

Re: [racket] help simple networking

2010-10-08 Thread Noel Welsh
On Fri, Oct 8, 2010 at 6:56 AM, wrote: > could somebody please let me know what I have to do? > > server source: > #lang racket > (require racket/tcp) > (define listener (tcp-listen 12345)) > (let echo-server () > (define-values (in out) (tcp-accept listener)) > (display "received") Right here,

[racket] networking error[simple server and client]

2010-10-08 Thread 김태윤
hello~ I finally made it,sending string to localhost and receive it but when I try to send to other computer, it doesn't work does my code has problem? the source is looks like this server #lang racket (define server (tcp-listen 12345)) (define-values (s-in s-out) (tcp-accept server)) (read-line s-

Re: [racket] networking error[simple server and client]

2010-10-08 Thread Noel Welsh
On Fri, Oct 8, 2010 at 12:39 PM, 김태윤 wrote: > tcp-connect: connection to 59.4.64.153, port 12345 failed (at step 6: No > connection could be made because the target machine actively refused it.; > errno=10061) > this error is appear as well as when I try to send something while server is > not run

Re: [racket] networking error[simple server and client]

2010-10-08 Thread Noel Welsh
Please email your responses to the list not (just) me. You'll get more responses. On Fri, Oct 8, 2010 at 3:10 PM, 김태윤 wrote: > there is a router on server computer > is there any way I can use computer as server with router? Probably you just need to open a port, which you can do via your router

[racket] the program can't find image file

2010-10-08 Thread 김태윤
hello. there is a problem when I make an executable file source is located at c:\ and run.bmp is located at c:\ so in c:\ there are c:\traffic.rkt c:\run.bmp and in the source file there is a line such as (define hero (bitmap "run.bmp")) and I make as an executable file and execute it. so far s

Re: [racket] the program can't find image file

2010-10-08 Thread Noel Welsh
define-runtime-path is your friend. Put the images in the same directory as your code, then (define-runtime-path here ".") (define hero (build-path here "run.bmp")) HTH, N. On Fri, Oct 8, 2010 at 4:45 PM, 김태윤 wrote: > hello. > there is a problem when I make an executable file > source is locat

Re: [racket] the program can't find image file

2010-10-08 Thread 김태윤
hello after I define as (define-runtime-path hero ".") (define hero (build-path hero "run.bmp")) and then when I try to use it with place-image, place-image: expected as first argument, given: # appears what's wrong with me? thanks in advanced. 2010/10/9 Noel Welsh > define-runtime-path is

Re: [racket] the program can't find image file

2010-10-08 Thread Noel Welsh
I made an error. This > (define hero (build-path hero "run.bmp")) should be (define hero (bitmap (path->string (build-path hero "run.bmp" HTH, N. _ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users

[racket] writing garbage collector in racket/scheme?

2010-10-08 Thread YC
Hi all - I have a rather curious question - is it possible to write a garbage collector in a pointerless language such as racket/scheme? This is not about whether one should do such a thing, but rather trying to see whether it is possible at all, and if possible what steps/approaches it will look

Re: [racket] writing garbage collector in racket/scheme?

2010-10-08 Thread Joe Marshall
On Fri, Oct 8, 2010 at 11:49 AM, YC wrote: > Hi all - > I have a rather curious question - is it possible to write a garbage > collector in a pointerless language such as racket/scheme? It is possible if the system provides a good API to the underlying memory architecture. The Scheme standard do

Re: [racket] writing garbage collector in racket/scheme?

2010-10-08 Thread Robby Findler
If you are after an eduction, you can just make yourself a big array and write a compiler / runtime system that uses that array instead of calling 'cons'. Shriram's PLAI has a module on garbage collectors that does this extremely well (by taking away some of the annoying work and letting you focus

Re: [racket] writing garbage collector in racket/scheme?

2010-10-08 Thread YC
Thanks Robby & Joe - this gives me the sketch I needed to see how it will work. Thanks again. On Fri, Oct 8, 2010 at 12:46 PM, Robby Findler wrote: > If you are after an eduction, you can just make yourself a big array > and write a compiler / runtime system that uses that array instead of > cal

[racket] try/catch/finally idiom in Racket

2010-10-08 Thread Sam Phillips
Hi All, I understand using call-with-exception-handler/with-handlers/etc. to catch exceptions in a block of code, but I'm at a loss to what the best way to do a "finally" or cleanup action after a block of code. My intuition is to use dynamic-wind, but I figure there may be a better way that I ju

Re: [racket] try/catch/finally idiom in Racket

2010-10-08 Thread Jay McCarthy
I use dynamic-wind for this. If there is something better, I don't know what it is. dynamic-wind is a little bit funny though because if you capture continuations then the in/out handlers can run multiple times which might defy your expectations. You could set up a continuation barrier on the insid

Re: [racket] try/catch/finally idiom in Racket

2010-10-08 Thread Neil Van Dyke
Should "racket/base" include something like "unwind-protect"? The documentation could warn about what this restricts. I feel bad every time I use "dynamic-wind" to approximate "unwind-protect", pretending that I don't have first-order continuations. But often I'm cleaning up one-shot external

Re: [racket] try/catch/finally idiom in Racket

2010-10-08 Thread Robby Findler
Probably you wanted a prompt in that case. Robby On Friday, October 8, 2010, Neil Van Dyke wrote: > Should "racket/base" include something like "unwind-protect"? > > The documentation could warn about what this restricts. > > I feel bad every time I use "dynamic-wind" to approximate "unwind-prot

Re: [racket] try/catch/finally idiom in Racket

2010-10-08 Thread Neil Van Dyke
OK, thanks. I will take a look at these continuation prompts. Don't recall seeing them before. Robby Findler wrote at 10/08/2010 08:25 PM: Probably you wanted a prompt in that case. Robby On Friday, October 8, 2010, Neil Van Dyke wrote: Should "racket/base" include something like "unwi

[racket] a little macro exercise

2010-10-08 Thread Shriram Krishnamurthi
One of my students recently sent me this needless email message: > Well, how would you do switch fall-through in Scheme? Could you > write a version of the case statement that does that? Since the honor of Racket was at stake (yes, we can have all the same stupid features the scripting languages

Re: [racket] writing garbage collector in racket/scheme?

2010-10-08 Thread Hendrik Boom
On Fri, Oct 08, 2010 at 11:49:27AM -0700, YC wrote: > Hi all - > > I have a rather curious question - is it possible to write a garbage > collector in a pointerless language such as racket/scheme? It is necessary to limit the amount of dynamic storage the garbage collector churns through by its

Re: [racket] the program can't find image file

2010-10-08 Thread 김태윤
hello I stuck at defining an image with relative path when I define as (define image (bitmap "run.bmp")), it works only in my computer because there is no run.bmp in other people's computer with exactly same path and the compiler does not seems to include the image in the distribution file but ju

Re: [racket] a little macro exercise

2010-10-08 Thread Shriram Krishnamurthi
Oh, and you should make sure your solution generates code that is linear in the size of the input. Someone just sent me a solution that works, but I'm pretty sure is quadratic. Shriram _ For list-related administrative tasks: http://lists.racket

Re: [racket] a little macro exercise

2010-10-08 Thread Neil Van Dyke
Shriram Krishnamurthi wrote at 10/08/2010 09:04 PM: http://github.com/shriram/cas-cad-e And using "syntax-rules": http://www.neilvandyke.org/weblog/2010/10/#2010-10-08 Note that it was unclear to me where the "break" form could appear, so I restricted it to being at the end of the clau

Re: [racket] a little macro exercise

2010-10-08 Thread Shriram Krishnamurthi
> Note that it was unclear to me where the "break" form could appear, > so I restricted it to being at the end of the clause, like how > people typically use "break" in C-like "switch" forms. "it was unclear ... so I restricted" = the refuge of rogues. Here's a test that my version passes: (defi

Re: [racket] a little macro exercise

2010-10-08 Thread Eli Barzilay
Here's a much shorter version that doesn't require goto emulation, and is also almost syntax-rules-kosher, modulo a syntax parameter for breaking: --- #lang racket (provide cas-cad-e) (require racket/stxparam) (define-s

Re: [racket] a little macro exercise

2010-10-08 Thread Neil Van Dyke
Shriram Krishnamurthi wrote at 10/08/2010 10:42 PM: "it was unclear ... so I restricted" = the refuge of rogues. Pirates of the Ambiguous Specification -- http://www.neilvandyke.org/ _ For list-related administrative tasks: http://lists.racket

Re: [racket] a little macro exercise

2010-10-08 Thread Neil Van Dyke
Eli Barzilay wrote at 10/08/2010 10:57 PM: Here's a much shorter version that doesn't require goto emulation, Nice. On principle, I was going to trouble to avoid redundant tests, as well as give the compiler a single optimization-friendly "case" form, followed by tail calls. In practice, I

Re: [racket] try/catch/finally idiom in Racket

2010-10-08 Thread Sam Phillips
On Fri, Oct 8, 2010 at 4:40 PM, Jay McCarthy wrote: > I use dynamic-wind for this. If there is something better, I don't > know what it is. dynamic-wind is a little bit funny though because if > you capture continuations then the in/out handlers can run multiple > times which might defy your expec

Re: [racket] a little macro exercise

2010-10-08 Thread Eli Barzilay
15 minutes ago, Neil Van Dyke wrote: > Eli Barzilay wrote at 10/08/2010 10:57 PM: > > Here's a much shorter version that doesn't require goto emulation, > > Nice. On principle, I was going to trouble to avoid redundant > tests, as well as give the compiler a single optimization-friendly > "case"

Re: [racket] a little macro exercise

2010-10-08 Thread Jay McCarthy
I wrote mine without looking at Elis. I like his and mine better than the others. And obvs I like mine more. =P #lang racket (require racket/stxparam) (define-syntax-parameter break (λ (stx) (raise-syntax-error 'break "Used outside cas-cad-e" stx))) (define-syntax-rule (cas-cad-e e [(n ...) code

Re: [racket] a little macro exercise

2010-10-08 Thread Eli Barzilay
20 minutes ago, Jay McCarthy wrote: > I wrote mine without looking at Elis. I like his and mine better than > the others. And obvs I like mine more. =P Heh -- I almost did something very close to that, but then got tempted to do something without the mutations. -- ((lambda (x) (x x)) (

Re: [racket] a little macro exercise

2010-10-08 Thread Neil Van Dyke
Jay McCarthy wrote at 10/08/2010 11:41 PM: I wrote mine without looking at Elis. I like his and mine better than the others. And obvs I like mine more. =P Mutation?! :) I suppose that these different solutions might hint at some of our varying styles or priorities. My use of "syntax-rul

Re: [racket] a little macro exercise

2010-10-08 Thread Jay McCarthy
Mutation that is invisible to the user is fine by me. Jay Sent from my iPhone On Oct 8, 2010, at 10:04 PM, Neil Van Dyke wrote: > Jay McCarthy wrote at 10/08/2010 11:41 PM: >> I wrote mine without looking at Elis. I like his and mine better than the >> others. And obvs I like mine more. =P >>

Re: [racket] a little macro exercise

2010-10-08 Thread Jay McCarthy
Alright, here's the version with no mutation: (define-syntax-rule (cas-cad-e e [(n ...) code ...] ...) (let/ec esc (syntax-parameterize ([break (make-rename-transformer #'esc)]) (let*-values ([(tmp) e] [(earlier? ret) (values #f (void))] [(earlier? ret)

Re: [racket] a little macro exercise

2010-10-08 Thread Eli Barzilay
8 minutes ago, Jay McCarthy wrote: > Alright, here's the version with no mutation: (cas-cad-e 1 [(1) (values 1 2 3)]) In other words: (define-syntax-rule (cas-cad-e e [(n ...) code ...] ...) (let/ec esc (syntax-parameterize ([break (make-rename-transformer #'esc)]) (let*-values ([(tm

Re: [racket] a little macro exercise

2010-10-08 Thread Jay McCarthy
You got me Sent from my iPhone On Oct 8, 2010, at 10:33 PM, Eli Barzilay wrote: > 8 minutes ago, Jay McCarthy wrote: >> Alright, here's the version with no mutation: > > (cas-cad-e 1 [(1) (values 1 2 3)]) > > In other words: > > (define-syntax-rule (cas-cad-e e [(n ...) code ...] ...) > (le