lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Thursday, February 27, 2014, steve donovan <steve.j.donovan@gmail.com> wrote:
On Thu, Feb 27, 2014 at 1:03 PM, Journeyer J. Joh
<oosaprogrammer@gmail.com> wrote:
> When I first saw OO, I felt OO is the one I can do everything only if I can
> I understand what you are trying to say now.
> I even feel sorry for you because you wrote too much to me spending your
> expensive time.

Don't worry about us - we do this because we enjoy writing about this
stuff, plus it will be useful for others searching the list archives.

Sean's koan is great - there is no single great thing.  A wise
programmer knows when to pick up a screwdriver and when to pick up a
hammer.  A big problem with Java is that its designers decided that
hammers would solve all problems.


...and that nouns would solve all problems. 

Imagine how you would go about implementing an arbitrary property pattern in Java or C++. You want to be able to name a property, store any value type in it. Pass it around, etc. 

You may need *some* extra code in Lua, at some point, but the code for that pattern starts out like this:

my_obj.properties.foo = any_value_of_any_type

Test to see if foo is on an object?

my_obj.properties.foo == nil

At some point, you may want to know the property's parent object. You can add that later, without needing to refactor a bunch of scaffolding that gave you the ability to store any value into any arbitrarily named field. 

Testing becomes that much more important. :)

But it looks like implementing patterns in Lua is not possible, sometimes because there is little or nothing to do. 

-Andrew