views:

80

answers:

3

Hi, here's a short question that my googling failed to deliver any clues on.

It seems to be pretty commonplace to use the word "res" for one of the indexes in function arguments. Its existence appears to be agnostic to whatever programming language you look at.

What does it stand for? A simple guess would be, "resource", perhaps? If this is spot on, it would be nice if someone who feels pedagogically inclined, would care to help me shed some light on this. What I don't grok, in particular, is when and why there's a use for the meaning, "resource" (granted that this is the actual meaning of "res").

Edit 1: I'm providing a random example, this is from the NodeJS.org homepage:

var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');

Edit 2: I first came across the "res" thing while working with a PHP backend developer on a fairly modded WP instance. At the time things were too hectic to really sort out what he meant in his quick explanation, but he seemed to scatter the word all around, in arguments and $res variable calls alike. It's obviously impossible to comment on individual programmers' style and preference of coding, but I'm mostly curious to know if there's some sort of untold consensus among programmers – and if there's a single purpose – using a so called "res" pointer. (Compare eg. with using i for "iterator" as often used in loops.)

+2  A: 

A HTTP transaction consists of a request from the client to the server and a response from the server to the client.

Jörg W Mittag
+2  A: 

Not an answer, but

It seems to be pretty commonplace to use the word "res" for one of the indexes in function arguments. Its existence appears to be agnostic to whatever programming language you look at.

Nope. My guess is this is only common for Javascript doing http request/response (or a few very similar things).

Brian
See my Edit2 in the question.
hced
+4  A: 

In case it's not quite clear from the various answers and comments, in this context req is short for request and res is short for response.

Gabe