lua-users home
lua-l archive

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


(2) it has a definite cost in programmer productivity.  Why waste
all that time waiting for GCC?  It's certainly become a factor

That's one of Bruce Eckel's points - dynamic typing helps productivity.
Besides the time for compilation of a complex strong-typed program (to
say nothing of generic programs), the type and class declarations take
also "programmer cycles". I found this problem with my own descriptor
system - I need to force on myself the discipline to write descriptors.
It takes time which detracts from the actual work that has to be done.
Which leads me to the point that

Lua gives the programmer something even more interesting,
which is the ability to create an environment which is as
permissive or restrictive as you wish.   I believe it would be
possible (although probably would be expensive) to insist
that certain variables only refer to MyClass, for instance.

we don't need to write descriptors for all values, but just for the
"important" ones. Or as Steve says, the restrictions can be imposed only
where most needed. E.g., the public interface for a module, not its
internal functions - though we would lose some comfort at the internal
testing. So I guess we could leave practice to show where a descriptor
is needed, and put it there (just as I've heard that in Holland parks
are built without alleys and after some time alleys are asphalt-paved
where people have trodded paths).

The example

function foobar(String x, MyClass y) ... end

in my system looks like

function foobar( x, y )
  desc.validateParams()
  ...
end

If foobar has a registered descriptor, validateParams will throw a
meaningful assert. This could be done also by a call hook, removing the
need to write the validateParams call explicitly. Since a call hook
would have some performance hit, it could be enabled in "test runs"
only. Or maybe only the performance-critical functions could have a flag
in their descriptor telling that they should be checked only in test
runs. Again, the descriptive power of Lua allows us to do many things.

Using separate descriptors instead of some special syntax in the
function header would also help separate interface from implementation,
because the function descriptors can be grouped together and help the
library user easily read the library interface.

Ivan