Re: sprintf() query

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

(*) everything is a number
(*) numbers can be used to represent text characters

I can identify three styles of output. (conventional languages only offer the 'data-type' style.)

(1) programmer output "the programmer chooses the look for the output."

(2) data output "the data chooses the look for the output"

(3) data-type output "the data-type chooses the look for the output."

Much more flexible than any conventional language.

-- programmer output 
 
object x  
	x = 1234 
	print(1, x) 	-- you chose 'print' for number output 
	--> 1234 
	 
	x = "hello" 
	puts(1, x)     -- you chose 'puts' for text output 
	--> hello 
-- data output 
-- warning: can not tell if a small integer is a character or a number 
 
object x 
	x = 1234 
	pp(x)		-- data seems to be numeric; output is numbers 
	--> 1234 
	 
	x = "hello" 
	pp( x )      -- data seems to be text; output is text 
	--> "hello" 
 
include std/pretty.e 
	pretty_print( x )	-- both numbers and text shown simultaneously 
	--> {104'h',101'e',108'l',108'l',111'o'} 
-- data-type output 
-- must invent a new procedure 'write' 
 
object x = 1234      -- objects are numeric 
string str = "hello" -- strings are text 
 
	write( x )		-- numeric data-type; numeric output 
	--> 1234  
 
	write( str )	-- string data-type; string output 
	--> hello 

Details still to be worked out.

_tom

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

Search



Quick Links

User menu

Not signed in.

Misc Menu