Re: Eu's poor design(Irv)

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

On Sun, Aug 17, 2003 at 11:19:29AM -0700, eugtk at yahoo.com wrote:
> 
> 
> --- jbrown105 at speedymail.org wrote:
> 
> > > In most "high level" languages, after you define a
> > > variable 
> > > as a certain type, you can just "print" that
> > variable
> > > without concern about the type. Not with Eu. You, 
> > > the programmer, have to choose the correct print
> > > function from a number of supplied functions
> > > to properly display each type of variable. This is
> > a
> > > job 
> > > for the computer language, not the programmer. 
> > > For examples, see almost any language other than 
> > > asm or C. 
> > 
> > You can do that in Eu.
> > 
> > print(1, x)
> > 
> > or even
> > 
> > ? x
> 
> Well, not exactly.
> Given the following:
>  integer x
>  atom y
>  sequence z
> 
> x = 23
> y = 3.1415
> z = "Hello"
> 
> Many languages will allow you to something like:
> print(x,y,z) 
> and it will come out looking like you would expect. 
> 

Yes that is true. Of course its pretty easy to write a user-defined
routine to fix this, see below.

> But in Eu, not only can't you print several variables 
> with one command, but you also must choose different 
> print commands for each, if you want them to look like
> what you are expecting:
> 
> print(1,z) -- {72,101,108,108,111} (not much of a
> greeting, is it?
> 
> ? z -- {72,101,108,108,111} (no improvement)
> 
> puts(1,x) -- ^W  (short for WTF?)
> 
> ok, I'll try print(1,x,y,z) -- nope, print takes only
> 2 args.
> 
> How about print(1,{x,y,z})
> {23,3.1415,{72,101,108,108,111}}
> Halfway there.
> 
> Maybe print(1,x & y & z)
> {23,3.1415,72,101,108,108,111}
> An array of 7 numbers?
> 
> Now I'm really confused, and I still don't see the 
> stuff I put in there!
> 

The answer, would be something like:

global procedure pprint(sequence variable_arguments)
	for i = 1 to length(variable_arguements) do
		? variable_arguements[i]
	end for
end procedure

pprint({x, y, z}) --use a sequence to simulate variable arguments.

> Of course, after a bit of experience, you learn that 
> you should write:
> print(1,x) print(1,y) puts(1,z)
> or
> printf(1,"%d %f %s",{x,y,z})
> 
> See how this would confuse a beginner?
> Doesn't this make debugging harder if you 
> don't know what type the data you're looking at is 
> "supposed" to be? Or if you do know, but the data 
> turns out to be something else. 

If you use '?' or even pprint() universally, then the only confusion would be
with strings.

> 
> As you say, this is because Eu doesn't really have a 
> string type.  
> 
> But "Hello" looks very much like a string, doesn't it?
> Eu didn't fuss about that assignment, so it must be
> ok,
> and most people who have written even one ("Hello
> World") program in any language other than machine
> code naturally expect a programming language to know
> about strings.

Yes, that is a problem. One solution is to print out everything that looks
like a string as a string, but that doesnt work because you still don't KNOW
its a string.

Unlike atoms and integers, Euphoria doesnt know if a sequence is a sequence or
a string. Hence there is no builtin way for you to tell either.

> 
> As I said, Euphoria is pretty good - mostly because of
> its  clean, clear syntax (borrowed from Pascal, it
> appears) but in many ways it could certainly be
> better. 
> What would it take, 1 extra byte to identify a string
> as a string so Eu could handle strings gracefully?

Hmm, yes a very good point.

> 
> Irv
> 

jbrown

> 
> 
> TOPICA - Start your own email discussion group. FREE!
> 
> 

-- 
 /"\  ASCII ribbon              | http://www.geocities.com/jbrown1050/
 \ /  campain against           | Linux User:190064
  X   HTML in e-mail and        | Linux Machine:84163
 /*\  news, and unneeded MIME   | http://verify.stanford.edu/evote.html

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

Search



Quick Links

User menu

Not signed in.

Misc Menu