the use of 'out' in a parameter list / situation
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
the use of 'out' in a parameter list / situation
Hi guys,
Can anyone please suggest some X# syntax to show how to use the 'out' option in a parameter list.
I had a quick fumble around but with no good results.
End of day, brain hurts, nee my Forum colleagues ;-0)
Apparently Tuples can happily replace the use of 'OUT'.
HELP !!!
TIA,
Phil.
Can anyone please suggest some X# syntax to show how to use the 'out' option in a parameter list.
I had a quick fumble around but with no good results.
End of day, brain hurts, nee my Forum colleagues ;-0)
Apparently Tuples can happily replace the use of 'OUT'.
HELP !!!
TIA,
Phil.
- lumberjack
- Posts: 727
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
the use of 'out' in a parameter list / situation
Phil,
Is that not REF?
Johan
Is that not REF?
Code: Select all
METHOD SyMethod(in AS STRING, out REF STRING)
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
the use of 'out' in a parameter list / situation
Hi again,
Having had another end of day fumble, I think I have a start, you know, my foot in the door!
Here are a couple of small images :-
I got success once I stopped trying to include 'as'.
Have a nice weekend,
Phil.
Having had another end of day fumble, I think I have a start, you know, my foot in the door!
Here are a couple of small images :-
I got success once I stopped trying to include 'as'.
Have a nice weekend,
Phil.
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
the use of 'out' in a parameter list / situation
Hi Johan,
I am not sure, I thought the REF idea was out of fashion a while back. These sorts of things are no much in my experience.
However, I do like the Tuple (sexy way) I will need to experiment.
I will feed back here if I get anything useful.
Regards,
Phil.
I am not sure, I thought the REF idea was out of fashion a while back. These sorts of things are no much in my experience.
However, I do like the Tuple (sexy way) I will need to experiment.
I will feed back here if I get anything useful.
Regards,
Phil.
the use of 'out' in a parameter list / situation
Johan,
See https://www.xsharp.eu/help/parameters.html
So AS, REF, OUT, IS and PARAMS are mutually exclusive.
Robert
See https://www.xsharp.eu/help/parameters.html
Code: Select all
parameterList : LPAREN (parameter (COMMA parameter)*)? RPAREN
;
parameter : (attributes)? SELF? identifier (ASSIGN_OP expression)? (parameterDeclMods datatype)?
| ELLIPSIS
;
parameterDeclMods : (AS | REF | OUT | IS | PARAMS) CONST?
;
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
- lumberjack
- Posts: 727
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
the use of 'out' in a parameter list / situation
Thanks Robert,
Sorry for any confusion, responded and then only checked the manual and did see OUT is recognized.
The same effect can be "simulated" with REF, provided you initialize the parameter before passing, which the OUT does not require. Both have its place.
REF: The parameter might be changed by the called method.
OUT: The parameter has to be set by the called method.
Regards,
Johan
Sorry for any confusion, responded and then only checked the manual and did see OUT is recognized.
The same effect can be "simulated" with REF, provided you initialize the parameter before passing, which the OUT does not require. Both have its place.
REF: The parameter might be changed by the called method.
OUT: The parameter has to be set by the called method.
Regards,
Johan
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
the use of 'out' in a parameter list / situation
An interesting short post Johan,
Thanks, I will now give these ideas a go in a test 'rig'.
Speak soon,
Phil.
Thanks, I will now give these ideas a go in a test 'rig'.
Speak soon,
Phil.
-
- Posts: 178
- Joined: Sat Dec 05, 2015 10:44 am
- Location: Germany
the use of 'out' in a parameter list / situation
Hi Johan,
this
Does this mean OUT parameters are always NULL at the beginning and should be tested !NULL before return?
Frank
this
wasn't clear to me. Thanks!Johan Nel wrote:
REF: The parameter might be changed by the called method.
OUT: The parameter has to be set by the called method.
Does this mean OUT parameters are always NULL at the beginning and should be tested !NULL before return?
Frank
- lumberjack
- Posts: 727
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
the use of 'out' in a parameter list / situation
Hi Frank,
Regards Johan
No, it will raise an error during compilation that the parameter is not set.Frank Maraite wrote: this wasn't clear to me. Thanks!
Does this mean OUT parameters are always NULL at the beginning and should be tested !NULL before return?
Code: Select all
FUNCTION TestOut(h AS STRING, w OUT STRING) AS STRING
RETURN h + " " + w
error XS0177: The out parameter 'w' must be assigned to before control leaves the current method
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa
- Phil Hepburn
- Posts: 743
- Joined: Sun Sep 11, 2016 2:16 pm
the use of 'out' in a parameter list / situation
Hi guys - Johan, Frank, and any others interested,
Attached are a couple of small images to help show the functionality etc.
OUT must change in the method code, and REF can change but does not have to. That's how it seems to me.
I suggest you try these out carefully for yourself before you use them, any guy who is not familiar with their use. Just so you know what is going on - check below :-
Hope this interests a few of you ;-0)
Cheers,
Phil.
Attached are a couple of small images to help show the functionality etc.
OUT must change in the method code, and REF can change but does not have to. That's how it seems to me.
I suggest you try these out carefully for yourself before you use them, any guy who is not familiar with their use. Just so you know what is going on - check below :-
Hope this interests a few of you ;-0)
Cheers,
Phil.