[Coco] DEFFN in Extended BASIC

Allen Huffman alsplace at pobox.com
Sun Jan 4 02:23:38 EST 2015


> On Jan 4, 2015, at 1:14 AM, Arthur Flexser <flexser at fiu.edu> wrote:
> 
> What that last program is doing is defining a function of the dummy
> variable AB as being equal to the sum of A and B.  So, regardless of what
> value of AB is used as an argument of the function, it returns A+B.  You
> could have made it DEFFNC(Q R)=A+B with the same result.
> 
> The program could be shortened to
> 10 A=10:B=1:PRINT A+B
> 
> In any case PRINTFNA(0) tokenizes to 6 bytes, PRINTA+B to 4 bytes, so
> there's no space saving.

Agreed. YMMV :) It would not makes sense for that. But for the program I was toying with:

DEFFNP(X Y)=1024+Y*32+X

"1024+Y*32+X" is 11 bytes

A line number and P=1024*Y*32+X takes 30 bytes.

A line number and P=FNP(X Y) is 26 bytes, so I can save 4 (at the loss of CPU time) every time I use it. (I just have to use it more times than the overhead for the DEFFNP line before it's break-even.)

Pity it's not available in Color BASIC, else it could be yet another trick to squeeze a tiny bit more memory out of those 4K programs.

		-- Allen


More information about the Coco mailing list