[Tutor] Useing Functions

Jeff Shannon jeff at ccvcorp.com
Sat Aug 21 00:17:19 CEST 2004

Danny Yoo wrote:

> Hi Jeff,
> Hmmm!  Sorry for taking this in an askew direction, but how difficult
> would it be to write a preprocessor?  You could write your programs in a
> kind of superset of Basic that has subroutines.  This superset wouldn't be
> directly executable, but would be input into a preprocessor.  This
> preprocessor could then transform that super-Basic back into regular
> Basic, and handle all the awkwardness of subroutine linkage, behind the
> scenes.

That should be possible, at least in principle, yes.  Of course, one 
of the big concerns I'd have to address is namespace collision -- in 
essence, every basic program gets stored in the same "directory".

[The Pick VM has a radically different filesystem architecture than 
the arbitrary-depth trees of unix and windows/dos.  The depth of the 
tree is strictly defined by the OS.  In essence, everything is a 
database table (except tables are called "files"); each program is an 
"item" (record) in one of these files (tables), and each line is an 
attribute (field) of that item.  All of our tools expect that all 
Basic programs (whether standalone or subroutines) will be in one 
file, and all of our UHL scripts (shell scripts, essentially) will be 
in a second file.  I'm not sure how much work it'd be to allow 
multiple "files" to contain executable code...]

Because all programs are in the same namespace, having lots of 
independent subroutines is also awkward -- there's currently 6756 
items there, which is a lot of names to check for collisions!  We have 
some naming conventions which help, but those have changed over the 

[As a side note, I've also been lamenting the difficulty of using CVS 
with our system.  It would require always editing files in Unixland 
(or Windowsland), and importing/exporting files from the database with 
every save/load.  That's not too hard, but our senior developer 
prefers to keep using the internal editor that he's very familiar 
with, so we'd have only a partial record in CVS...]

So, yes, I could write a preprocessor that'd take my super-Basic 
source code and save each function as a separate subroutine.  Of 
course, for this to be effective I'd also need to be able to edit 
existing programs written by someone else. This would require scanning 
PickBasic source to find all of the called subroutines and then 
including them.

Of course, the real problem here is that the other developers are used 
to writing long spaghetti code.  Even if I used this myself, I'd have 
a hard time convincing the senior developer that the way he's been 
programming for the last 15-20 years isn't good enough...  (It's also 
possible that there's better tools that he just hasn't bothered to 
learn, and therefore I've never seen.)

> Is there a specification on this old Basic dialect that we could look at?
> Just out of curiosity, of course...  *grin*

Well, it's not a spec, but a quick search on Google turns up 
http://www.jes.com/pb/ -- an online version of an introductory 
Pick/Basic book.

Jeff Shannon
Credit International

More information about the Tutor mailing list