Looking back, now that Vim script has become much more complex, a bit
more type checking would be good.
A valid point. Mabye this could be done by an assert command/function that checks its arguments or does nothing depending on an option (maybe 'debug')/flag/variable?

Problem is the syntax of type declarations.  Would require function
prototypes, for example.  Vim script follows Python here: no type
declarations.
I'm not sure if I can follow you here. I was thinking of something really simple in the line of:

   fun! Foo(a, b)
       assert a:a >= 0 && a:a <= 10
       assert type(a:b) == 0, "Not a string"
       return a:a + a:b
   endf

   assert Foo(1, 2) == 3
   assert Foo(1, -2) == -1

and maybe

   assert_raise Foo(1, "bla")

Similar commands are used in some other languages. The idea is that vim scripts could run in some sort of debug mode where these assertions are evaluated and in "normal" mode where they are ignored/stripped at read/compile-time (if this is possible with the current interpreter) and thus don't result in a speed penalty. That's probably not quite what you meant but I think it would help (IMHO sufficiently) when writing slightly non-trivial functions.




        
                
___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de

Reply via email to