lua-users home
lua-l archive

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



On 28-Aug-05, at 12:43 PM, Mike Pall wrote:

Automatically deriving the contract is the most desirable option.
But this is tough for the above function. Apart from requiring
interprocedural analysis it requires quite a bit of knowledge
about the identity and the behaviour of 'type'.

Yes, which is why it would be useful to make it explicit.

I'm not thinking about "how to make Lua as fast as C" here. Although that's an interesting project. I'm trying to think about "how to make it easy to write good Lua programs".

The advantage of The (or some equivalent) is that it could produce good debugging messages; it reduces the workload to insert parameter checking into a function. That's a Good Thing, independent of JIT.

However, it also provides a good hint for a JIT. Whether the JIT wants to take advantage of it or not, that's fine.

I'm not going to provide any syntactic suggestions, but they
abound in other languages. Pseudo-comment syntax, however, would
make the optionality clear. (eg. --#contract ... )

Comments don't go through to the bytecode ...

True, but a compiler which was aware of pseudo-comments could do something useful with them, just like a documentation tool which is aware of pseudo-comments can do something allegedly useful with them.

I know you are fixated on your project, and that's also a Good Thing. But do try to remember that writing good code is often more important than getting the code to run fast; some of us use Lua rather than Other Languages because it's easier to write good code, and easier to read it afterwards.