Arc Forumnew | comments | leaders | submitlogin
Comment macro
2 points by mflack 6494 days ago | 5 comments
Possibly there would be value in having the programmer form comments in sexp form, and discard with a macro rather than in the reader.

This allows for the possibility that the macro acts upon the comment differently when the programmer decides this may be helpful.

  (mac com body 
    `(do ,@(keep [no:isa _ 'string] body)))
I've named it 'com' so I can play with it at the arc prompt but really you'd want to actually name it ';' so that it looks like an old school comment.

So instead of:

  ; Adds together 1 2 and 3
  (+ 1 2 3)
You write:

  (; "Adds together 1 2 and 3"
    (+ 1 2 3))
Normally the macro pulls out the string; but you could alter that behavior to print out the comments during execution, or to show the enclosing comment for an error in the debugger, or to register the comments in a def form.


3 points by vrk 6494 days ago | link

I would see more value in making a documention generating macro, so that you could easily keep the documentation and program code in one place, not unlike Perl POD and JavaDoc.

  (doc "<function documentation>"
    (def fun args ...))
In normal compilation, the doc macro would simply return the function definition, but it could be defined to generate, say, LaTeX or HTML, or a DOM tree that could be rendered using an arbitrary markup language. The difficulty is identifying the type of code that is enclosed in the doc block, as if you want to extend the paradigm to non-function definitions, or arbitrary macros even, it's going to get hairy.

-----

3 points by treef 6494 days ago | link

already done in the arc-wiki (def fun args "comment" body)

that was like the first thing we added

-----

1 point by vrk 6493 days ago | link

Well! This is certainly a nice improvement.

-----

3 points by pg 6494 days ago | link

I think do is this macro.

-----

1 point by mflack 6417 days ago | link

Except semantically.

-----