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

ANN: Seed7 Release 2008-02-17

7 views
Skip to first unread message

thomas...@gmx.at

unread,
Feb 17, 2008, 5:13:00 PM2/17/08
to
Hello,

I have released a new version of Seed7: seed7_05_20080217.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:
- A new chapter about object orientation was added to the manual
(Many thanks for the feedback to Leonardo Cecchi, Malcolm McLean
and Reinder Verlinde).
- The manual was changed to mention that the 'in' parameter of arrays
and structs is a reference ('ref') parameter.
- The faq was improved to contain a paragraph about static type
checking.
- The implementation type NULL_FILE was renamed to null_file.
- The struct copy of the compiler (comp.sd7) was changed to leave the
dynamic type unchanged.
- The following primitive actions were added or improved in the
compiler (comp.sd7): FIL_ERR, FIL_IN, FIL_OUT, FLT_GROW, FLT_MCPY,
HSH_INCL, HSH_LNG, INT_PLUS, PRG_EXEC, PRG_STR_ANALYZE, SCR_CURSOR
and STR_GETENV.
- The primitive action CLS_CREATE2 was changed to call the
CLEAR_TEMP_FLAG macro (This is a fix for a bug found by
Leonardo Cecchi).
- The function match_subexpr_type was changed to allow normal (not
DYNAMIC) interface functions to be used for implementation values.
- The primitive action PRC_GETENV was renamed to STR_GETENV.
- The bas7.sd7 (basic interpreter) example program was improved.
- A bug in the primitive action RFL_NOT_ELEM was fixed.
- The functions copy_list, array_to_list and struct_to_list were
change to return thecreated list.

Greetings Thomas Mertes

Seed7 Homepage: http://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.

Message has been deleted

Aaron Gray

unread,
Feb 18, 2008, 4:41:13 AM2/18/08
to
> - The manual was changed to mention that the 'in' parameter of arrays
> and structs is a reference ('ref') parameter.

Is that overridable or is the a const modifier ?

Aaron


thomas...@gmx.at

unread,
Feb 18, 2008, 9:09:03 AM2/18/08
to

I am not sure what you ask for, therefore I provide some
information in the hope that it answers your question:

- A 'ref' parameter is a reference parameter where the formal
parameter is constant.
- A 'val' parameter is a value parameter where the formal
parameter is constant.
- An 'in' parameter is either a 'ref' or a 'val' parameter.
This decision is bound to the type.

For 'in', 'ref' and 'val' parameters you do not need a const
modifier since the formal parameters are already constant.

You are always allowed to use 'ref' and 'val' parameters to
specify that the parameter should be by reference or by value,
but normally the 'in' parameter should be preferred.

You can declare a subtype of an array type and specify that
the 'in' parameters should be by value (but the direct use of
'val' parameters make it more explicit).

If you want a variable reference parameter which allows you
to change the formal (and actual) parameter you should use an
'inout' parameter:

- An 'inout' parameter is a reference parameter where the
formal parameter is variable (value changes are allowed and
effect the actual parameter). For 'inout' parameters the
actual parameter is also requested to be variable.

If you want a variable value parameter which allows you to
change the formal parameter (local value) you should use an
'in var' parameter:

- An 'in var' parameter is a value parameter where the
formal parameter is variable.

If you still have questions, just ask.

Aaron Gray

unread,
Feb 18, 2008, 11:42:21 AM2/18/08
to
"Aaron Gray" <ang.u...@gmail.com> wrote in message
news:61t25sF...@mid.individual.net...

>> - The manual was changed to mention that the 'in' parameter of arrays
>> and structs is a reference ('ref') parameter.
>
> Is that overridable or is the a const modifier ?

Sorry what I ment to type was :-

Is that overridable or is there a const modifier ?

Aaron


thomas...@gmx.at

unread,
Feb 18, 2008, 1:43:00 PM2/18/08
to
On 18 Feb., 17:42, "Aaron Gray" <ang.use...@gmail.com> wrote:
> "Aaron Gray" <ang.use...@gmail.com> wrote in message

It is overridable by using 'val' of 'ref' parameters.
Instead of:

const func integer: test1 (in array string: anArray) is
return length(anArray);

it is possible to write:

const func integer: test2 (ref array string: anArray) is
return length(anArray);

which is normally equivalent to the test1 example.
If you want a value parameter for an array you can write:

const func integer: test3 (val array string: anArray) is
return length(anArray);

I know that it is stupid to copy an array just to return it's
length, but it is possible. There is also a possibility to
override the meaning of an 'in' parameter by declaring a
subtype as in the following example program:

$ include "seed7_05.s7i";

const type: myArray is subtype array string;

IN_PARAM_IS_VALUE(myArray);

const func integer: test4 (val myArray: anArray) is
return length(anArray);

const proc: main is func
local
var myArray: anArray is 100 times "x";
begin
writeln(test3(anArray));
end func;

That 'in' parameters for arrays are by reference ('ref') is
defined in the "seed7_05.s7i" library.
Since most of Seed7 is defined in "seed7_05.s7i" the
meaning of 'in' parameters and many other things can be
changed there, but in most cases this is not desirable.

To answer the second part of your question:

is there a const modifier ?

is easier. The formal 'in', 'val' and 'ref' parameters are
already const. Therefore a const modifier is not needed.

For variable parameters see my previous mail about 'inout'
and 'in var' parameters.

I hope this answers your question.

Bart

unread,
Feb 18, 2008, 4:02:28 PM2/18/08
to
On Feb 17, 10:13 pm, thomas.mer...@gmx.at wrote:


[From Seed 7 FAQ]
>Variables with object types contain references to object values....
> a := b

>For primitive types a different logic is used...
> a := b
>both variables are still distinct and changing one variable has no effect on the other.

This is more of a general question about a:=b for a class object being
different from a:=b for an ordinary object. It seems to be the case in
several oo languages.

Why?

OK, objects are implemented by reference and all that, and maybe this
saves some copying, but that should all be transparent.

Surely the meaning of something as basic as a:=b should not depend on
something as arbitrary as whether a and b have datatypes T or U. If
someone changes their mind then a lot of recoding might be needed!

--
Bart

Aaron Gray

unread,
Feb 18, 2008, 6:19:32 PM2/18/08
to
> I hope this answers your question.

Yes, thanks,

Aaron


thomas...@gmx.at

unread,
Feb 19, 2008, 4:51:04 PM2/19/08
to
On 18 Feb., 22:02, Bart <b...@freeuk.com> wrote:
> On Feb 17, 10:13 pm, thomas.mer...@gmx.at wrote:
>
> [From Seed 7 FAQ]
>
> >Variables with object types contain references to object values....
> > a := b
> >For primitive types a different logic is used...
> > a := b
> >both variables are still distinct and changing one variable has no effect on the other.
>
> This is more of a general question about a:=b for a class object being
> different from a:=b for an ordinary object. It seems to be the case in
> several oo languages.
>
> Why?
IMHO it is a cornerstone of classic OO programming languages
like Smalltalk and its descendants: Object variables and
parameters contain just pointers to the actual object value
which is at the heap. It is almost not mentioned by OO
proponents but in classic OO programming not everything is
done with methods. Assignments are always done as pointer
assignments, independend of the object class. Also comparisons
are done as pointer comparisons. Therefore a 'clone' method
to do deep copies and an 'compare' method to do logical
comparisons is necessary.

The advantage of this OO pointer philosophy is that container
classes are easier to implement (they store just pointers in
the container).

> OK, objects are implemented by reference and all that, and maybe this
> saves some copying, but that should all be transparent.
>
> Surely the meaning of something as basic as a:=b should not depend on
> something as arbitrary as whether a and b have datatypes T or U. If
> someone changes their mind then a lot of recoding might be needed!

Most OO programmers have the different assignment logic for
object variables in their mind. They would be confused when
those assignments would work as deep copies (As Seed7 does
for all other types).

IIRC Simula had two different assignment operators:
:= For value copy assignments
:- For reference assignments

Seed7 is an extensible programming language.
It would be possible to define the assignment to do a (deep)
copy of the implementation (object) value and to have
a different operator to do reference assignment.

I don't belive that OO fan's would be happy without
reference assignment?

What do you think?

Bartc

unread,
Feb 19, 2008, 6:43:10 PM2/19/08
to

I think it's a bit late to change things now.

I suppose I just have to think about objects as pointers instead, with
whatever they're pointing to being automatically managed:

ptrA := ptrB ( programming equivalent of training wheels :-)

--
Bart

Captain Tony Valare

unread,
Mar 26, 2008, 7:39:27 PM3/26/08
to
As t may be applied to a recursion,

ptrA := ptrB

is possibly the only way to fly. I have been reading on the topic of data
structures, and one author who i located in the group being sold at
powells.com. Any comment on this book note written by his publisher?

