Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Seed7 Release 2007-03-05

0 views
Skip to first unread message

thomas...@gmx.at

unread,
Mar 5, 2007, 11:54:50 AM3/5/07
to
Hello,

I have released a new version of Seed7: seed7_05_20070305.tgz

In the Seed7 programming language new statements and operators
can be declared easily. Types are first class objects and therefore
templates/generics need no special syntax. Object orientation is
used when it brings advantages and not in places when other
solutions are more obvious.

Seed7 is covered by the GPL (and LGPL for the Seed7 runtime library).

Changelog:
- The support for float was changed to use IEEE 754 NaN and Infinity
instead of exceptions.
- The exception checking program chkexc.sd7 was improved and the
chkflt.sd7 program was added.
- All exponentiation operators were improved to evaluate 0 ** 0 to 1.
- The associativity of the ** operator was changed to work right to
left.
- A declaration for an = and <> operator was added for interface
types.
- Basic support for exceptions in compiled programs was added.
- Parts of the manual describing float operations and exponentiation
were improved.
- The performance of the flt_ipow action was improved.
- The compiler was improved to produce better code for the primitive
actions arr_sort, arr_times, cls_eq, cls_ne, flt_isnan, flt_log10,
int_fact, rfl_append, rfl_cpy, rfl_for, rfl_mklist, rfl_ne, rfl_tail
and
str_str.

Greetings Thomas Mertes

Seed7 Homepage: http://seed7.sourceforge.net
Project page: http://sourceforge.net/projects/seed7

Kevin André

unread,
Mar 7, 2007, 3:40:32 AM3/7/07
to
thomas...@gmx.at wrote:

> I have released a new version of Seed7: seed7_05_20070305.tgz

(...)

> - All exponentiation operators were improved to evaluate 0 ** 0 to
> 1.

That's not correct. 0 ** 0 is undefined. x ** 0 = (x ** 1) / x and you
can't do that when x is zero.


--
Kevin André

thomas...@gmx.at

unread,
Mar 8, 2007, 11:33:34 AM3/8/07
to
On 7 Mrz., 09:40, Kevin André <kevin.andre.dont.l...@spam.telenet.be>
wrote:

In mathematics there is a convention to define x ** 0 as 1.
This comes very handy. For example:
10 ** 2 = 100
10 ** 1 = 10
10 ** 0 = 1
10 ** -1 = 0.1
10 ** -2 = 0.01
This is also used in exponential notation for numbers like
1.7e0 which is short for 1.7 * 10 ** 0 and means just 1.7 .

0 ** 0 is something different.
0 ** x is 0 for x > 0 but 0 ** x is Infinity for x < 0.
0 ** 0 is a point of discontinuity.
At wikipedia there is information about that topic:
http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_zero_power
This wikipedia article states that C, Java, Python,
Ruby, Haskell, ML, Scheme and MATLAB define 0 ** 0 as 1.
My own research showed that Fortran, Ada and C++ also
define 0 ** 0 as 1. Seed7 does now the same as all
these programming languages:
Define A ** 0 to be always 1.

But Seed7 is an extensible programming language.
You can define a subtype which returns NaN for 0.0 ** 0.0:

const type: myFloat is subtype float;

const func myFloat: (in myFloat: base) ** (in myFloat: exp) is func
result
var myFloat: result is 0.0;
begin
if base = 0.0 and exp = 0.0 then
result := NaN;
else
result := base ** exp;
end if;
end func;

Greetings Thomas Mertes

Dave Vandervies

unread,
Mar 8, 2007, 11:56:43 AM3/8/07
to
In article <4UuHh.45844$lu3.3...@phobos.telenet-ops.be>,
Kevin =?ISO-8859-1?Q?Andr=E9?= <kevin.andr...@spam.telenet.be> wrote:
>thomas...@gmx.at wrote:

>> - All exponentiation operators were improved to evaluate 0 ** 0 to
>> 1.
>
>That's not correct. 0 ** 0 is undefined. x ** 0 = (x ** 1) / x and you
>can't do that when x is zero.

If you're going to make corrections, you should at least get them right.

Any mathematician will tell you that 0**0 is defined to be 1 by
convention. This makes a lot of special cases less special (x**0 comes
up a lot more often than 0**x) and also makes x**x as a real-valued
function on the reals continuous at the endpoint at x=0, which tends to
be convenient.


dave

--
Dave Vandervies dj3v...@csclub.uwaterloo.ca
> I have no clue.
Actually, I don't believe that in general. I am, however, prepared to believe
it in this particular case. --Mark McIntyre and Richard Heathfield in CLC

Kevin André

unread,
Mar 9, 2007, 3:46:26 AM3/9/07
to
thomas...@gmx.at wrote:

The article you refer do states that "In many settings, 0 ** 0 is
defined to be 1." But it also says "In other settings, especially
calculus and complex analysis, 0 ** 0 is treated as an indeterminate
form and left undefined."

So you could define 0 ** 0 to be 1, but then you get this:

0 ** 2 = 0
0 ** 1 = 0
0 ** 0 = 1
0 ** -1 = 0
0 ** -2 = 0

It would look better if you would have another zero in that list
instead of the 1, but that wouldn't be 'correct' either. I remember
from the calculus lessons we were told that 0 ** 0 is undefined just
like 0 to the power of plus or minus infinity.


--
Kevin André

thomas...@gmx.at

unread,
Mar 9, 2007, 4:38:15 AM3/9/07
to
On 9 Mrz., 09:46, Kevin André <kevin.andre.dont.l...@spam.telenet.be>

There is just one thing you forgot.
The expression x ** -y is defined as 1 / (x ** y) .
Therefore your table must be:

0 ** 2 = 0
0 ** 1 = 0
0 ** 0 = 1

0 ** -1 = Infinity
0 ** -2 = Infinity

Now the definition of 0 ** 0 as 1 does not stand out any more.
It is a compromise but there are good arguments for doing it
this way. As I mentioned before, other programming languages
like Fortran, C, C++, Ada, Java, Python, Ruby, Haskell, ML,
Scheme and MATLAB took the same approach.

Greetings Thomas Mertes

Seed7 Homepage: http://seed7.sourceforge.net
Project page: http://sourceforge.net/projects/seed7

thomas...@gmx.at

unread,
Mar 9, 2007, 4:42:29 AM3/9/07
to
On 9 Mrz., 09:46, Kevin André <kevin.andre.dont.l...@spam.telenet.be>

> >> (...)

There is just one thing you forgot.


The expression x ** -y is defined as 1 / (x ** y) .
Therefore your table must be:

0 ** 2 = 0


0 ** 1 = 0
0 ** 0 = 1

0 ** -1 = Infinity
0 ** -2 = Infinity

Now the definition of 0 ** 0 as 1 does not stand out any more.
It is a compromise but there are good arguments for doing it
this way. As I mentioned before, other programming languages
like Fortran, C, C++, Ada, Java, Python, Ruby, Haskell, ML,
Scheme and MATLAB took the same approach.

Greetings Thomas Mertes

Seed7 Homepage: http://seed7.sourceforge.net
Project page: http://sourceforge.net/projects/seed7

thomas...@gmx.at

unread,
Mar 9, 2007, 4:52:01 AM3/9/07
to
On 9 Mrz., 10:42, thomas.mer...@gmx.at wrote:
> On 9 Mrz., 09:46, Kevin André <kevin.andre.dont.l...@spam.telenet.be>
> wrote:
...

Sorry for sending my mail two times.

Eric Sosman

unread,
Mar 9, 2007, 8:40:49 AM3/9/07
to
Kevin André wrote:
>
> The article you refer do states that "In many settings, 0 ** 0 is
> defined to be 1." But it also says "In other settings, especially
> calculus and complex analysis, 0 ** 0 is treated as an indeterminate
> form and left undefined." [...]

The history of mathematics has a lot to do with finding
ways to define things that had been undefined. For a long
time the subtraction of ten sheep from a herd of ten was
undefined, and then zero got invented to make it definable.
Subtracting fourteen sheep from ten was undefined until
negative numbers were introduced to make it definable.
Taking the square root of the size of the resulting herd
was undefined until i (aka j) was introduced to make it
definable.

Why all these extensions of definition? Because they
turned out to be useful. It can sometimes be useful to
define 0**0 as 0, sometimes to define it as 1, and sometimes
to leave it well enough alone. Which is best depends more
on the problem at hand than on the thing itself. Are positive
and negative infinity different? Place a circle tangent to the
real line at the origin, map every number to a unique point on
the circle by drawing a line from the number to the "North Pole,"
and answer again. Is this a perverse construction? It gets rid
of an infinite number of infinite discontinuities in the tangent
function, so it can't be all bad ...

When there are multiple sensible ways to define something,
different problems will dictate different definitions.

My 2i cents.

--
Eric Sosman
eso...@acm-dot-org.invalid

Kevin André

unread,
Mar 9, 2007, 9:34:47 AM3/9/07
to
thomas...@gmx.at wrote:

> On 9 Mrz., 09:46, Kevin André
> <kevin.andre.dont.l...@spam.telenet.be> wrote:
>> thomas.mer...@gmx.at wrote:
>> > On 7 Mrz., 09:40, Kevin André
>> > <kevin.andre.dont.l...@spam.telenet.be> wrote:
>> >> thomas.mer...@gmx.at wrote:
>> >> > I have released a new version of Seed7: seed7_05_20070305.tgz
>
>> >> (...)
>
>> >> > - All exponentiation operators were improved to evaluate 0 **
>> >> > 0 to 1.
>
>> >> That's not correct. 0 ** 0 is undefined. x ** 0 = (x ** 1) / x
>> >> and you can't do that when x is zero.
>
>> > In mathematics there is a convention to define x ** 0 as 1.
>> > This comes very handy. For example:
>> > 10 ** 2 = 100
>> > 10 ** 1 = 10
>> > 10 ** 0 = 1
>> > 10 ** -1 = 0.1
>> > 10 ** -2 = 0.01
>> > This is also used in exponential notation for numbers like
>> > 1.7e0 which is short for 1.7 * 10 ** 0 and means just 1.7 .

(...)

>> So you could define 0 ** 0 to be 1, but then you get this:
>
>> 0 ** 2 = 0
>> 0 ** 1 = 0
>> 0 ** 0 = 1
>> 0 ** -1 = 0
>> 0 ** -2 = 0
>
> There is just one thing you forgot.
> The expression x ** -y is defined as 1 / (x ** y) .
> Therefore your table must be:
>
> 0 ** 2 = 0
> 0 ** 1 = 0
> 0 ** 0 = 1
> 0 ** -1 = Infinity
> 0 ** -2 = Infinity
>
> Now the definition of 0 ** 0 as 1 does not stand out any more.

OK. You got me there. I guess I should get a bit more sleep these
days :-)

> It is a compromise but there are good arguments for doing it
> this way. As I mentioned before, other programming languages
> like Fortran, C, C++, Ada, Java, Python, Ruby, Haskell, ML,
> Scheme and MATLAB took the same approach.

I'll remember it for the day I need to implement it in my language :-)
Anyway, I've never really had to use exponentiation in my programs so
I did not know what those languages did. IMHO exponentiation is so
little used in regular programs that I did not provide a ** operator
in my language but decided to provide it as a function in the
standard library.


--
Kevin André

CBFalconer

unread,
Mar 9, 2007, 10:20:04 AM3/9/07
to
Kevin André wrote:
>
... snip ...

>
> So you could define 0 ** 0 to be 1, but then you get this:
>
> 0 ** 2 = 0
> 0 ** 1 = 0
> 0 ** 0 = 1
> 0 ** -1 = 0
> 0 ** -2 = 0

Now you almost have an impulse function. :-)

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

0 new messages