Re: Just say 'YES' to strings (or not?)

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

irv mullins wrote:

> > Then it would also be possible to reduce the number of functions needed to
> > output stuff, resulting in a shorter learning curve, fewer errors, simpler
> > programming.
> 
> I don't see this being true.  Enlighten me.

atom a
integer i
sequence name, pantsize

a = 3.1415
i = 23
name = {"John","Doe"}
pantsize = {30,32}

Now, give me one line which can print all of these in a readable form.
In Python, it's:

print a,i,name,pantsize

[irv@localhost irv]$ python test.py
3.1415 23 ['John', 'Doe'] [30, 32]

(Python uses square brackets instead of curly)

A one-liner in Euphoria which gets nearly the same result:
printf(1,"%f %d %s %s %d %d",{a,i,name[1],name[2],pantsize[1],pantsize[2]})

Now, change the name to be {"John","M',"Doe} and see if it still works.
With Python (and Lua) it works, with Euphoria you have to rewrite your printf()
everytime a type or even the contents (in the case of sequences) changes.
If you want to get something similar without using printf(), 
you get the pleasure of writing:

print(1,a) puts(1," ")
puts(1,name[1]) puts(1," ")
puts(1,name[2]) puts(1," ")
print(1,pantsize)

> > When was the last time you wanted to compare two strings and get back a
> > sequence of ones and zeros?  Is there any reason you could not get that
> > result by writing a simple loop, in the rare event you really needed it?

<snip some code>

But a bmp sequence is not a string! 
Nowhere did I say we should do away with sequences or sequence comparisons.

Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu