Saturday, May 18, 2024

Single word comments

In Listack, I created "sugar words" to improve readability, the downfall of the homoiconic languages.  (Lisp, Joy, Factor, Listack, etc.)

    if: {> 5} then {"Is greater than 5." .println} else {Is not greater than 5." .println} 

In hindsight, this was a mistake.  It complicated the parser and slowed down the interpreter.  In addition, you could make your own sugar words - which could spell disaster if sugar words created in one module interfered with words in another.

As a simpler solution (and simpler is almost always better!), I created the single word comment.

    if: {> 5} #then {"Is greater than 5." .println} #else {Is not greater than 5." .println} 

This form is handled quite simply by the parser, has no effect on the interpreter, and you can't accidentally shadow a real word.  The effect is similar to optional keywords in other languages, but is accomplished more simply.

No comments:

Post a Comment

I reserve the right to remove egregiously profane or abusive comments, spam, and anything else that really annoys me. Feel free to agree or disagree, but let's keep this reasonably civil.