Re: String?

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

Pete Lomax wrote:
> 
> On Tue, 01 Jun 2004 07:50:08 -0700, irv mullins
> <guest at RapidEuphoria.com> wrote:
> 
> >Add to that the fact that user-written type checking does 
> >nothing to simplify or eliminate errors when doing output, so it's a 
> >half-solution at best.
> I still don't get that.

It really isn't that complicated:

Consider the following -
a = 12
b = 23.6609
c = "Hello"
d = [1,2,6,"Hi"]

>>> print a, b, c, d
12 23.6609 "Hello" [1,2,6,"Hi"]

That's python. You don't have to come up with the "right" function 
to properly print variables, python manages to keep track for itself 
what is a string and what is an integer, a float, or a sequence.

Lua does much the same.

Both, of course also have a printf() type of func for when you actually 
need special formatting, and like Euphoria's printf(), they are a bit slower
than print.

Now, without using printf, let's see you get Euphoria to display 
the contents of variable d:

constant d = {1,2,"Hi"}

print doesn't work, it displays: {1,2,{72,105}} - where's the "Hi"?

? doesn't work either, it displays:
{
  1,
  2,
  {72,105}
}

puts() won't even run:  
test.exu:10
sequence found inside character string
--> see ex.err

So not only do you have to pick and choose the correct output function 
for each variable (and each member of the variable) separately, but if 
the contents of a variable change, or the nesting changes, you have to 
go back and rewrite every line that outputs that variable.

Try changing {1,2,"Hi"} to {1,2,{"Hello","World"}} and see if it still 
works. Not even prinf() will help you here. 
printf(1,"%d %d %s %s\n",{d[1],d[2],d[3][1],d[3][2]})

Now make it {1,2,3,{"Hello","World"}} and see what happens.

Does anyone think that meets the definition of "simple"?
Python, Lua, and several other languages handle this in a 
straightforward manner, even though they do not have typed 
variables. Surely if Euphoria is going to make us declare types, 
it could make use of that information later. And user-written 
type checking isn't going to help.

By the way, no one need bring up the "but that would make 
Euphoria slower" argument. I have already benchmarked Euphoria and Lua on 
output, and Lua wins handily.

Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu