Version 0 of Annotating words for better specifying procs in Tcl9

Updated 2014-02-19 14:34:02 by jima

jima 2014-02-19

Novem is already in the works. Many proposals boil around it.

I am thinking in what changes would have the most impact in how Tcl is perceived. Things like {*} indeed produced a visible change in Tcl as it modified how things looked for the coder at syntax level.

Not long ago (2012 in Tcl time is not that much), TIP 401 was proposed to introduce yet another such word prefix {#}, this one for comments, and with it the idea of a possible proliferation of {prefix} forms.

In my mind the introduction of these prefixes only make sense if the goal is to enhance the way Tcl understands the data is being fed with.

In the case of {*} it was a message of "a expanded list comes here". For {#} the proposed message is, "this word you shall ignore".

Watching JO at the XXth conference it was clear to me that one of the main premises underlying Tcl was that each command is responsible for interpreting and processing the words which form its arguments.

This is an awesome concept, or contract, as Tcl core is made conceptually oblivious to the works of an extension command.

But, there are places where this contract proves a limitation. For instance, reading the efforts done in the sugar macro processor you can see how some commands (if and while for instance) need to be "better explained" to Tcl to facilitate the macro processor understand how it should handle its arguments.

Perhaps sugar or the Tcl core for that matter would need to do better business with Tcl code (a sucession of Tcl commands, each one of them king to its own arguments) a little aid to just get the information needed to process the stuff.

What information would be needed?

Knowing that Tcl is really a nickname for at least three languages working in unison: that of Tcl scripts, that of Tcl expressions, and that of Tcl assembly language, suggest an answer.

Perhaps it would be a good idea to annotate the arguments expected by a command in the following way:

{=} would mean "this word is a Tcl expression".

{%} would mean "this word is a Tcl script".

So a single:

proc if { {=}expression {%}branch1 {%}branch2  } {
    ...
}

Would provide enough information for other commands to grasp a better understanding of a command they might need to tweak on.

The corresponding info subcommands would be giving information about what type each argument of a command is.


Going farther with the idea of {prefix} forms... it can be argued that type annotations, as in {double}, {int} and such, might be handy... this seems excessive to me... what I propose is limited to what I think is a more fundamental level of the types a word can be in Tcl.