Closed HamptonMakes closed 12 years ago
Seems to be in the parser....
Yeah, I'm using Go's built-in maps to accumulate the keyword args as they're being parsed, and maps are unordered. Is the order important? I assumed not. As long as the relative ordering of the ordinal args is consistent, the behavior should be the same. I.e., all the following should be equivalent:
foo("bar", "hux", a: "A", b: "B") foo("bar", a: "A", "hux", b: "B") foo(b: "B", a: "A", "bar", "hux")
In other words, as long as "bar" comes before "hux", all the preceding examples should have the same behavior.
On Mon, Jan 16, 2012 at 2:59 PM, Hampton Catlin reply@reply.github.com wrote:
Seems to be in the parser....
Reply to this email directly or view it on GitHub: https://github.com/moovweb/tritium/issues/12#issuecomment-3519980
The problem is that it breaks the tests... Ruby keeps track of the order, so we need to... that or its impossible to Spec test the input/output expectations.
On Jan 16, 2012, at 3:05 PM, Aaron Leung wrote:
Yeah, I'm using Go's built-in maps to accumulate the keyword args as they're being parsed, and maps are unordered. Is the order important? I assumed not. As long as the relative ordering of the ordinal args is consistent, the behavior should be the same. I.e., all the following should be equivalent:
foo("bar", "hux", a: "A", b: "B") foo("bar", a: "A", "hux", b: "B") foo(b: "B", a: "A", "bar", "hux")
In other words, as long as "bar" comes before "hux", all the preceding examples should have the same behavior.
On Mon, Jan 16, 2012 at 2:59 PM, Hampton Catlin reply@reply.github.com wrote:
Seems to be in the parser....
Reply to this email directly or view it on GitHub: https://github.com/moovweb/tritium/issues/12#issuecomment-3519980
Reply to this email directly or view it on GitHub: https://github.com/moovweb/tritium/issues/12#issuecomment-3520081
All right, I can make the change.
Keyword argument order should be preserved now. I.e., something like:
foo(a: 1, b: 2, c: 3)
will consistently expand to something like:
$tmp1 = 1 $tmp2 = 2 $tmp3 = 3 foo() { set("a", $tmp1) set("b", $tmp2) set("c", $tmp3) }
Seems to be going out of order...
Comes out as...