Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.fortran    |    Putting John Backus on a giant pedestal    |    5,127 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 4,615 of 5,127    |
|    Lawrence D'Oliveiro to Andrew    |
|    Re: Implicit Semicolons And Statement-Co    |
|    06 Feb 24 20:07:30    |
   
   From: ldo@nz.invalid   
      
   On Tue, 6 Feb 2024 10:14:20 +0100, Andrew wrote:   
      
   > Looking at the JavaScript example. One pair of () brackets is easy to   
   > keep track of, multiple nested brackets (complex expressions) can lead   
   > to mismatched brackets and very confusing / entertaining syntax errors.   
      
   One technique I have found for minimizing errors is to always enter   
   the closing bracketing symbol immediately after the opener, then start   
   inserting the stuff that does between. This reduces the chance of   
   bracketing mismatches.   
      
   Here’s a more complex example: using indentation in a two-dimensional   
   layout to make clearer the structure of the expression:   
      
    const SECONDS_PER_MINUTE = 60   
    const SECONDS_PER_HOUR = 3600   
      
    document.getElementById("content").innerHTML =   
    Array.from   
    (   
    function*() /* generate entries */   
    {   
    for (let i = 0; i <= 32; ++i)   
    {   
    yield i * SECONDS_PER_HOUR / 4   
    } /*for*/   
    }(),   
    function(t) /* format entries as hh:mm */   
    {   
    const hours = Math.floor(t / SECONDS_PER_HOUR)   
    const minutes = Math.floor((t - hours * SECONDS_PER_HOUR) /   
   SECONDS_PER_MINUTE)   
    return "" + hours + ":" + (minutes < 10 ? "0" : "") + minutes   
    }   
    ).reduce   
    (   
    (sofar, elt) => /* join entries into a single string */   
    sofar + (sofar != "" ? ", " : "") + elt,   
    ""   
    )   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca