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.
Is that overridable or is the a const modifier ?
Aaron
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.
Sorry what I ment to type was :-
Is that overridable or is there a const modifier ?
Aaron
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.
[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
Yes, thanks,
Aaron
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?
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
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...
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...
> 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
>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.
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...
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.
> 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>
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...