Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

More specifically, hs.window.focusedWindow() returns a userdata, with a metatable where the __index entry is the hs.window table. This means that looking up entries on the returned win object (e.g. looking up win.frame) will end up looking up the same key on the hs.window table. Or in other words, it's not literally a copy of the table, but it behaves like it. It's prototype-based inheritance, similar to JavaScript.


I didn't actually look at the implementation of these functions and tables, but yea, I am fairly familiar with Lua and metatables from my days of working on WoW addons.

As for JavaScript, my opinion is that Lua is everything JavaScript should have been: A clean, minimal, sanely designed, language. JavaScript on the other hand is nothing but mistakes piled upon mistakes. It's really disheartening to see JavaScript get shoved into places Lua fits better, like as Gnome Shell's scripting language. Oh well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: