Previous Thread
Next Thread
Print Thread
6.5.1725.0 -- DATN(x,y), FACT(x) #35888 07 Feb 23 06:44 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content OP
Member
OP Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
It has been pointed out that we somehow overlooked the important trigonometric function DATN(x,y) which has been supported in AlphaBASIC as far back as 1.3.

Nearly as mortifying is the discovery (thanks to Bob Fowler for both of these observations) that the FACT(x) implementation was not properly dealing with non-integers.

Both of these gaping holes have been filled in 6.5.1725.0, available here...

ash-6.5.1725.0-w32-upd.zip
ash65notes.txt

Note that the VERSYS.LIT update mentioned in the notes is available via the UPDCUR utility.

Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #35891 08 Feb 23 05:41 PM
Joined: Sep 2002
Posts: 5,450
F
Frank Online Content
Member
Online Content
Member
F
Joined: Sep 2002
Posts: 5,450
Apparently the "gaping" hole was more of a pin prick! crazy

Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36853 04 Dec 23 05:25 PM
Joined: Jun 2001
Posts: 713
S
Steven Shatz Offline
Member
Offline
Member
S
Joined: Jun 2001
Posts: 713
I recently updated to A-Shell v7.0 from v6.5.1722.2 and discovered that "DATN" is now a keyword. Can you set up a way to override its use as a keyword? I have hundreds of modules with over 5,000 references to DATn (lowercase last letter) as a subfield of an array. (PS: It is doubtful I will ever need the double arctangent function.)

Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36854 04 Dec 23 06:53 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content OP
Member
OP Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Never need the double arctangent??? shocked With apologies to Captain Renault, I'm shocked ! As the judge might say, ignorance of the trigonometric functions is no excuse!

However, I guess I'm not shocked that any seemingly innocuous refinement would break someone's code; if fact, that almost seems to be a given. And that the problem doesn't surface until months or even years later.

Usually I'm pretty careful about introducing keywords, typically adding a dot prefix to avoid this kind of conflict (which is why we have so many dot variables and dot functions). But that didn't seem like an option with DATN(), which had apparently been part of AlphaBASIC going way back. (Maybe even to "the beginning"?)

So, what's the workaround? My first thought was that maybe we could treat DATN as a non-keyword unless it was an array, i.e. DATN(...). But if it's a sub-field of an array, I suspect that you have actual DATn(...) references in your code. And the fact that you are using mixed case, while maybe technically providing a keyhole opening for a distinction, introducing case sensitivity for keywords would seem like a violation of an otherwise universal rule: keywords are not case sensitive; variables are. Also, even if as a practical matter all your DATn() references have only one dimension, using that as the distinction between a system function and an application array is just too ugly to consider (and would totally prevent the compiler from tagging an invalid number of subscripts).

If all of your DATn references were in ++include modules, you could use the new transclude feature to incorporate pattern substitution into the process, converting DATn to, say DATnx. But if you have hundreds of programs to update, that might not seem so attractive.

Another workaround would be to take this as an opportunity to learn the wonderful UNIX utility sed, which you could combine with find to make a single-line script that would convert all occurrences of DATn in all of your files to something else. Given how powerful that is, you might spend many hours testing and refining your script to make sure it didn't have side effects, and then you'd have to recompile and perhaps redistribute all your programs. So, still a big operation.

Yet another workaround would be to revert to using the standalone compiler, in which case you could use a version prior to compiler edit 1014, and even create a COMPIL.DO that was command line and command file compatible with COMPIL.LIT. But, you'd be unable to access any language features added since then.

