Saturday, November 25, 2023

📚 An approach to line identifiers: an emoji + number + label hybrid

NOTE: I have a cognitive disability and Fuch's Dystrophy, so finding ways to overcome both of these challenges is an on-going and ever-evolving process of continuous improvement/experimentation !

For the longest time, I used to avoid using GOTO and GOSUB because I wanted to avoid unstructured programming at all costs, GOTO and GOSUB being part of unstructured programming.

I've found myself over the last year seeing GOTO and GOSUB in a different light, often finding them useful in the context of structured programming.  As I've been increasingly making use of these statements, I've also been reevaluating my usage of line identifiers.  What I've realized:

  • I heavily dislike line numbers, because the numbers don't mean anything to me
  • I dislike line labels because they do not make it easy for me to locate the related line (when looking at a GOTO or GOSUB statement)
However:
  • I really like sequential line numbers because they help me locate (i.e. scroll to) the related line (when looking at a GOTO or GOSUB statement)
  • I really like descriptive line labels because they help me identify what I'm jumping to (two birds with one stone: serving the purpose of line identification for the program, and serving the purpose of telling the programmer what's going on (so no need to clutter the code with a comment)
So it struck me: I need line labels that give me both benefits (line number to locate the related line, and descriptive text to let me know what the GOTO or GOSUB is for.

So the format I need for line labels:  999_XXX:
  • "999" is an integer number of any length (the number can even have leading zeroes)
  • The underscore is only a suggestion (you can omit it or use any other valid character)
  • "XXX" is whatever mixture of alphabetic characters, numeric characters, emojis, and other valid characters
    • other valid characters
      • accented characters
      • exclamation mark and question mark
      • non-consecutive tildes
      • non-consecutive "tick marks"
      • # $ % |
    • INVALID characters (i.e. we cannot use these in line identifiers
      • space character
      • period and comma
      • tilde and "tick mark" (`)
      • single quote (') and double-quote (")
      • @ ^ & * ( ) - + = / \ > <  { } [ ] : ;
  • The semi-colon (:) suffix (i.e. the last character) is required
However, I've found it helpful to prefix line labels with emojis to indicate that a line identifier is part of a sequential group of identifiers.  I find this helps to quickly visually identify a group of related identifiers.

So the final format I need for line labels:❓999_XXX:
  • ❓ is whatever emoji (or even a unicode character) that is available and suitable to quickly let me know whether or not I'm in the right ballpark of code in my search for a particular line.
Here's are line identifiers from my BAM Draw program:

⚙120_do_new_drawing:
⚙130_init_program:
⚙140_prompt_height:
⚙150_prompt_width:
🖥210_refresh_canvas:
🖥220_setup_screen:
🍔310_show_menu_pick: 
🍔320_show_next_menu_item:
🍔330_toggle_menu_pick:
🖼410_do_grid:
🖼420_toggle_grid:
🖼430_undo_grid:
✒510_change_marker:
✒520_do_marking:
✒530_set_marker:
🎨610_change_color:
🎨620_show_color_menu:
🎨630_show_color_picks:
🎨640_toggle_color_menu_mode:
🔧710_do_export:
🧭810_MovL:
🧭820_MovR:
🧭830_MovU:
🧭840_MovD:

Of course, none of these line labels are that close to each other.  They are visually separated by several or more lines of code.  You'll have to verify yourself how this kind of line label format works by viewing the BAM Draw source code and searching for the lines of code that match the identifiers in GOSUB statements.



1 comment:

  1. It might be a good idea to make sure that emojis are not considered as a character that makes an identifier unique (i.e. something that distinguishes an identifier from another identifier.)

    Just in case an emoji used in a BAM program on one device does not misbehave on another device that does not support that emoji.

    I must chew on that idea a little bit before I update the post with some related guideline.

    ReplyDelete

🖥 Oriental Paintbrush Sim

This is a port and mod of a QBJS program ("Calligraphy Pro 128 Studio:  Oriental paintbrush mode") by Vince. Click/touch the canva...