why is this legal?

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

why is this legal?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:16 pm

by CarlRanson >> Tue, 19 Nov 2002 3:13:49 GMT

Hi all,
Can anyone tell me a valid reason that the following works in Jade???

JadeScript.aaa1(s : String input);begin

s[1] := 'A';
end;

JadeScript.aaa2();
vars
s : String;begin

s := 'abc';
aaa1(s);
write s; // produces Abc ????
end;

I would have thought that s[1] := 'A'; would be considered an update of the input parameter s and therefore should not be allowed.

Arent Input and Constant primitive parameters functionally the same in Jade???

CR

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: why is this legal?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:16 pm

by allistar >> Tue, 19 Nov 2002 3:46:36 GMT

Here is what the help says for primitive parameters:

input: Cannot be updated by assignment, but can be updated within a primitive type method using the self system variable.

So what that means is that doing s := "Abc" would be illegal as you
are doing an assignment. Doing s[1] := 'A' is not technically doing an assignment and is the equivelant of a primitive method on String that does this:

setChar(pos: Integer; char: Character) updating;begin

self[pos] := char;
endif;

Which according to the help is a valid thing to do to an input
parameter (updating it within a primitive type method using the self system variable).

Regards,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer
Auckland, NEW ZEALAND

Greentree International,
Developer of Greentree Financial Software. ------------------------------------------------------------------


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 26 guests

cron