tag:blogger.com,1999:blog-5956904987508681406.post3879961632117677752..comments2024-02-19T22:58:12.523-06:00Comments on Tom Talks Too Much: Member access syntax: dots, brackets, and functionsTomhttp://www.blogger.com/profile/15808034942220416445noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-5956904987508681406.post-70610825033793650792009-10-26T08:34:36.089-05:002009-10-26T08:34:36.089-05:00Brian, good point which I'd not emphasized her...Brian, good point which I'd not emphasized here (even though in my TA job I was emphasizing your point to beginning programmers last week). Still, JavaScripts unification of the namespace for both syntaxes is interesting. But your point I think relates to the "object key" concept I last mentioned and helps provide weight in that direction.Tomhttps://www.blogger.com/profile/15808034942220416445noreply@blogger.comtag:blogger.com,1999:blog-5956904987508681406.post-45484418691297128602009-10-25T16:16:58.213-05:002009-10-25T16:16:58.213-05:00I've given this a lot of thought too recently....I've given this a lot of thought too recently. And I think the important difference between dot access and [] access is that typically dot access uses only an identifier (which never conflicts with a local variable), but the [] operator allows any arbitrary expression.Unknownhttps://www.blogger.com/profile/08425084298893714261noreply@blogger.comtag:blogger.com,1999:blog-5956904987508681406.post-7749772736791496232009-10-21T10:03:58.265-05:002009-10-21T10:03:58.265-05:00Or in other words, 'persons.4' makes sense...Or in other words, 'persons.4' makes sense but its equivalent '4(persons)' doesn't. Also, 'persons(4)' makes sense but its equivelant '4.persons' doesn't.<br /><br />However, 'persons.get(4)' and its equivalent 'get(persons, 4)' both make sense. Given that, 'persons[4]' as shorthand for 'persons.get(4)' also seems reasonable.<br /><br />Maybe another view of the theme is that object keys shouldn't be used directly as method names.Tomhttps://www.blogger.com/profile/15808034942220416445noreply@blogger.comtag:blogger.com,1999:blog-5956904987508681406.post-67382527695219059002009-10-21T09:04:38.032-05:002009-10-21T09:04:38.032-05:00Cedric, thanks for the comment. I did have that me...Cedric, thanks for the comment. I did have that mentioned in passing in a paragraph as part of my syntax equivalence dilemma. In the sense that I'm claiming 'persons.4' is equivalent to '4(persons)', and that just doesn't seem right to me.<br /><br />(One of my troubles here is that I threw this post together a bit too fast. On limited time, sometimes I just make sure to post before I forget a thought that I might want to remember in the future. But it means I might have a less than ideal presentation of the subject.)Tomhttps://www.blogger.com/profile/15808034942220416445noreply@blogger.comtag:blogger.com,1999:blog-5956904987508681406.post-35106794880334677262009-10-21T01:59:42.823-05:002009-10-21T01:59:42.823-05:00Why not person.4? Identifiers typically never sta...Why not person.4? Identifiers typically never start with a number, so that's reasonably easy to parse...<br /><br />-- <br />CedricCedrichttps://www.blogger.com/profile/13274064962794267826noreply@blogger.com