Lowercase keywords

LISTO 19 lists keywords in lowercase, but how do you get Matrix Brandy to accept lowercase keywords on input (assuming you can)?
>LISTO 19
>LIST
   10 print pi
>print pi

Mistake
>

Comments

  • Soruk
    edited August 15
    This is not supported (and is not supported by ARM BBC BASIC either).

    There is a huge risk of breaking existing code by adding this, as variable names can be made easily distinguishable from keywords simply by using lower case, but supporting lower case keywords would break this.

    Matrix Brandy saves programs in plain text and tokenises them upon loading, thus a program that previously worked would be at risk of being broken.
  • Hated_moron
    edited August 15
    Soruk wrote: »
    This is not supported (and is not supported by ARM BBC BASIC either).
    OK, but why, then, is there an option for listing a program in lowercase keywords? Listing it in a format that it doesn't accept on input seems, how shall I say, peculiar at the very least! If this is an ARM BASIC thing I suppose I should be asking the question elsewhere, but it boggles my mind. :wink:

    There's a discussion at the 'BASIC Programming' Facebook Group where it is stated that many BASICs do the opposite: that is accept lowercase keywords on input but provide the option to list them in capitals. That makes sense, since capital keywords are always accepted, but not what Matrix Brandy does.
    Matrix Brandy saves programs in plain text and tokenises them upon loading, thus a program that previously worked would be at risk of being broken.
    Well yes, but there is exactly the same risk in BB4W and BBCSDL if the program is re-tokenised for any reason, so I don't see how it's significantly different.

    Enabling the Lowercase Keywords option - which I don't recommend - is a choice made by the user, and if he makes that choice he must accept the consequences. It's not as though any irreversible loss arises, he simply has to disable that option before loading the old program again!

    Trying to protect the user from his own mistakes is all very well, but not at the loss of a facility that many people want. My question was prompted by somebody at Facebook commenting that being forced to enter keywords in capitals was his main complaint about Brandy.
  • It is indeed a thing in ARM BASIC too, the same LISTO value will list keywords in lower case, but they must still be entered in upper case.

    By not implementing this in Brandy isn't really protecting users from themselves, it's not breaking compatibility with old programs that might use variables like "count" and "width" which would cease to be valid variable names.
  • Soruk wrote: »
    It is indeed a thing in ARM BASIC too, the same LISTO value will list keywords in lower case, but they must still be entered in upper case.
    I'm guessing this wasn't a decision by Sophie, who I credit with more sense!
    By not implementing this in Brandy isn't really protecting users from themselves, it's not breaking compatibility with old programs that might use variables like "count" and "width" which would cease to be valid variable names.
    As I said, it's no worse than the equivalent option in BB4W/BBCSDL/BBCTTY - if the program gets retokenised - and I've not had any complaints from users that it "breaks compatibility", because it doesn't. You can still load and run old programs saved when that option wasn't enabled.

    In fact in Brandy it would be less dangerous than in my versions, because with mine you could potentially re-save the program before you noticed the option is enabled, and that could be irreversible. You couldn't make that mistake in Brandy because it saves the program in plain text.

    zm5axtf0knpn.png

  • Soruk
    edited August 15
    Actually, up until a commit a few minutes ago, SAVE was affected by LISTO! Just never noticed it before as it's not a feature I use, so with your current build SAVEing a program with LISTO 16 set would render an unloadable program.

    Now that is fixed, I could look to seeing if acceptance of lowercase keywords is feasible with a runtime toggle. Upstream allows immediate-only commands to be accepted in lower or uppercase, but regular keywords were uppercase only. I removed that very early on as it appeared to be a strange anomaly and didn't match either 6502 or ARM BBC BASIC in behaviour (and it was hardwired, not toggleable).
  • Adding lowercase support back (and across the board, not just immediate mode only keywords) was surprisingly straightforward. So it's added, though disabled by default, and can be enabled with the command line option. '-lck', the config file option 'lowercase' or at runtime with SYS "Brandy_AllowLowercase",1 (use 0 to switch it back off).

    I've manually rebuilt the nightlies so this addition is already available for Windows, Linux EL7-9 and Fedora 38-40.
  • Soruk wrote: »
    Actually, up until a commit a few minutes ago, SAVE was affected by LISTO!
    Dare I ask whether that 'feature' has been in Matrix Brandy for very long? Was it caused by a recent change or has it been there for some time, perhaps even in upstream Brandy?!
  • Soruk
    edited August 16
    It's in upstream:
    [soruk@AlmaVM8 tmp]$ tbrandyupstream 
    
    Brandy Basic V Interpreter Version 1.20.1 (Linux) 24-Sep-2014
    
    Starting with 524288 bytes free
    
    >10 PRINT PI
    >RUN
    3.14159265
    >LISTO 16
    >L.
       10print pi
    >SAVE "pitest" 
    >Q.
    [soruk@AlmaVM8 tmp]$ cat pitest 
       10print pi
    [soruk@AlmaVM8 tmp]$ tbrandyupstream 
    
    Brandy Basic V Interpreter Version 1.20.1 (Linux) 24-Sep-2014
    
    Starting with 524288 bytes free
    
    >LOAD"pitest"
    >L.
       10print pi
    >RUN
    '=' missing or syntax error in statement has misled interpreter at line 10
    >Q.
    [soruk@AlmaVM8 tmp]$ _
    
  • I did spot an error in my lowercase implementation - LOAD / CHAIN also followed the setting (as they also use the same underlying primitives for reading text to tokens). This has now been fixed so a program MUST have upper-case keywords irrespective of the lowercase keyword setting. A program written outside of Brandy that contains lowercase keywords can be read in using *EXEC.
  • Soruk
    edited August 16
    Soruk wrote: »
    It is indeed a thing in ARM BASIC too, the same LISTO value will list keywords in lower case, but they must still be entered in upper case.
    I'm guessing this wasn't a decision by Sophie, who I credit with more sense!
    I wouldn't be so sure about that...
    This is an (emulated) ARM Evaluation System second processor, with the original V1.00 ARM BASIC - and that supports LISTO 16.
    ihab8k57nffi.png