3

I know LuaDoc uses "---" on the first line of comments like this:

--- an example function
-- @param a parameter a desc
-- @param b parameter b desc
function f (a,b)
   --code
   --code
end

However I see this in the beginning of comments:

--~ comment for a function
function f (a,b)
   --code
   --code
end

does it have special meaning?

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
AlexStack
  • 16,766
  • 21
  • 72
  • 104
  • Whoops. Deleted my answer as I didn't see that that was a "dash dash tilde" in the second code rather than "dash dash dash". I'm inclined to think that's a typo, but hard to say without context. – Conspicuous Compiler Aug 03 '11 at 17:41
  • Where have you seen "--~" used in the wild? I don't see any reference to it in the LuaDoc documentation. Also, I've corrected LUA to Lua. Lua is not an acronym, it is a proper noun. – RBerteig Aug 03 '11 at 18:13
  • 1
    Note that LuaDoc is not the only tool in the wild. Maybe your code assumes something else would be used? – Alexander Gladysh Aug 04 '11 at 06:30

2 Answers2

9

The SciTE editor distributed with Lua for Windows uses this as a marker for their automatic commenting facility.

Try selecting a block and select 'Edit/Block Comment or Uncomment' from the menu, it adds --~ to the front of the line. Likewise Uncomment removes it. However if you just have --, then select the menu option it doesn't recognize this as a comment, and adds it's own comment --~.

I've assumed that it has no significance, it's just an easy marker for the SciTE editor to parse. As noted by RBerteig there is no special significance of --~ to LuaDoc, and it is otherwise just a comment like any other to Lua itself.

Community
  • 1
  • 1
daven11
  • 2,905
  • 3
  • 26
  • 43
  • this is actually the correct answer. the code was written by an amateur in Scite Windows, so I assume he just thought all the comments should be written with --~ instead of -- – AlexStack Aug 04 '11 at 11:44
  • +1. Adding another answer with new information is always welcome at SO. Even more so when the new answer reveals the actual origin of a mystery as you have done here. I've edited it to fix a format quirk, and make reference to the idiom having no other meaning to either Lua or LuaDoc. – RBerteig Aug 05 '11 at 02:17
3

Apparently not.

Inspection of the implementation of the version of LuaDoc included in Lua for Windows reveals that there appears to be no case where a comment of the form --~ is noticed by its parser as anything other than an additional line of a LuaDoc comment block that began with a --- comment.

That is, it is possible that a comment beginning with --~ can continue a documentation comment block, but not introduce a document comment block.

Without additional context, it difficult to guess whether this was a typo or a way to leave a nearly correct LuaDoc comment that will be ignored until the tilde is changed to a dash. The latter interpretation is plausible if the context made the function marked that way appear to be a boiler plate template. In that case, when the template is copied and pasted for use, one would be expected to fix up the comment to make it visible to subsequent runs of LuaDoc.

RBerteig
  • 41,948
  • 7
  • 88
  • 128