LF: Fargo Communal Library, suggestion


[Prev][Next][Index][Thread]

LF: Fargo Communal Library, suggestion



Tim Gerla wrote:
> 
> Here's a start to the Fargo Communal Library. I included two routines
> that change the contrast, and an example program. Please tell me what
> you think, and lets make a great library!
> 
> -Tim
I have a couple suggestions about the library
THe problem with a "communal library" is that many different versions
could be distributed, causing incompatibility with different versions.

Also, some authors may want to contribute to the project, yet not have
their source distributed.

My soloutions would be to do the following:
keep the main source code private, yet include a sources.zip file or
something similar for those programmers that want their routines source
to be distributed.  This would also make it easire to look through the
zip file for just the source you need to learn from, and not be confused
by the rest. (for newbies of course... not us pros ;) hehe)

also, you should add a version function, such as this:
;;
	label	ver
	move.l	comunal_ver,d0
	rts
comunal_ver	dc.l	#1
;;
So that a programmmer could make sure the version is new enough to
contain all the rouines needed.

for example, if a program needs a line drawing routine that may have
been added in "revision 12" they could use the following code:
;;
	jsr		fargo[ver]
	cmp		#12,d0
	ble		will_work
	jsr		flib[clr_screen] ;maybee clr_scr?
	setfont		#2
	writestr	#10,#10,#2,old_lib
	jsr		flib[idle_loop]
will_work:
;main program here
;;
actually,now that I think about it, this could be simplified by putting
that code in the library itself, making the following:
;;
	label		ver
	move.l		comunal_ver,d0
	rts
comunal_ver	dc.l	#1

	label		is_ver
	movem.l		d1-d7/a0-a6,-(a7)
	move.l		d0,d1
	move.l		comunal_ver,d0
	cmp		d0,d1
	ble		will_work
	jsr		flib[clr_scr]
	setfont		#2
	writestr	#10,#10,#2,old_lib
	jsr		flib[idle_loop]
	move.l		#0,d0	
will_work:
	movem.l		(a7)+,d1-d7/a0-a6
	rts
old_lib	dc.b	"This program requires a newer FargoC lib."
;;
;input: d0.l as expected version
;output d0.l is current version, or 0 if unsupported
making only the following necessary in a program to check versions:
;;;
	jsr		fargo[is_ver]
	cmp		#0,d0
	beq		end
;program code
end:
	rts
;;;

the version number would be updated whenever a function is added, or
midified so much to make it distinguishable from others

the fargoc.fn file could also list the minimum version required for each
function, so that programmers could know exactly what version is the
oldest version that could be used.


-- 
Christopher Poole
poole.christopher@paradox.net
http://www.paradox.net/homepages/poole
http://mycorner.home.ml.org
http://poole.home.ml.org


Follow-Ups: References: