[erlang-questions] Speaking of comments
Richard O'Keefe
ok@REDACTED
Tue Dec 14 00:52:57 CET 2010
On 13/12/2010, at 8:19 PM, Edmond Begumisa wrote:
> Interesting article.
>
> I don't know about using non-ASCII for actual source-code as the author suggests. I'm not a language designer so I have no opinion this (though in relation to this, I've sometimes wondered about alternatives to programing languages revolving around English -- it must really irritate non-English speakers, especially those coming from languages using non-latin alphabets.)
MADCAP used a non-ASCII character set, including 2d structures.
APL used (and uses) a non-ASCII character set. It has no keywords.
I have seen Algol 60 programs written in French and Chinese.
I've also read Pascal in French (including French keywords)
and seen Simula 67 in Danish.
IBM mainframe compilers have for a long time allowed DBCS (double byte character sets).
Algol 60 was a comparatively straightforward case. Technically, keywords in
that language are single characters, and their rendering as boldface or
underlined English words is just one of many possible hardware representations.
>
> What I would love is very rich and flexible ways of attaching annotations or "running commentary" to source code.
Well, you _could_ use NuWeb, or NoWeb, or FunnelWeb, and add whatever annotations you like.
> I would think this could be done without changing the language in question.
Has very often been done. People have even written programs with commentary in Microsoft Word
and used a VBA macro to strip out and save separately the text with the 'Program' style. I
have my own very simple program for extracting <pre> sections, possibly restricted to a
particular class, from HTML so that
html4.0 foo.htm | pre >foo.erl
can let you extract code from commentary. How simple?
#include <stdio.h>
#include "dvm2.h"
int main(int argc, char **argv) {
char *wanted = argc > 1 ? argv[1] : (char*)0;
xml e0 = load_esis_through(stdin, 0);
int last_was_nl;
for_each_named_descendant(e0, "pre", e1)
if (wanted != 0 && !has_value(e1, "class", wanted)) continue;
last_was_nl = 1;
for_each_text_descendant(e1, e2)
fwrite(text_of(e2), 1, x_size(e2), stdout);
if (x_size(e2) != 0)
last_was_nl = text_of(e2)[x_size(e2)-1] == '\n';
end_each_text_descendant
if (!last_was_nl) putc('\n', stdout);
end_each_named_descendant
return 0;
}
That simple. Doing the same kind of thing using xmerl would be very little harder.
Now you could handle parallel comments in HTML using
<table width="100%">
<col width="50%" align="left"/>
<col width="50%" align="left"/>
<tbody> <!-- repeat for each chunk -->
<tr>
<td><pre>code</pre></td>
<td><p>comments</p></td>
</tr>
</tbody>
</table>
The limit has been our ingenuity, not our tools.\
More information about the erlang-questions
mailing list