News:

Welcome to RetroCoders Community

Main Menu

LET now allows multiple variables

Started by CharlieJV, Feb 05, 2023, 01:41 AM

Previous topic - Next topic

CharlieJV

The LET statement was implemented such that it could only handle one value-to-variable assignment.

Now, the LET statement allows multiple value-to-variable assignments.


For example:
LET a$ = "howdy",  b$ = "there"

Taking advantage of line continuation, and the LET keyword becomes useful as a visual marker indicating the declaration or variables and value assignments:

LET a$ = "howdy", _
    b$ = "there"

As was the case before, the LET keyword is optional (when declaring and assigning a value to one, and only one, variable.)

CharlieJV

Oops, a little bug I have to fix.  Stay tuned.

CharlieJV


johnno56

"LET"... a statement I have not used in a 'long' time... Cool...
May your journey be free of incident.  Live long and prosper.

CharlieJV

Quote from: johnno56 on Feb 05, 2023, 11:43 AM"LET"... a statement I have not used in a 'long' time... Cool...

Using LET for one variable has never been much use to me.  But LET for a group of variables, that I like; a small and simple visual cue to say "hey", here's a bunch of variables.

Really, the big reason I gave LET that extra capability: I cannot stand the use of DIM to declare variables.  Kind of stuck in the mindset of "DIM is for arrays."

CharlieJV

A buddy made a very good point:


QuoteWhat's the difference between

10 let a=1, b=2

and
20 let a=1 : b=2

For me, it is about consistency.  I like things to at least have the option to work the same.

So having LET now work syntactically the same as CONST snuffs out an annoyance I had:

CONST A% = 1, B% = 2, C% = 3
LET A% = 1, B% = 2, C% = 3

In the scheme of things, that's kind of minuscule, but having them work differently is an attention-grabbing distraction (annoyance) otherwise.  Yeah, it doesn't take much.  SQUIRREL !

CharlieJV

And just because that was annoying me too ...

"DIM" has always been to me about declaring an array.

At some point, BASIC implementations started using that for declaring variables.

That has always annoyed me.

So as an alternative to DIM, I've setup the keyword VAR without getting into much fuss: VAR invokes the exact same code as DIM, so VAR can be used to declare arrays too.

The goal for myself is to use VAR for variables (if I'm not using LET), and use DIM for arrays.

Semantically/intuitively, that feels better to me.

CharlieJV

From the XOJO Blog:  Var, Dim or both?

Kind of neat to find, after the fact, that somebody else out there likes to use VAR for variables and keep DIM for arrays.