Trying to find Rails' parameter parsing code

[Please quote when replying.]

Adam Lassek wrote:

That’s not all there is to it. There is also a convention using
parentheses to combine parameters together.

Never heard of this. Example?

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

That’s not all there is to it. There is also a convention using
parentheses to combine parameters together.

Marnen Laibow-Koser wrote:

[Please quote when replying.]

Adam Lassek wrote:

That’s not all there is to it. There is also a convention using
parentheses to combine parameters together.

Never heard of this. Example?

Oh, wait, are you talking about the (1i) used in date selectors? So far
as I know, that’s specific to the date parsing code, not a basic field
combining feature.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Okay, that’s what I needed to know. So this convention is limited to
encoding nesting relationships for Hashes, denoting Array values, and
it apparently originated from PHP. Still looking for the proper term
for this convention, but that’s good enough for now.

On 25 Aug 2010, at 19:04, Adam Lassek wrote:

Okay, that’s what I needed to know. So this convention is limited to
encoding nesting relationships for Hashes, denoting Array values, and
it apparently originated from PHP. Still looking for the proper term
for this convention, but that’s good enough for now.

The concept of parsing parameters into a ‘deep hash’ based on field
names in square brackets was already present in the initial commit of
Rails:

As mentioned earlier, Rack adopted this convention from Rails before its
1.0 release:

http://groups.google.com/group/rack-devel/browse_thread/thread/732e2c1e014bde30/4ee0135df7767f17

In this context of Rack, the common term for this seems to be ‘nested
parameter parsing’.

The suggestion that the idea comes from PHP is probably correct, given
that DHH was working in PHP before starting Rails. PHP parses parameters
with names like person[address][city] into PHP’s equivalent of nested
hashes, multidimensional associative arrays, and in that community the
concept seems to go by some variation of ‘GET/POST multi-dimensional
parameters’.

As a bit of history, this deep hashing was added for PHP 4.0 beta 3 back
in 1999:

http://svn.php.net/viewvc?view=revision&revision=12991

in response to this bug:

http://bugs.php.net/bug.php?id=279

But the basic idea of using ‘foo[bar]’ and ‘foo[]’ as parameter names in
order to get a single-level associative or indexed array seems to have
been around from at least as far back as PHP 2 in 1996:

http://svn.php.net/viewvc/archived/phpfi/trunk/src/type.c?view=markup&pathrev=2#l47

where it’s included with little fanfare and no specific name. No idea if
this was in turn lifted from somewhere else – if anywhere, it’d most
likely be from Perl CGI conventions from around that period.

Chris

Chris M. wrote:

On 25 Aug 2010, at 19:04, Adam Lassek wrote:

Okay, that’s what I needed to know. So this convention is limited to
encoding nesting relationships for Hashes, denoting Array values, and
it apparently originated from PHP. Still looking for the proper term
for this convention, but that’s good enough for now.

The concept of parsing parameters into a ‘deep hash’ based on field
names in square brackets was already present in the initial commit of
Rails:

[…]

Thanks for the history lesson. That was fascinating.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]