Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Line, block and nested comments - Lua compared to other languages

You can comment your Lua program in two ways.

a) using comments that start -- , in which case they run to the end of the line - so that's a line comment

b) starting --[[ , in which case they run through to the next ]] which may be in the same line, or a number of lines later - so that's a block comment

Line and block comments are common in many other languages too
• in PHP, for example, a line comment starts with a # or //, and a block comment runs from /* to */.
• in C++ and in Java, line comments start with //, and block comments run from /* to */.
• ANSI C only supports block comments from /* to */, though some extended compilers accept line comments from //.
&bull, In Tcl, Perl and Python you have just line comment support from # to the end of the line
and in all the languages we teach, blank lines will be ignored too so are in effect a separating comment

One of the things I regret about block comments in most langauges is that they cannot be nested. In other words, you can't write a comment with a comment. "Does this matter?" you ask. Yes, it does to me ... I want to be able to comment out a whole block of code that's already got comments within it, and that's a problem where the end of the inner comment also forces the end of the outer comment. Lua (uniquely in the languages we teach) provides a solution in that block comments can start with extra = signs between the [ and [, and then the terminating sequeence need to have the same number of == signs ... so

  print ("This will be printed first")
  
  --[===[ Comment out a whole big block!
  
  --[[ This is a multiline comment telling you about
  the work this code is doing ]]
  
  print ("This will not be printed in the middle")
  
  --[[ This is another multiline comment telling you about
  the work this code is doing ]]
  
  end of big block comment ]===]
  
  print ("This will be printed last")


will just print out two lines, with the one in the middle being skipped.

Examples, in context - see [here].
(written 2014-05-04, updated 2014-05-06)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
U101 - Introduction to Lua.
  [1111] Training in Lua - (2007-03-16)
  [1695] Lua Course - here is the index - (2008-07-03)
  [1699] If you are learning Lua, here are some more examples - (2008-07-06)
  [1737] Rules, suggestions, considerations for Lua variable names - (2008-08-05)
  [1842] Lua Course, and the Wiltshire Countryside too - (2008-10-16)
  [2310] Learning to write high quality code in Lua - (2009-07-30)
  [3724] Learning to Program in Lua - public / open training course / class - (2012-05-09)
  [4324] Learning to program - variables and constants - (2014-11-22)


Back to
Embedding Lua to perform tailored code at an interval
Previous and next
or
Horse's mouth home
Forward to
Lazy operators in Lua - what they mean, and examples
Some other Articles
Eurpoean Elections, and other elections ahead. Some thoughts on campaigns and policies
String formatting in Lua - string.format as a wrapper for sprintf
Dot or Colon separator between table name and member in Lua - what is the difference?
Lazy operators in Lua - what they mean, and examples
Line, block and nested comments - Lua compared to other languages
Embedding Lua to perform tailored code at an interval
Survey - Journeys
Metrics - historic and current TransWilts train use
How effective is our publicity?
Facebook marketing - who are we reaching?
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2021: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4271_Lin ... uages.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb