You are viewing jcreed

Notes from a Medium-Sized Island - [entries|archive|friends|userinfo]
Jason

[ website | My Website ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[Jan. 28th, 2013|01:34 pm]
Previous Entry Add to Memories Share Next Entry
[Tags|, ]

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

Comments:
[User Picture]From: gwillen
2013-01-28 08:11 pm (UTC)

(Link)

Missing comma? (Is this JS? What does JS do when you juxtapose lists?)
[User Picture]From: jcreed
2013-01-28 08:16 pm (UTC)

(Link)

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.
[User Picture]From: chrisamaphone
2013-01-28 09:11 pm (UTC)

(Link)

why yes of course i meant to take the COMMITth element of this array what else could i have meant
[User Picture]From: gwillen
2013-01-28 10:04 pm (UTC)

(Link)

... oh. I think I get at best partial credit, for not realizing how it was going to parse that. Duh.
[User Picture]From: jcreed
2013-01-28 08:17 pm (UTC)

(Link)

the point is, it's not parsed as juxtaposed lists, but as an array index expression.
[User Picture]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...
[User Picture]From: bhudson
2013-01-30 07:36 pm (UTC)

(Link)

I feel like this says something we already know about software development: stay the fuck away from javascript.