While many computer science textbooks are confined to teaching programming
code and languages, Algorithms and Data Structures: The Science of Computing
takes a step back to introduce and explore algorithms - the content of the
code. Focusing on three core topics: design (the architecture of
algorithms), theory (mathematical modeling and analysis), and the scientific
method (experimental confirmation of theoretical results), the book helps
students see that computer science is about problem solving, not simply the
memorization and recitation of languages. Unlike many other texts, the
methods of inquiry are explained in an integrated manner so students can see
explicitly how they interact. Recursion and object oriented programming are
emphasized as the main control structure and abstraction mechanism,
respectively, in algorithm design. Designed for the CS2 course, the book
includes text exercises and has laboratory exercises at the supplemental Web
site.

Saturday's 6 $million Dubai World Cup race features Curlin. He ran a good
one on the track last month. Now he's back for all the marble. coverage in
today's Handicapper's edge at
http://www.tsnhorse.com/cgi-bin/editorial/full_edition.cgi

GL at the races


"Bartc" <b...@freeuk.com> wrote in message
news:iQJuj.10236$XI....@text.news.virginmedia.com...

Captain Tony Valare

unread,
Mar 26, 2008, 9:57:13 PM3/26/08
to
With recursion being a main control structure, as the author suggests,
somewhere I missed the boat. I've never used recursion except once in a
prime number analysis algorithm from a programming book. It said that epime
numbers were a combination of prime factors (which makes sense), so to find
the primes the algorithm factor all the factors, so it used the same few
steps and substituted the last prime factors by calling the function
recursively. I might see how this is practical in two dimensional arrays
i.e., linear optimization algorithms.. It would seem good to process the
bit maps that draw the screen.

Those seem to be structures which fit the use of a recussive algorithm. The
data structure is supposed to meet the requirement of the programming
problem to be solved. so anybody know any prime numbers for analyzing. I
gotr just the control structure for that!

"Bartc" <b...@freeuk.com> wrote in message
news:iQJuj.10236$XI....@text.news.virginmedia.com...

Richard Heathfield

unread,
Mar 27, 2008, 2:41:43 AM3/27/08
to
Captain Tony Valare said:

> With recursion being a main control structure, as the author suggests,
> somewhere I missed the boat. I've never used recursion except once in a
> prime number analysis algorithm from a programming book. It said that
> epime numbers were a combination of prime factors (which makes sense),

No, it makes no sense at all. Primes /are/ prime factors. They are not
combinations of anything. That is practically the definition of primes!

Exercise: here are the first ten primes: 2, 3, 5, 7, 11, 13, 17, 19, 23,
29. List their prime factors.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

Richard Harter

unread,
Mar 27, 2008, 4:04:53 AM3/27/08
to
On Thu, 27 Mar 2008 06:41:43 +0000, Richard Heathfield
<r...@see.sig.invalid> wrote:

>Captain Tony Valare said:
>
>> With recursion being a main control structure, as the author suggests,
>> somewhere I missed the boat. I've never used recursion except once in a
>> prime number analysis algorithm from a programming book. It said that
>> epime numbers were a combination of prime factors (which makes sense),
>
>No, it makes no sense at all. Primes /are/ prime factors. They are not
>combinations of anything. That is practically the definition of primes!
>
>Exercise: here are the first ten primes: 2, 3, 5, 7, 11, 13, 17, 19, 23,
>29. List their prime factors.

Well, it may or may not make sense. It rather depends upon what
an epime number might be and what kind of combining is being
done.


Richard Harter, c...@tiac.net
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.

Captain Tony Valare

unread,
Mar 27, 2008, 4:37:00 PM3/27/08
to
I spent a 1/2 hour to find a line by Stephen Kochan of Bell Labs ,
Programming in C 1988 Hayden Books, "One method for generating prime numbers
involves an approach which uses the notion that a number is prime if it is
not evenly divisible by any other prime number. This stems from the fact
that any non-prime integer can be expressed as a multiple of prime factors.
(For example 20, has the prime factors 2, 2, and 5). The program algorithm
can test if a given integer is a prime by determining if it is evenly
divisible by any other previously generated prime. The term used
"previously generated" suggests that a recursive function is useful.

As a further optimization of the prime number generator program, it can be
demonstrated that any non-prime integer n, must have as one of its factors
an integer that is less then or equal to the square root of n.