Other than that, I guess yet another switch could be added to the compiler, but it does seem kind of overkill for just one symbol. If going to all that trouble to add a compiler switch/feature, it seems like it should do something more generally useful. One idea that comes to mind would be to extend the DEFALIAS statement to allow substitution of identifier names (whether keywords or variables), rather than just function names. You could then insert something like DEFINE DATn = DATnx into your top-level common include (after first doing a global search for any occurrences of DATnx. But I'd have to seek spiritual counsel as to whether that constituted a 7.1 enhancement rather than a 7.0 bug fix.

Any other ideas? Actually, I just thought of another: I suppose we could use a variation of a hack currently used with the identifier DEBUG. I see now that the documentation fails to mention this, but if DEBUG appears as a mapped variable, then it is treated as such; otherwise it is treated as a keyword indicating the status of the SET DEBUG option. Even though it's a hack, it might just pass muster as a refinement that can be slipped into 7.0.

Let me know what you think; in any case we should probably take some time to see if any better ideas surface before taking any rash action.


Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36855 04 Dec 23 10:18 PM
Joined: Jun 2001
Posts: 713
S
Steven Shatz Offline
Member
Offline
Member
S
Joined: Jun 2001
Posts: 713
Would it be any easier to add an OPTION statement to the Miame INI (e.g., OPTION=NODATNFUN)?

Is there a way to rename a built-in function, and if renamed, would that also change the compiler keyword?

Is there a way to make the "DEFINE" statement ignore the fact that DATN is a keyword? Then, I could redefine all of my occurrences of DATn as DATy?

Could you invent a new A-Shell BASIC statement to remove a keyword for a function that I swear I will never use? REMOVE-KEYWORD DATN

How about a version of A-Shell that omits the DATN() function and DATN keyword? (Like old times)

The "transclude" idea won't work in my case. Almost all of my DATn mappings are at the BAS level, not in a BSI.
The "sed" solution involves changes to too many modules. I would like to avoid that.

I would be OK with a new compiler switch.

Your last idea, the hack, is my preference since I wouldn't have to make any changes at all.

Sorry, I don't have any better ideas at this time.

Last edited by Steven Shatz; 04 Dec 23 10:19 PM.
Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36856 04 Dec 23 10:41 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content OP
Member
OP Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Well you get an A for brainstorming effort. And improvements to the DEFINE or DEFALIAS statement might be worthwhile anyway. But for now, I think we agree that the last idea is the easiest for both of us. And even though it is a kind of hack, it's intuitive and doesn't require you to change anything. (Provided of course that you have actually mapped the DATn variable before referencing it. But in that case, you'd deserve to be forced to do some work to clean that up!)

I've been queueing up a few other minor fixes and will plan on posting a 7.0.1752.2 update tonight or tomorrow. To speed things up, remind me of which platform(s) you're using.

Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36857 04 Dec 23 10:54 PM
Joined: Jun 2001
Posts: 713
S
Steven Shatz Offline
Member
Offline
Member
S
Joined: Jun 2001
Posts: 713
I'm running on Centos v7.9 (customer is on Centos 7.5). Interface is AlphaLAN.

Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36858 05 Dec 23 06:39 AM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content OP
Member
OP Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Ok, the update is available at:

ash-7.0.1752.2-el7-upd.tz
ash70notes.txt

The Windows and ATE versions can be updated from the Help > Check For Updates menu. The other Linux platforms will come along in the next day or two.

Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36872 13 Dec 23 06:05 PM
Joined: Jun 2001
Posts: 713
S
Steven Shatz Offline
Member
Offline
Member
S
Joined: Jun 2001
Posts: 713
Sorry it took so long to respond. I downloaded the tz update and installed ashell 7.0.1752.2. When I try compiling, I get the same DATn errors. Is there a new version of complp.lit to go with the revised ashell module?

I tried UPDCUR in SYS: That gave me COMPLP.LIT v1.1(137) - an upgrade from my v1.1(136). However, recompiling still produced the same errors.

Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36874 13 Dec 23 07:18 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content OP
Member
OP Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Hmmm.... confused

The 137 update of COMPIL.LIT (which is identical to COMPLP.LIT except for the name) was from a year ago, fixing a display issue relating to the scroll-back on non ATE clients, and also fixing a problem with not setting the default switches properly based on the LIT name. In other words, not related to this issue.

The actual fix is in the compiler code which is embedded inside the ashell executable. You can view that version by entering COMPIL (or COMPLP) without any arguments. It should be 1041. If not, then somehow we have a mixup in the versions. (Use VER to verify the A-Shell version.)

Here's a sample test program:
Code
 MAP1 ARRAY(10)
        MAP2 DATN(3),F

    DATN(2,3) = 23
    ? "DATN(2,3) = ";DATN(2,3)
end

When compiled under a prior version of the compiler, it generates the error ?Keyword or function (DATN) illegal - variable ID expected...

Under compiler 1041+ / A-Shell 7.0.1752.2+ it should compile without error and display 23 (i.e. the value of the array element). This is because the compiler, having seen DATN mapped as a variable, treats DATN(2,3) as an array element rather than a trig function.

If you comment out the first two instances of DATN (or change them to DATX), then it treats DATN(2,3) as the trig function and outputs 0.588003

If that doesn't clear things up, you may need to make me up a little sample to illustrate the problem.

Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36877 13 Dec 23 10:27 PM
Joined: Jun 2001
Posts: 713
S
Steven Shatz Offline
Member
Offline
Member
S
Joined: Jun 2001
Posts: 713
Your test program compiled cleanly and both variations (DATN as a variable and DATN() as a function) worked as described. So I realize I have a different problem than before. The errors I get when I compile with my variable defined as MAP2 DATn,S,75 are:

.complp BINUPD /m /a /av /s /n /i /x:2 /P /LF
run1:fil607.bsi[307,210]:41: ?Syntax error - DATn(01) = BINDER'INS'NAM1 -->> DATn(01) = BINDER'INS'NAM1 [EOL]
run1:fil607.bsi[307,210]:42: ?Syntax error - DATn(02) = BINDER'INS'NAM2 -->> [premature EOL]
run1:fil607.bsi[307,210]:43: ?Syntax error - DATn(03) = FN'fmtdate$(BINDER'POL'FROM,"mm/dd/yy") -->> ,"mm/dd/yy") [EOL]
etc.
End of compilation [Errors exist!]

If I change your program to more closely match my set up:

Code
 MAP1 ARRAY(10)
        MAP2 DATN,S,75     ! a single string instead of a float array

    DATN(1) = "This is a test"
    ? "DATN(1) = ";DATN(1)
end

It still compiles and runs fine.

However, when I use my variable name DATn, I get:

Code
.complp a /m /a /av /s /n /i /x:2 /P
a.bas:4: ?Syntax error  - DATn(1) = "This is a test" -->> DATn(1) = "This is a test" [EOL]
a.bas:5: ?Syntax error  - ? "DATn(1) = ";DATn(1) -->> ) [EOL]
End of compilation [Errors exist!]

Can you force your fix to be case-insensitive?

Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36878 13 Dec 23 10:45 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content OP
Member
OP Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Ugh. My fault for not noticing the case sensitivity complication. (There's a mismatch between the case sensitivity of variable name and the insensitivity of system functions and other keywords, which led to the disconnect here.)

By coincidence Joe just discovered an unrelated compiler issue (not exactly a bug but a failure to complain about a statement that doesn't quite make sense), so I'll fix them both and post an update later tonight or tomorrow.

Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36879 14 Dec 23 01:29 AM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content OP
Member
OP Online Content
Member
J
Joined: Jun 2001
Posts: 11,645

Re: 6.5.1725.0 -- DATN(x,y), FACT(x) [Re: Jack McGregor] #36880 14 Dec 23 04:53 PM
Joined: Jun 2001
Posts: 713
S
Steven Shatz Offline
Member
Offline
Member
S
Joined: Jun 2001
Posts: 713
That fixed it. Everything compiles properly again. Thank you!


Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3