logoalt Hacker News

651012/09/20241 replyview on HN

I one time by sort of accident coined a config format by parsing todo.txt It was so useful it stuck around for much longer than I had intended to. Rather than comment out stuff it just looks for "=" and ignores everything else.

   conf = {};
   configFile.split('\n').forEach( function(x){
      y = x.split(' ');
      if(y[1]=="=") conf[y[0]] = y[2];
   });
Everything is a comment with exception of lines like:

speed = 100 km/h

weight = 60 kg

maxBuffer = 200 chars (between 100 and 300 works best)

output: {"speed":100,"weight":60,"maxBuffer":200}

It had walls of text with headings and something configurable sprinkled in. Crockford would be screaming. lol


Replies

selcuka12/09/2024

Reminds me of Whitespace [1] where anything but a whitespace is a comment.

[1] https://en.wikipedia.org/wiki/Whitespace_(programming_langua...