Coding conventions

new topic     » topic index » view thread      » older message » newer message

Code wrapping conventions: From the developers list, there was talk about wrapping. Now, if you wrap you have to set a specific line length. Suppose you don't set any line length at all? You're editor does the wrapping for you but sometimes the structure is not clear when you leave it to the editor. I have taken this here beause it is more suitable for illistration purposes.

Here is no wrapping:

	-- lower for Windows or DOS, lower for all.  K.I.S.S. 
	sequence translator_base = lower(translator[search:rfind(SLASH,translator)+1..$]) 
	sequence interpreter_base = lower(executable[search:rfind(SLASH,executable)+1..$]) 
	integer dos_or_win = find(platform(),{WIN32,DOS32}) 
	if (match( "eucd", translator_base ) != 0) or ( length(translator) = 0 and platform() = DOS32 ) then 
		-- NOOP 
	elsif (match( "ecw", translator_base ) != 0 and dos_or_win)or (match( "euc", translator_base ) != 0 and dos_or_win ) or ( length(translator) = 0 and platform() = WIN32 ) then 
		translator_options &= " -CON" 
	elsif ( match( "ecu", translator_base ) != 0 ) or ( match( upper("euc"), upper(translator) ) != 0 )or ( length(translator) = 0 and find( platform(), { LINUX, FREEBSD, OSX, SUNOS, OPENBSD } ) ) then 
		-- NOOP 
	elsif match( upper("ec.exe"), upper(translator) ) != 0 then 
		-- NOOP 
	else 
		printf( 2, "Cannot determine translator\'s platform.", {} ) 
		abort(1) 
	end if                                   

Here is wrapping at 132:

	-- lower for Windows or DOS, lower for all.  K.I.S.S. 
	sequence translator_base = lower(translator[search:rfind(SLASH,translator)+1..$]) 
	sequence interpreter_base = lower(executable[search:rfind(SLASH,executable)+1..$]) 
	integer dos_or_win = find(platform(),{WIN32,DOS32}) 
	if (match( "eucd", translator_base ) != 0) or ( length(translator) = 0 and platform() = DOS32 ) then 
		-- NOOP 
	elsif (match( "ecw", translator_base ) != 0 and dos_or_win)or (match( "euc", translator_base ) != 0 and dos_or_win ) 
		or ( length(translator) = 0 and platform() = WIN32 ) then 
		translator_options &= " -CON" 
	elsif ( match( "ecu", translator_base ) != 0 ) or ( match( upper("euc"), upper(translator) ) != 0 ) 
		or ( length(translator) = 0 and find( platform(), { LINUX, FREEBSD, OSX, SUNOS, OPENBSD } ) ) then 
		-- NOOP 
	elsif match( upper("ec.exe"), upper(translator) ) != 0 then 
		-- NOOP 
	else 
		printf( 2, "Cannot determine translator\'s platform.", {} ) 
		abort(1) 
	end if                                   

Here is wrapping at 80 (for console editors)

	-- lower for Windows or DOS, lower for all.  K.I.S.S. 
	sequence translator_base = 
	lower(translator[search:rfind(SLASH,translator)+1..$]) 
	sequence interpreter_base = 
	lower(executable[search:rfind(SLASH,executable)+1..$]) 
	integer dos_or_win = find(platform(),{WIN32,DOS32}) 
	if (match( "eucd", translator_base ) != 0)  
	    or ( length(translator) = 0 and platform() = DOS32 ) then 
		-- NOOP 
	elsif (match( "ecw", translator_base ) != 0 and dos_or_win)  
		    or (match( "euc", translator_base ) != 0 and dos_or_win ) 
		    or ( length(translator) = 0 and platform() = WIN32 ) then 
		translator_options &= " -CON" 
	elsif ( match( "ecu", translator_base ) != 0 )  
		    or ( match( upper("euc"), upper(translator) ) != 0 ) 
		    or ( length(translator) = 0 and  
		         find( platform(),  
			 { LINUX, FREEBSD, OSX, SUNOS, OPENBSD } ) )  
		    then 
		-- NOOP 
	elsif match( upper("ec.exe"), upper(translator) ) != 0 then 
		-- NOOP 
	else 
		printf( 2, "Cannot determine translator\'s platform.", {} ) 
		abort(1) 
	end if                                   

There is also the subject of what is the best indent size, given 80 line length, 8 is too big IMO.

Shawn Pringle

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu