From a general point of view, defensive programming is generally seen as a good practice to achieve software reliability.
But, for me, it has always seemed difficult or tedious to acieve with tiddlywiki programming (I mean, using tiddlywiki or programming filters or widget in javascript and maybe other things). Because we have no easy way to take care of this.
And this is due to having limited ability to decide what to do next. Having to resort to filter to decide what the next point will be and use macro is a lot of boilerplate and makes for a reduced readability when things get complex. And defensive programming add many a test while checking for input sanity. We would gain a lot if a new mechanism were invented to take care of that.
Or maybe I’m just wrong and don’ts know better.
I created this topic because someone, a competent someone, once declared to our Great Leader that he had invented a monad with Tiddlywiki. And Maybe types are an example of monads and could help program defensively. So maybe we could be not so far away from a better place in that respect.
Let’s look at a real life example of my cde base. I have to get a list of colums name from a tiddler and succequently doing some stuff with it. They must be in a field called “columns” and each be only made of lowercase letters with maybe additional digits. No space! I would like to suspend my treatment if that would be the case, but I don’t want to uglify my code. Te code below is but a simple part in building a table listing raw data. How could we imagine being defensive here?
<tr>
<$list variable=colname filter="[list[columns]]">
<th><<colname>></th>
</$list>
</tr>