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: Seed7 Relea...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 18 Topic 1109 of 1217
Post > Topic >>

Re: Seed7 Release 2008-02-17

by thomas.mertes@[EMAIL PROTECTED] Feb 18, 2008 at 10:43 AM

On 18 Feb., 17:42, "Aaron Gray" <ang.use...@[EMAIL PROTECTED]
> wrote:
> "Aaron Gray" <ang.use...@[EMAIL PROTECTED]
> wrote in message
>
> news:61t25sF2003j0U1@[EMAIL PROTECTED]
>
> >> - 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 ?

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.

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.
 




 18 Posts in Topic:
ANN: Seed7 Release 2008-02-17
thomas.mertes@[EMAIL PROT  2008-02-17 14:13:00 
Re: Seed7 Release 2008-02-17
"Aaron Gray" &l  2008-02-18 09:41:13 
Re: Seed7 Release 2008-02-17
"Aaron Gray" &l  2008-02-18 16:42:21 
Re: Seed7 Release 2008-02-17
thomas.mertes@[EMAIL PROT  2008-02-18 06:09:03 
Re: Seed7 Release 2008-02-17
thomas.mertes@[EMAIL PROT  2008-02-18 10:43:00 
Re: Seed7 Release 2008-02-17
"Aaron Gray" &l  2008-02-18 23:19:32 
Re: ANN: Seed7 Release 2008-02-17
Bart <bc@[EMAIL PROTEC  2008-02-18 13:02:28 
Re: ANN: Seed7 Release 2008-02-17
thomas.mertes@[EMAIL PROT  2008-02-19 13:51:04 
Re: ANN: Seed7 Release 2008-02-17
"Bartc" <bc@  2008-02-19 23:43:10 
Re: ANN: Seed7 Release 2008-02-17
"Captain Tony Valare  2008-03-26 17:39:27 
Re: ANN: Seed7 Release 2008-02-17
"Captain Tony Valare  2008-03-26 19:57:13 
Re: ANN: Seed7 Release 2008-02-17
Richard Heathfield <rj  2008-03-27 06:41:43 
Re: ANN: Seed7 Release 2008-02-17
cri@[EMAIL PROTECTED] (R  2008-03-27 08:04:53 
Re: ANN: Seed7 Release 2008-02-17
"Captain Tony Valare  2008-03-27 14:37:00 
Re: ANN: Seed7 Release 2008-02-17
Richard Heathfield <rj  2008-03-27 19:57:35 
Re: ANN: Seed7 Release 2008-02-17
"Captain Tony Valare  2008-03-27 16:04:09 
Re: ANN: Seed7 Release 2008-02-17
Richard Heathfield <rj  2008-03-27 21:36:52 
Re: ANN: Seed7 Release 2008-02-17
"Captain Tony Valare  2008-03-27 19:09:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Fri Jul 25 18:05:54 CDT 2008.