I got it.

Thanks Ray!

- Joe

On 01/21/2011 05:12 AM, Jay McCarthy wrote:
2011/1/21 Insik Cho<imin...@gmail.com>:
hi guys,

I have used 'call/input-url' function frequently, whose definition is:

(call/input-url URL connect handle) → any
URL : url?
connect : (url? . ->  . input-port?)
handle : (input-port? . ->  . any)

I coded like:

(define a-url (string->url "http://www.google.com";))
(call/input-url a-url get-pure-port (lambda (p) (display (read-bytes 1024
p))))

Tired to type 'lambda' function, I extracted it like:

(define a-url (string->url "http://www.google.com";))
(define (read-1024 p) (display (read-bytes 1024 p)))
(call/input-url a-url get-pure-port (read-1024 p))
You are calling "read-1024" with the argument "p" which appears to be
free in this program. You don't want to pass call/input-url the result
of read-1024, you want to call it with read-1024 itself:

(call/input-url a-url get-pure-port read-1024)

But, it generates errors.

What's wrong?
The question is: what 'handle' means?
'handle' has no special meaning in Racket. This library just uses that name.

Is it like a callback function in C?
You could imagine that it is a "callback" from call/input-url to your
code to do something to the port before it closes it.

Jay

Thanks in advance.

- Joe



_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev



_________________________________________________
 For list-related administrative tasks:
 http://lists.racket-lang.org/listinfo/dev

Reply via email to