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.
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.
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:
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:
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:
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.
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.