Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Standardised extended libs???
#9
I think you misunderstand what I'm saying with point 2. 

What I'm saying is this:   You can't write your library knowing every default that a user has.  You have to code so that your library works with *any* default setting.

And what am I talking about with a default setting?

OPTION BASE 0
OPTION BASE 1

You wouldn't know which of those two statements an user of your library might have as their default.  If you just DIM foo(100), you could end up with issues if you assume foo() holds elements from (0 to 100) and the user has set OPTION BASE 1.

Instead of: DIM foo(100)
Explicitly define:  DIM foo(0 to 100)

No matter what option base they have or use, your code is now going to work with either of them without any issues.



Second example:

_DEFINE A-Z AS _FLOAT
DEFLNG A-Z
DEFDBL A-Z

You can't just assume that everyone is going to have a default variable type of SINGLE in their code.  

Don't:  DIM SHARED X, Y, Z
Instead:  DIM SHARED AS SINGLE X, Y, Z

Now, regardless of what DEF or _DEFINE an user has in their program, your library isn't going to have any issues meshing with it.

If you just DIM SHARED X, and *expect* X to be a default SINGLE, and the user has a line of DEFLNG A-Z at the top of their code, what's going to happen with your library?  It's probably going to explode and do stuff it's not supposed to do as X might be 0, or X might be 1, but it can never be 0.234567 like it's supposed to be for the library usage.



Same with arrays.  You can't *assume* that they're under $DYNAMIC or $STATIC.

Don't write your library with:
$DYNAMIC
DIM foo(10)

Instead, if foo is supposed to be a dynamic array and resizable for your usage:
REDIM foo(0 to 10) AS SINGLE

The first code had multiple possible conflicts with an user's program.  The use of Dynamic might have corrupted a global setting they were relaying on ($STATIC), for whatever reason.  foo() has an undefined lower base, so it *might* be 0; it *might* be 1.  How would you know?  foo() *might* be a SINGLE.  It might just happen to be a string.  Again, how would you know??  You don't know what DEF, _DEFINE, Option Base, $Dynamic/$Static the other guy is going to use in his library.

You have to assume that their default isn't going to match yours, and thus explicitly define your own stuff for a library.

REDIM foo(0 TO 100) AS SINGLE

With the above, it doesn't matter if they use $DYNAMIC or $STATIC.  You've declared that to be a redimmable array from the start.
It also doesn't matter if they have Option Base 0, or Option Base 1.  Your array foo() starts at base 0; you specified that explicitly.
It doesn't matter if they DEFINT A-Z or DEFSTR F or _DEFINE whatever type they want as their default variable tyle.  You've explictly declared foo() to be SINGLE.



*THAT'S* the type of thing I was speaking about with point 2 above.  You have to assume that everyone has their own style and that yours isn't going to match.  You can't take things for granted.  Explicitly define what you can and you'll make your library as user friendly as possible.  

And if it's NOT user friendly, you won't have a lot of friends using your library.  Big Grin
Reply


Messages In This Thread
Standardised extended libs??? - by Unseen Machine - 03-05-2025, 05:01 AM
RE: Standardised extended libs??? - by Petr - 03-05-2025, 06:27 PM
RE: Standardised extended libs??? - by SMcNeill - 03-21-2025, 08:16 PM
RE: Standardised extended libs??? - by mdijkens - 03-22-2025, 01:51 PM
RE: Standardised extended libs??? - by mdijkens - 09-02-2025, 11:53 PM
RE: Standardised extended libs??? - by SMcNeill - 08-30-2025, 04:41 AM
RE: Standardised extended libs??? - by SMcNeill - 09-02-2025, 09:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  The reverse of _droppedfile extended function needed doppler 0 311 09-25-2025, 03:19 PM
Last Post: doppler

Forum Jump:


Users browsing this thread: 1 Guest(s)