9 ms·
In fact, since objects and arrays are one and the same in Lua, one can even do away with the nested calls, which also simplifies things visually: Div { i
by kroltan 6y ago
In fact, since objects and arrays are one and the same in Lua, one can even do away with the nested calls, which also simplifies things visually:
Div {
id = "outer",
Div {id = "innerA"},
Div {
id = "innerB",
Div {}
}
}
This works because when you omit the key (id=) of a table item in Lua, it is assumed to have a incrementing numeric key.
- goatlover 6y agoThat's very neat. In the pure prototyping language IO, since the syntax was defined as messages to objects, you could define your own syntax to support xml or html directly in IO. I wonder if Netscape hadn't collaborated with Sun if JS would have had a more pure implementation of prototypes, and how those might have been leveraged more minus all the confusion from mixing in Java-like syntax on top of JS's object model.
- kroltan 6y agoI don't have the sources right now, but I once watched (not attended!) a presentation that talked about how JS was initially intended to be a language more like Lisp or Smalltalk, but was changed into an OO language to appease the heavy marketing at the time.
- kazinator 6y agoThe duo of Lisp and Smalltalk basically define what OO means. Javascript simulates some of the aspects of OOP in an ad hoc way by turning every object into a hash table so that properties can be tacked onto it. It's what you implement if it's Wednesday, and the boss asks for a some sort of working OOP system by Friday.
- kroltan 6y agoYou're right I was half asleep when I wrote the previous comment, I am very sorry. I meant a C(Java?)-like language. Which I am aware has nothing to do with OO, just syntax style.