Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua comment --~

Tags:

lua

luadoc

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?

like image 381
AlexStack Avatar asked Oct 26 '25 04:10

AlexStack


2 Answers

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.

like image 56
daven11 Avatar answered Oct 29 '25 07:10

daven11


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.

like image 45
RBerteig Avatar answered Oct 29 '25 08:10

RBerteig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!