Serving HTTP quickly

Started by Jeff, March 13, 2008, 01:50:40 PM

Previous topic - Next topic

Jeff

#15
Heh, sorry about that.  I had already changed it but hadn't posted that:


(define (num-cpus)
  "Returns the number of cpus as known by sysctl, or 1 if the exec call fails."
  (or (int (first (exec "sysctl -n hw.ncpu"))) 1))
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

Jeff

#16
Is local faster?
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

Lutz

#17
Not sure if its faster, but that was not the point of my comment ;-)



When I was reading:


(let (conn request) ...)

I saw: he is setting the local variable 'conn' to the contents of 'request', and was looking for 'request' else where, finding out that it was never used, except inside the 'let' expression.



Basically you where initializing a local 'conn' to the contents of an unbound global variable 'request', never used before.



Of course you intention was, to have have two variables 'conn' and 'request' which are local to the function, which is better expressed using


(local (conn request) ...)



ps: remember, there is a syntax of 'let' where you can leave out the parenthesis around the variable-value pair;


(let (x 1 y 2) (list x y)) => (1 2)


perhaps this is where the confusion comes from.



See also: http://www.newlisp.org/downloads/newlisp_manual.html#let">http://www.newlisp.org/downloads/newlis ... l.html#let">http://www.newlisp.org/downloads/newlisp_manual.html#let

Jeff

#18
Gotcha.  I'm working on http header parsing at the moment.  There are so many places it needs to be sanity checked.  Lighthttpd's sources are helpful.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code