[erlang-questions] Speaking of comments

Edmond Begumisa ebegumisa@REDACTED
Fri Dec 17 07:39:51 CET 2010


On Tue, 14 Dec 2010 10:52:57 +1100, Richard O'Keefe <ok@REDACTED>  
wrote:

>
> 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.

Educative. Now I can stop wondering :)

>>
>> 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've had a look. I like these tools. What I don't like is having to go  
through a separate generation step to use their output. I think it would  
be useful to have these sort of rich annotations for *consumption* in  
Editors/IDEs. To be able to both edit and view them while coding.

Also, I'm lazy (this is also why I don't use edoc as much as I should.) I  
just want to start typing rich annotations straight into my editor. I want  
someone else to take care of the markup. If I have to write markup while  
I'm programming, it reduces the chances that I'll adequately comment my  
code.

>> 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.\
>

Though we're not really talking about the same thing, I see your point.

- Edmond -

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


More information about the erlang-questions mailing list