So it is only necessary to determine if a given integer is prime by testing
it for even divisibility against all prime factors up to the square root of
the integer.
(but all those are infested by prime factors). So those primes can be
generated by using prime factors. It was not quite as straight forward as
you all believed. I ultimately could show what coincidence there was
between prime factors of the eventually generated primes. (what a nail
biter that was)>


"Richard Heathfield" <r...@see.sig.invalid> wrote in message
news:3tadnbYxX94...@bt.com...

Richard Heathfield

unread,
Mar 27, 2008, 3:57:35 PM3/27/08
to
[Top-posting fixed]

Captain Tony Valare said:
> "Richard Heathfield" <r...@see.sig.invalid> wrote in message
> news:3tadnbYxX94...@bt.com...
>> Captain Tony Valare said:
>>
>> > With recursion being a main control structure, as the author
>> > suggests, somewhere I missed the boat. I've never used
>> > recursion except once in a prime number analysis algorithm
>> > from a programming book. It said that epime numbers were a
>> > combination of prime factors (which makes sense),
>>
>> No, it makes no sense at all. Primes /are/ prime factors. They are not
>> combinations of anything. That is practically the definition of primes!
>>

<snip>



> So it is only necessary to determine if a given integer is prime by
> testing it for even divisibility against all prime factors up to the
> square root of the integer.

Yes, but that doesn't mean that primes are a combination of prime factors
(which is what you actually said in your previous article).

> (but all those are infested by prime factors). So those primes can be
> generated by using prime factors.

Certainly true.

> It was not quite as straight forward as you all believed.

We're not mind readers. I replied to what you wrote, not to what you may
have meant to write.

> I ultimately could show what coincidence there was
> between prime factors of the eventually generated primes. (what a nail
> biter that was)

Yes, it must have been astounding to discover that every single prime had
the same number of prime factors... none whatsoever.

Captain Tony Valare

unread,
Mar 27, 2008, 6:04:09 PM3/27/08
to
Something that is related to the base number system makes all numbers prime
in base 2. since there are just 2 numbers, then all there are is the number
itself, or the number to the zero power. Any number to the zero power = 1.
Now to bring that idea forward, you could have a set of numbers which had
that property, but use a different base number system. Say base 13. Would
there be any prime numbers, well yes. And those primes would not have prime
factors, but logically they would not be ! (non primes). And in base 13,
all of the non primes can be derived from a set of prime factors. So if the
primes can not be derived from a set of prime factors and the non primes can
be, then the prime number which is the largest factor of all the previous
non primes, is the number we are saying has all of the non primes as
factors. Except that it is prime in this case and it has only itself to the
zero for a factor, and no other prime. In base 2..

Richard Heathfield

unread,
Mar 27, 2008, 5:36:52 PM3/27/08
to
Captain Tony Valare said:

> Something that is related to the base number system makes all numbers
> prime
> in base 2.

The primality or otherwise of members of Z does not depend on the textual
representation you choose.

> since there are just 2 numbers, then all there are is the
> number
> itself, or the number to the zero power.

You appear to be talking about modulus, rather than number bases.

> Any number to the zero power = 1. Now to bring that idea
> forward, you could have a set of numbers which had
> that property, but use a different base number system. Say base 13.
> Would there be any prime numbers, well yes.

Actually, assuming you mean mod 13, no, there wouldn't be any primes. As
Wolfram rightly says, "a prime number is a positive integer having exactly
one positive divisor other than 1", so 0 and 1 aren't prime by definition.
1 * 2 = 2 (mod 13) and 5 * 3 = 2 (mod 13), so 2 isn't prime. 2 * 2 = 4
(mod 13), so 4 isn't prime. 1 * 5 = 5 (mod 13) and 2 * 9 = 5 (mod 13), so
5 isn't prime. 2 * 3 = 6 (mod 13), so 6 isn't prime. 5 * 4 = 7 (mod 13),
so 7 isn't prime - and so on.

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>

Captain Tony Valare

unread,
Mar 27, 2008, 9:09:23 PM3/27/08
to
You got me, since 1 is not a prime number. And I will be quoting you before
you will be quoting me.
Are you at all interested in the Karma of War.. My selection for this
evening would be:

Guns and Butter
http://kpfa.org/archives/index.php?arch=25483

GL (good luck horse racing)

"Richard Heathfield" <r...@see.sig.invalid> wrote in message

news:xfmdnYqJzLocj3Ha...@bt.com...

0 new messages