BSL:Introduction: Difference between revisions

→‎Syntax: moving details to BSL:Syntax; some syntax corrections
(wording; shortening a sample; improving a sample)
(→‎Syntax: moving details to BSL:Syntax; some syntax corrections)
Line 44: Line 44:
:''See [[BSL:Syntax]] for details.''
:''See [[BSL:Syntax]] for details.''


BSL allows two kinds of syntax to be used somewhat interchangeably, which can be called "shell-style" and "C-style". This can make it more complicated to talk about the language, and you can also generate errors with mixed syntax. Using the C style requires a bit more typing, but it creates safer and more readable code.
===Punctuation===
 
Braces define blocks of code, whether the block is a function or a conditional:
Braces define blocks of code, whether the block is a function or a conditional:


Line 73: Line 72:
The same code would look like this in shell-style BSL:
The same code would look like this in shell-style BSL:


  func some_function
  func void some_function(void)
  {
  {
     var int a
     var int a;
     a = 4
     a = 4
     sleep 60
     sleep 60
     if (a eq 4)
     if (a eq 4)
     {
     {
       dprint "Hello" # the quotes could be left out too
       dprint "Hello"
     }
     }
  }
  }


Notice that parentheses are always needed with "if" statements, and also note that the type (see "Types" below) of the function and its parameters can be left out in shell-style BSL (this meaning "void" implicitly).
Notice that parentheses are always needed with "if" statements and semicolons are always needed on variable declarations.


==Types==
==Types==