Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Languages Misc > Re: ANN: Seed7 ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 14 of 18 Topic 1135 of 1217
Post > Topic >>

Re: ANN: Seed7 Release 2008-04-20

by Mensanator <mensanator@[EMAIL PROTECTED] > Apr 28, 2008 at 02:15 PM

On Apr 28, 3:19=A0am, thomas.mer...@[EMAIL PROTECTED]
 wrote:
> On 28 Apr., 01:30, Mensanator <mensana...@[EMAIL PROTECTED]
> wrote:
>
> > I couldn't find anywhere in the manual how to stop the program.
>
> > Is there an equivalent to C's exit(0)?
>
> There is the function:
> =A0 exit (PROGRAM)
>
> where 'PROGRAM' is used as keyword. Currently I have no possibility
> to provide a return value for exit. I will look at that. Probably
> the best solution is to provide an 'exit' function with an integer
> parameter just as C has.

Oh, I don't need the parameter, just the way out. And it worked fine,
just what I needed (to abort if user doesn't supply all the required
command line parameters). I searched for "exit" in the manual and
didn't
find it. If this isn't in the manual, it should be.

>
> > Also, am I reading this correctly?
>
> > =A0A[1] =3D> First element,
>
> > You have arrays index from 1?
>
> This is the default. But the lowest allowed index of an array is
> just as dynamic as the highest allowed index is. If you define an
> array with:
>
> =A0 var array integer: arr is 0 times 0;
>
> The starting index is 1. If you assign a new value to this array
> with
>
> =A0 arr :=3D [0] (1, 2, 3);
>
> it gets a new starting index, a new size and new values for arr[0],
> arr[1] and arr[2]. Now a statement as
>
> =A0 writeln(arr[0]);
>
> writes 1. There is no limitation what value can be used as the
> first index for an array. You can define the following array:
>
> =A0 var array integer: arr2 is [-2] (3, 4, 5, 6);
>
> Now 'writeln(arr2[-1]);' writes 4.
> To solve your problem you need to replace
>
> =A0 cycle_stats :=3D number times cycle.value;
>
> with
>
> =A0 cycle_stats :=3D [0 .. number] times cycle.value;
>
> to allow idices in the range 0 to number. If you want a C like
> behavior where the array has number elements counting from
> 0 to number -1 use:
>
> =A0 cycle_stats :=3D [0 .. pred(number)] times cycle.value;
>
> If you add elements to the array with:
>
> =A0 cycle_stats &:=3D 1000 times cycle.value;
>
> the lowest array index (0 in this case) stays unchanged.
> I hope that this helps.

Oh, ok. I take back what I said about Seed7 being worthless.

>
> It seems that I need to add something to the manual and the FAQ.

Yes, you should. Otherwise you risk pissing off potential users
who have to manipulate their array pointers because you didn't
do***ent that it's a default and can be changed.

>
> BTW.: Seed7 does also sup****t not integer indices. You can also
> define arrays with use 'char', 'boolean' or some enumeration type
> as index.
>
> > That's insane.
>
> > Why would you do such a silly thing?
>
> To explain why I use 1 as default start index for arrays I provide
> a little list:
>
> =A0 - apple
> =A0 - cherry
> =A0 - lemon
> =A0 - strawberry
> =A0 - pear
> =A0 - orange
>
> Most people agree that the third line from below is 'strawberry'.

But then, most people aren't programmers. Who's your target audience
for Seed7?

> In normal life nobody would say that the second line from the top is
> 'lemon'. So Seed7 uses 'common sense' as guideline instead of
> 'computer science wisdom'.

Suppose I'm doing math in radix 666 and have an array representing
the digit positions:

'123'
'444'
'23'

To evaluate this, I would do 23*666**2 + 444*666**1 + 123*666**0.

So the array must index from 0.

You'll get a lot further using 'computer science wisdom' than with
'common sense'. I always ask people:

