lua-users home
lua-l archive

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


On Wed, Oct 24, 2012 at 10:29 AM, Geoff Leyland
<geoff_leyland@fastmail.fm> wrote:
> foo(
>  a, -- string
>  b) -- integer

Yeah, I support this pattern with the last comment _before_ the
closing parens - should not be difficult to check for this case, which
reads better anyhow.

> I saw those in the LDoc manual, and it could be difficult if nonstandard aliases were defined, but standard ones would be good.  I guess argcheck could read the same config file as LDoc and get the same set of aliases?

Next release (soon!) will define the primitive types as tparam
aliases, so @string, etc. (@int is interesting one, since you apply an
additional custom constraint here, very useful)

> I know!  I've been gratuitously commenting code since I wrote it.  Trouble is, it's slooooow.  It should be possible to compile the checks after the first time around and that might help.

What could work is if there's an argcheck option to run a preprocessed
version, with explicit type asserts (they can all be on the same line
as 'function' so no line number confusiions)

> At the moment it tries mt.__type, mt.__typename, mt.__typeinfo[type] (but not mt._name - I missed that!), then searches for globals and upvalues with the same name as the type and checks if they match the metatable.  You could easily make "type detectors" pluggable.

That's the way to go!  Sigh, we really do suffer for a lack of OOP
conventions....

steve d.