Re: Eu's poor design

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

On Sun, Aug 17, 2003 at 08:19:29PM +0000, Andreas Rumpf wrote:
> 
> 
> jbrown105 at speedymail.org wrote:
> > 
> > 
> > On Sun, Aug 17, 2003 at 07:41:01PM +0000, Andreas Rumpf wrote:
> > > 
> > > 
> > > > (making a stack in Eu is easy)
> > > Let's see the stack in Eu:
> > > 
> > > sequence stack
> > > stack = {}
> > > 
> > > function push(sequence stack, object item)
> > >   return stack = append(stack, item)
> > 
> > this is wrong, btw. should be:
> > 
> > stack = append(stack, item)
> > return stack
> Yes, as I said I should stop coding in topica windows.

LOL.

> > 
> > > end function
> > > 
> > > function pop(sequence stack) -- returns stack without top
> > 
> > No, the pop removes the top of the stack, and then returns the part it
> > removed.
> Not necessarily.

> > 
> > >   return stack[1..length(stack)-1]
> > > end function
> > > 
> > > function topOfStack(sequence stack)
> > >   return stack[length(stack)]
> > > end function
> > > 
> > > Yes, quite easy. But what if I want to make it easier and more 
> > > efficient? (Using push()/pop() that modify the stack directly!) Guess 
> > > what, it can't be done in Eu.
> > 
> > Wrong.
> > 
> > sequence stack
> > stack = {}
> > 
> > procedure push(object item)
> > 	stack = append(stack, item)
> > end procedure
> > function pop()
> > 	object item
> > 	item = stack[length(stack)]
> > 	stack = stack[1..length(stack)-1]
> > 	return item
> > end function	
> > 
> > or with your version of pop() and topOfStack() (which is wrong btw)
> > 
> > function pop()
> > 	return stack[1..length(stack)-1]
> > end function
> > function topOfStack()
> > 	return stack[length(stack)]
> > end function
> 
> So, you used a global variable... (And proved one of my earlier 
> posts...) What if I want to have 2 different stacks? - Use a sequence of 
> stacks and pass the routines the index of the stack to work with. This 
> is a solution. But it simulates pbr! So why not have it directly?

Ask Rob why not to have PBR directly. But the point: if you really need
pbr in Eu, you can simulate it. (You can even make a library and have
set_ptr() and get_ptr() to make it look nice if you want.)

Hence, lack of PBR might hurt the beauty of the code. But it doesnt make it
harder to use Euphoria!

> 
> > > Again, in Pascal/C/etc. I have choice how to implement certain things!
> > > You can't even write a swap() routine, because of lack of pbr!
> > 
> > Well C has no pbr. It has simulated pbr via pointers.
> Ok, forget about C. What about Basic/Ada/C++?

<sidebar>
Did the original version of BASIC have pbr?
I wonder if anyone even has a copy of the original BASIC heh.
</sidebar>

I should point out that a variable_id() would give Eu pointers, which in
turn would let us simulate pbr far better than a sequence.

> > 
> > Yes, the inability to have a swap() routine is annoying. Very much so.
> > Of course this could also be solved via macros ...
> > 
> > object tmp
> > macro swap(a,b) tmp = a a = b b = tmp
> > ...
> > swap(var_one, var_two)
> > 
> > but only because the macro is rewritten as
> > 
> > tmp = var_one var_one = var_two var_two = tmp
> > 
> > so even the macro simulates pass-by-reference!
> Let's implement a macro facility instead of pbr! (Irony)

Seriously, I think we need macros. We really do.

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     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu