Tech Support > Computers & Technology > Programming > Seed7 Release 2007-03-05
Seed7 Release 2007-03-05
Posted by thomas.mertes@gmx.at on March 5th, 2007


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

Posted by Kevin André on March 7th, 2007


thomas.mertes@gmx.at wrote:

(...)

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é


Posted by Alf P. Steinbach on March 7th, 2007


* Kevin André:
If you apply that rigorously then any power of zero is undefined. 0^n =
(0^(n+1))/0 = oops. So this relationship doesn't hold for powers of 0.

And there's another fault in the logic above.

Namely the assumption that usual mathematical relationships hold for
computer arithmetic, in general. No, they don't, in general.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Posted by Arthur J. O'Dwyer on March 7th, 2007



On Wed, 7 Mar 2007, Alf P. Steinbach wrote:
True, true; but still 0**0 is undefined, and therefore the Right Thing
to do if it's ever evaluated is to throw an exception or make the result
undefined (either in the "undefined behavior" sense, or simply by making
it a floating-point NaN, "undef" atom, or whatever).

If you're talking about the equivalent of 'unsigned int's in C, then
really you shouldn't even be providing an exponentiation operator in
the first place; it'll just confuse people who expect normal math.
("What d'you mean 10**9 is 51712?!") If you're talking about bignums,
you should expend the extra bit to represent "not a number"; except for
/really/ high-performance systems, it'll be RAM well spent.

my $.02,
-Arthur

Posted by Ben Pfaff on March 7th, 2007


"Arthur J. O'Dwyer" <ajonospam@andrew.cmu.edu> writes:

I don't know whether you're familiar with the sci.math FAQ on
this, so I'll point to it:
http://www.faqs.org/faqs/sci-math-fa...lnumbers/0to0/
--
Ben Pfaff
blp@cs.stanford.edu
http://benpfaff.org

Posted by Dave Vandervies on March 8th, 2007


In article <4UuHh.45844$lu3.399467@phobos.telenet-ops.be>,
Kevin =?ISO-8859-1?Q?Andr=E9?= <kevin.andre.dont.like@spam.telenet.be> wrote:
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 dj3vande@csclub.uwaterloo.ca
it in this particular case. --Mark McIntyre and Richard Heathfield in CLC

Posted by thomas.mertes@gmx.at on March 8th, 2007


On 7 Mrz., 19:04, "Arthur J. O'Dwyer" <ajonos...@andrew.cmu.edu>
wrote:
At wikipedia there is information about that topic:
http://en.wikipedia.org/wiki/Exponen...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 raises NUMERIC_ERROR
for 0 ** 0 :

const type: myInt is subtype integer;

const func myInt: (in myInt: base) ** (in myInt: exp) is func
result
var myInt: result is 0;
begin
if base = 0 and exp = 0 then
raise NUMERIC_ERROR;
else
result := base ** exp;
end if;
end func;

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;

Well - Seed7 integers are at least 32 bit signed.
Therefore 10 ** 9 gives 1000000000 .

IMHO integers and bigIntegers should not have NaN, NULL or
anything like that. They should just raise an exception for
expressions like 'n div 0' and '0 div 0'.

Greetings Thomas Mertes

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


Posted by Kevin André on March 9th, 2007


thomas.mertes@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é


Posted by thomas.mertes@gmx.at on March 9th, 2007


On 9 Mrz., 09:46, Kevin André <kevin.andre.dont.l...@spam.telenet.be>
wrote:
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


Posted by CBFalconer on March 9th, 2007


thomas.mertes@gmx.at wrote:
Now (IMO) this is a valid argument for the definition. As long as
the user is clear that it is a definition of convenience.

--
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



Similar Posts