"Do you want the Truth or something you can understand?"

Ignorance is only skin deep, but stupid goes to the bone.

>
> > How much time do you waste translating this to C?
>
> You are probably speaking of runtime overhead.
> There is some overhead. For every array access an additional
> subtraction is necessary. But Seed7 checks also that
> index >=3D upper_bound and index <=3D lower_bound which is probably
> more expensive than a subtraction.

Ok, it least it crashes gracefully instead of getting a segment fault.

>
> > Haven't you ever used modular arithmetic with indices,
> > where 0 is a legal value?
>
> > This is serious enough not to recommend Seed7 for
> > "real" programming.
>
> Sorry that you had troubles with the arrays. Mea culpa. I should
> improve the chapter about arrays in the manual. I hope that
>
> =A0 cycle_stats :=3D [0 .. number] times cycle.value;
>
> solves your problem. If you still have problems or have more
> questions, just ask.

Well, it was easy enough to work around, so I'll leave it as is.

Oh, and I think I got the Sedgewick algorithm working now in Seed7.

If it p***** my testing, I'll post it on my web-site tonight
in case you want a peek before I have the web page that will
highlight the Seed7 versions of the Brent & Sedgewick algorithms.

>
> Greetings Thomas Mertes
>
> Seed7 Homepage: =A0http://seed7.sourceforge.net
> Seed7 - The extensible programming language: User defined statements
> and operators, abstract data types, templates without special
> syntax, OO with interfaces and multiple dispatch, statically typed,
> interpreted or compiled, ****table, runs under linux/unix/windows.
 




 18 Posts in Topic:
ANN: Seed7 Release 2008-04-20
thomas.mertes@[EMAIL PROT  2008-04-20 13:51:24 
Re: ANN: Seed7 Release 2008-04-20
Mensanator <mensanator  2008-04-21 21:26:26 
Re: ANN: Seed7 Release 2008-04-20
thomas.mertes@[EMAIL PROT  2008-04-21 23:46:18 
Re: ANN: Seed7 Release 2008-04-20
Mensanator <mensanator  2008-04-22 10:09:21 
Re: ANN: Seed7 Release 2008-04-20
thomas.mertes@[EMAIL PROT  2008-04-24 23:30:21 
Re: ANN: Seed7 Release 2008-04-20
Mensanator <mensanator  2008-04-25 00:46:36 
Re: ANN: Seed7 Release 2008-04-20
Mensanator <mensanator  2008-04-25 00:53:31 
Re: ANN: Seed7 Release 2008-04-20
thomas.mertes@[EMAIL PROT  2008-04-25 05:01:18 
Re: ANN: Seed7 Release 2008-04-20
Mensanator <mensanator  2008-04-25 10:30:31 
Re: ANN: Seed7 Release 2008-04-20
thomas.mertes@[EMAIL PROT  2008-04-27 06:58:56 
Re: ANN: Seed7 Release 2008-04-20
Mensanator <mensanator  2008-04-27 12:05:47 
Re: ANN: Seed7 Release 2008-04-20
Mensanator <mensanator  2008-04-27 16:30:41 
Re: ANN: Seed7 Release 2008-04-20
thomas.mertes@[EMAIL PROT  2008-04-28 01:19:50 
Re: ANN: Seed7 Release 2008-04-20
Mensanator <mensanator  2008-04-28 14:15:23 
Re: ANN: Seed7 Release 2008-04-20
Mensanator <mensanator  2008-05-03 00:43:47 
Re: ANN: Seed7 Release 2008-04-20
thomas.mertes@[EMAIL PROT  2008-05-07 00:48:44 
Re: ANN: Seed7 Release 2008-04-20
thomas.mertes@[EMAIL PROT  2008-05-07 01:24:46 
Re: ANN: Seed7 Release 2008-04-20
Mensanator <mensanator  2008-05-07 10:46:17 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 5:29:45 CDT 2008.