|
[Jan. 28th, 2013|01:34 pm]
|
I was mystified for a lot longer than I feel I should have been as to why
var sql = [
["BEGIN TRANSACTION"],
["INSERT INTO SOME PLAUSIBLE SQL WITH A PARAMETER LIKE $1;", [JSON.stringify(state)]]
["COMMIT"],
];
console.log(sql);
produced
[["BEGIN TRANSACTION"], undefined]
I feel like this says something about human perception or cognition or something. |
|
|
| Comments: |
Missing comma? (Is this JS? What does JS do when you juxtapose lists?)
yup. there's no type error involved in taking the "COMMIT" field of an array object that doesn't have it. Just silent failcess and an undefined value.
why yes of course i meant to take the COMMITth element of this array what else could i have meant
... oh. I think I get at best partial credit, for not realizing how it was going to parse that. Duh.
the point is, it's not parsed as juxtaposed lists, but as an array index expression.
![[User Picture]](http://l-userpic.livejournal.com/82063752/1900156) | From: gf2e 2013-01-30 07:49 am (UTC)
| (Link)
|
I wonder if any work has been put into making language syntax that is more resistant to errors like this. Didn't they supposedly do that with lojban? If it can be done with human languages it can surely be done with machine languages...
I feel like this says something we already know about software development: stay the fuck away from javascript. | |