Re: [cc65] Directory/Drive functions

Date view Thread view Subject view

From: Greg King (gngking_at_erols.com)
Date: 2003-06-11 20:50:04


From: Groepaz
Date: Thursday, June 05, 2003, 11:43 AM
>
> On Thursday, 05 June 2003 11:21, Ullrich von Bassewitz wrote:
> > On Wed, Jun 04, 2003, at 11:33:11PM -0400, Greg King wrote:
> > > CBM programs are "sticky" (they stay in memory; we can rerun them
> > > without reloading them).  That means that we should avoid static
> > > initializers; and, programs should restore their environment,
> > > as much as possible.
> >
> > While I would say that you're right in most cases, I still don't think
> > it is true for DEVNUM.  Since every file operation changes DEVNUM,
> > programs and utilities for the CBMs do not expect DEVNUM to remain
> > unchanged when a program is run.  And, most C programs cannot be run
> > twice, because static data has changed.
>
> Actually, quite a bunch of tools DO use devnum to find out about the
> last-used drive.  However, the general advice on using these tools is
> "reset -- load -- run" too, so no real need for restoring environment.

Most CBM programs do not talk to the console through files, they use the
Kernal's default channels; and, when a program uses only one peripheral
device, DEVNUM does not change.

The fact that some old programs are badly written should not stop us from
making well-written new programs.  Tools should be easy to use -- and, easy
to re-use.  Not everyone has super-fast loaders :-).  Even when we do have
them, it is easier to re-run a program than it is to reload-and-run it.
(I want that convenience!)

That is why I said, "we should avoid static initializers."  Even
statically-stored variables, in tools, should have their first values set
dynamically (every time that the program runs).

I am not talking about a programmer's individual code for a specific
program.  I am talking about the "universal" library-code.  It should not
get in the way when programmers do make re-runnable programs.  (The library
already restores other things, such as the stack-pointer, zero-page,
vectors, a scroll-flag, and a margin.)  It takes only a few extra bytes to
restore DEVNUM.  I see no valid reason to leave it out.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-06-11 21:46:57 CEST