<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hello,<br>
<br>
Or when you have to write a function following a specific prototype
( graphic events, optim, ode, ...)<br>
<br>
If I would write a function that call another, I have to specify a
prototype to allow user to call my function.<br>
But in some case, the final user does not need all parameters so he
can replace unused inputs by ~.<br>
I think that only syntactic sugar.<br>
<br>
example:<br>
function for_each(iterable, fn)<br>
for i=1:size(iterable, "*")<br>
fn(iterable(i), i, iterable); //item, index, array<br>
end<br>
endfunction<br>
<br>
Users can define fn like this if tthey only need item and don't want
to use index and whole array<br>
function my_func(a, ~, ~)<br>
//blabla<br>
end<br>
<br>
I don't say that's essential :p<br>
That's my understanding<br>
Antoine<br>
<div class="moz-cite-prefix">Le 26/11/2019 à 16:15, Chin Luh Tan a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:16ea84894df.ec878ea5206082.1419682616925923037@bytecode-asia.com">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<div style="font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;">
<div>Hi Samuel, <br>
</div>
<div><br>
</div>
<div>In fact I've not been using matlab for more than 10 years,
so I try to understand this as well. <br>
</div>
<div><br>
</div>
<div>The input tilde is still abit confusing for me as well, I
am trying to understand its' usage as this page: <a
href="https://octave.org/doc/v4.4.1/Ignoring-Arguments.html"
target="_blank" moz-do-not-send="true">https://octave.org/doc/v4.4.1/Ignoring-Arguments.html</a><br>
</div>
<div><br>
</div>
<div>function val = pick2nd (~, arg2) <br>
</div>
<div> val = arg2;<br>
</div>
<div>endfunction<br>
</div>
<div><br>
</div>
<div>I can't see the reason why the input need to ignored in
this case, is it defined but not being user due to bad user
overlooked it? or is it neglected and the default value would
be used?<br>
</div>
<div><br>
</div>
<div>Then I find this : <a
href="https://stackoverflow.com/questions/25204074/correct-use-of-tilde-operator-for-input-arguments"
target="_blank" moz-do-not-send="true">https://stackoverflow.com/questions/25204074/correct-use-of-tilde-operator-for-input-arguments</a><br>
</div>
<div><br>
</div>
<div><b><i>"The tilde is only for function declaration. Matlab's
mlint recommends to replace unused arguments by ~. The
result is a function declared like this function output =
MyFunction(a, b, ~, c). This is a very bad practice. </i></b><b><i><br>
</i></b></div>
<div><b><i><br>
</i></b></div>
<div><b><i>Since you have a function where the parameters are
optional, you must call the function with empty arguments
output=MyFunction(str1,str2,[],[],...,true)."</i></b><br>
</div>
<br>
<div data-zbluepencil-ignore="true" style="" class="zmail_extra">It
sound to me that the input tilde is suggested by the matlab
mlint to improve the code so that the unused variable need not
to pass into the function, and to improve memory management? <br>
<br>
So there are 2 possibilities for the input tilde :<br>
<br>
1. used to replace unused variable in the input which defined
by user, but not being used. So the mlint recomment to replace
with tilde, it could be be remove possibly due to the project
has been calling the functions for many time, and changing the
4th to 3rd argument might need to change a lot of codes. In
this case, the %unused would be good. <br>
<br>
2. Tilde used to tell the function to use default value, then
replacing it with % unused might cause error. <br>
<br>
Think we need some x-matlaber to confirm which case. <br>
<br>
Thanks again.<br>
<br>
rgds,<br>
CL <br>
<br>
<br>
<br>
<div id="Zm-_Id_-Sgn1">---- On Tue, 26 Nov 2019 20:36:01 +0800
<b>Samuel Gougeon <<a target="_blank"
href="mailto:sgougeon@free.fr" moz-do-not-send="true">sgougeon@free.fr</a>></b>
wrote ----<br>
</div>
<br>
<blockquote style="border-left: 1px solid rgb(204, 204, 204);
padding-left: 6px; margin: 0px 0px 0px 5px;">
<div>
<div class="x_-860490224moz-cite-prefix">Hello Chin Luh,<br>
</div>
<div class="x_-860490224moz-cite-prefix"><br>
</div>
<div class="x_-860490224moz-cite-prefix">Thanks a lot for
your input.<br>
</div>
<div class="x_-860490224moz-cite-prefix"><br>
</div>
<div class="x_-860490224moz-cite-prefix">Both cases --
input and output will have to be converted --, since the
converter is also made to convert (sets of) functions
definitions, not only scripts.<br>
</div>
<div class="x_-860490224moz-cite-prefix"><br>
</div>
<div class="x_-860490224moz-cite-prefix">About the input
case: Steven's answer is still not really clear to me.
Doing some tests on Octave, we must anyway provide some
input at calling time when ~ is used as default input
in the definition. AFAIU, this ~ could just be to make
sure that no variable name used inside the function
matches the name of the input argument in the function
definition, since "~" alone can't be actually used as
variable's name. In this case, for Scilab, any input ~
could be replaced with an improbable variable name like
"%unused" or "%kwzxq", and that should do it.<br>
</div>
<div class="x_-860490224moz-cite-prefix"><br>
</div>
<div class="x_-860490224moz-cite-prefix">Please, correct
me if someone understands something else.<br>
<br>
Best regards<br>
Samuel<br>
</div>
<br>
Le 26/11/2019 à 03:33, Chin Luh Tan a écrit :<br>
<div><br>
</div>
<p><br>
</p>
</div>
_______________________________________________<br>
users mailing list <br>
<a target="_blank" href="mailto:users@lists.scilab.org"
moz-do-not-send="true">users@lists.scilab.org</a> <br>
<a target="_blank"
href="http://lists.scilab.org/mailman/listinfo/users"
moz-do-not-send="true">http://lists.scilab.org/mailman/listinfo/users</a>
<br>
<blockquote>
<div style="font-family: Verdana, Arial, Helvetica,
sans-serif;font-size: 10.0pt;">
<div>Hi Samuel, <br>
</div>
<div><br>
</div>
<div>I think your assumption likely correct on the input
and the output using ~<br>
</div>
<div><br>
</div>
<div><a target="_blank"
href="https://www.mathworks.com/matlabcentral/answers/288016-tilde-doesn-t-work-for-ignoring-my-inputs"
moz-do-not-send="true">https://www.mathworks.com/matlabcentral/answers/288016-tilde-doesn-t-work-for-ignoring-my-inputs</a><br>
</div>
<div><br>
</div>
<div>"<br>
</div>
<div class="x_-860490224paragraphNode x_-860490224wrappable" style="box-sizing: border-box;font-family: Helvetica, Arial, sans-serif;white-space: pre-wrap;margin: 2.0px 10.0px 10.0px 4.0px;line-height: 1.5;color: rgb(0,0,0);font-size: 14.0px;min-height: 17.0px;overflow: auto;font-style: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0.0px;text-transform: none;widows: 2;word-spacing: 0.0px;background-color: rgb(255,255,255);"><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;">You </span></span><b><span class="x_-860490224textWrapper" style="box-sizing: border-box;">can</span></b><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;"> use tilde to ignore input arguments when you </span></span><b><span class="x_-860490224textWrapper" style="box-sizing: border-box;">define</span></b><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;"> the function.</span></span>
</div>
<div class="x_-860490224paragraphNode x_-860490224wrappable" style="box-sizing: border-box;font-family: Helvetica, Arial, sans-serif;white-space: pre-wrap;margin: 2.0px 10.0px 10.0px 4.0px;line-height: 1.5;color: rgb(0,0,0);font-size: 14.0px;min-height: 17.0px;overflow: auto;font-style: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0.0px;text-transform: none;widows: 2;word-spacing: 0.0px;background-color: rgb(255,255,255);"><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;">You </span></span><b><span class="x_-860490224textWrapper" style="box-sizing: border-box;">cannot</span></b><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;"> use tilde to ignore input arguments when you </span></span><b><span class="x_-860490224textWrapper" style="box-sizing: border-box;">call</span></b><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;"> the function.</span></span>
</div>
<div class="x_-860490224paragraphNode x_-860490224wrappable" style="box-sizing: border-box;font-family: Helvetica, Arial, sans-serif;white-space: pre-wrap;margin: 2.0px 10.0px 10.0px 4.0px;line-height: 1.5;color: rgb(0,0,0);font-size: 14.0px;min-height: 17.0px;overflow: auto;font-style: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0.0px;text-transform: none;widows: 2;word-spacing: 0.0px;background-color: rgb(255,255,255);"><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;">You </span></span><b><span class="x_-860490224textWrapper" style="box-sizing: border-box;">cannot</span></b><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;"> use tilde to ignore output arguments when you </span></span><b><span class="x_-860490224textWrapper" style="box-sizing: border-box;">define</span></b><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;"> the function.</span></span>
</div>
<div class="x_-860490224paragraphNode x_-860490224wrappable" style="box-sizing: border-box;font-family: Helvetica, Arial, sans-serif;white-space: pre-wrap;margin: 2.0px 10.0px 10.0px 4.0px;line-height: 1.5;color: rgb(0,0,0);font-size: 14.0px;min-height: 17.0px;overflow: auto;font-style: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0.0px;text-transform: none;widows: 2;word-spacing: 0.0px;background-color: rgb(255,255,255);"><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;">You </span></span><b><span class="x_-860490224textWrapper" style="box-sizing: border-box;">can</span></b><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;"> use tilde to ignore output arguments when you </span></span><b><span class="x_-860490224textWrapper" style="box-sizing: border-box;">call</span></b><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;"> the function.</span></span>
</div>
<div class="x_-860490224paragraphNode x_-860490224wrappable" style="box-sizing: border-box;font-family: Helvetica, Arial, sans-serif;white-space: pre-wrap;margin: 2.0px 10.0px 10.0px 4.0px;line-height: 1.5;color: rgb(0,0,0);font-size: 14.0px;min-height: 17.0px;overflow: auto;font-style: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0.0px;text-transform: none;widows: 2;word-spacing: 0.0px;background-color: rgb(255,255,255);"><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;">If you want to be able to specify only the third argument, there must be some way for your function to disambiguate the one-input call from a call that specifies only the third input. Usually in MathWorks function this is done by specifying [] for the arguments for which the user doesn't want to specify. In that case the code would use the default value if either </span></span><span class="font" style="font-family:Menlo, Monaco, Consolas, "Courier New", monospace"><span class="x_-860490224textWrapper" style="box-sizing: border-box;">nargin</span></span><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;"> is too small or if </span></span><span class="font" style="font-family:Menlo, Monaco, Consolas, "Courier New", monospace"><span class="x_-860490224textWrapper" style="box-sizing: border-box;">nargin</span></span><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;"> is large enough and the specified input argument </span></span><span class="font" style="font-family:Menlo, Monaco, Consolas, "Courier New", monospace"><span class="x_-860490224textWrapper" style="box-sizing: border-box;">isempty</span></span><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;">.</span></span>
</div>
<div class="x_-860490224paragraphNode x_-860490224wrappable" style="box-sizing: border-box;font-family: Helvetica, Arial, sans-serif;white-space: pre-wrap;margin: 2.0px 10.0px 10.0px 4.0px;line-height: 1.5;color: rgb(0,0,0);font-size: 14.0px;min-height: 17.0px;overflow: auto;font-style: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0.0px;text-transform: none;widows: 2;word-spacing: 0.0px;background-color: rgb(255,255,255);"><span class="x_-860490224textBox" style="box-sizing: border-box;"><span class="x_-860490224textWrapper" style="box-sizing: border-box;">"</span></span>
</div>
<div class="x_-860490224paragraphNode x_-860490224wrappable" style="box-sizing: border-box;font-family: Helvetica, Arial, sans-serif;white-space: pre-wrap;margin: 2.0px 10.0px 10.0px 4.0px;line-height: 1.5;color: rgb(0,0,0);font-size: 14.0px;min-height: 17.0px;overflow: auto;font-style: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0.0px;text-transform: none;widows: 2;word-spacing: 0.0px;background-color: rgb(255,255,255);">From what I could think off, mat2sci conversion to replace ~ at the output arguments should always be safe. As for the input, since the tilde could not be used as input when calling function, I think there should not be any cases that need to be implemented in conversion?
</div>
<div class="x_-860490224paragraphNode x_-860490224wrappable" style="box-sizing: border-box;font-family: Helvetica, Arial, sans-serif;white-space: pre-wrap;margin: 2.0px 10.0px 10.0px 4.0px;line-height: 1.5;color: rgb(0,0,0);font-size: 14.0px;min-height: 17.0px;overflow: auto;font-style: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0.0px;text-transform: none;widows: 2;word-spacing: 0.0px;background-color: rgb(255,255,255);">Thanks.
</div>
<div class="x_-860490224paragraphNode x_-860490224wrappable" style="box-sizing: border-box;font-family: Helvetica, Arial, sans-serif;white-space: pre-wrap;margin: 2.0px 10.0px 10.0px 4.0px;line-height: 1.5;color: rgb(0,0,0);font-size: 14.0px;min-height: 17.0px;overflow: auto;font-style: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0.0px;text-transform: none;widows: 2;word-spacing: 0.0px;background-color: rgb(255,255,255);">Regards,
</div>
<div class="x_-860490224paragraphNode x_-860490224wrappable" style="box-sizing: border-box;font-family: Helvetica, Arial, sans-serif;white-space: pre-wrap;margin: 2.0px 10.0px 10.0px 4.0px;line-height: 1.5;color: rgb(0,0,0);font-size: 14.0px;min-height: 17.0px;overflow: auto;font-style: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-indent: 0.0px;text-transform: none;widows: 2;word-spacing: 0.0px;background-color: rgb(255,255,255);">CL
</div>
<div><br>
</div>
<div class="x_-860490224zmail_extra">
<div><br>
</div>
<div>---- On Tue, 26 Nov 2019 04:20:52 +0800 <b>Samuel
Gougeon <a target="_blank"
href="mailto:sgougeon@free.fr"
class="x_-860490224moz-txt-link-rfc2396E"
moz-do-not-send="true"><sgougeon@free.fr></a></b>
wrote ----<br>
</div>
<div><br>
</div>
<blockquote style="border-left: 1.0px solid
rgb(204,204,204);padding-left: 6.0px;margin: 0.0px
0.0px 0.0px 5.0px;">
<div>
<div class="x_-2142421898moz-cite-prefix">Le
23/11/2019 à 15:35, Samuel Gougeon a écrit :<br>
</div>
<blockquote>
<div class="x_-2142421898moz-cite-prefix">Hello<span
class="colour" style="color:rgb(0, 0, 0)">
Philipp, and to all (former ;-) matlabers,</span><br>
</div>
<div class="x_-2142421898moz-cite-prefix"><span
class="colour" style="color:rgb(0, 0, 0)"><br>
</span></div>
<div class="x_-2142421898moz-cite-prefix"><span
class="colour" style="color:rgb(0, 0, 0)"></span>Le
16/10/2019 à 11:46, P M a écrit :<br>
</div>
<blockquote>
<div dir="ltr">
<div>Dear experts,<br>
</div>
<div><br>
</div>
<div>trying to convert a matlab code to
scilab I come across following line:<br>
</div>
<div>
<pre style="font-family: Monospaced;font-style: normal;"><span class="colour" style="color:rgb(74, 85, 219)">[~</span><span class="colour" style="color:rgb(0, 0, 0)">,~,Minstances_hat</span><span class="colour" style="color:rgb(74, 85, 219)">]</span> <span class="colour" style="color:rgb(92, 92, 92)">=</span> <span class="colour" style="color:rgb(0, 0, 0)">unique</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(0, 0, 0)">B</span><span class="colour" style="color:rgb(74, 85, 219)">(</span><span class="colour" style="color:rgb(255, 170, 0)">:</span><span class="colour" style="color:rgb(74, 85, 219)">))</span><span class="colour" style="color:rgb(0, 0, 0)">;
</span>
</pre>
<pre style="font-family: Monospaced;font-style: normal;"><span class="colour" style="color:rgb(0, 0, 0)">How to replace the "~" symbol?
</span>
</pre>
<pre style="font-family: Monospaced;font-style: normal;"><span class="colour" style="color:rgb(0, 0, 0)">B is the blue channel of a RGB image...hence a m x n matrix of integers (type(B) = 8 )
</span>
</pre>
</div>
</div>
</blockquote>
<p><br>
</p>
<p>This issue is now reported as <a
href="http://bugzilla.scilab.org/show_bug.cgi?id=16254"
target="_blank" moz-do-not-send="true">bug
16250</a>.<br>
</p>
<p>Solving this issue would improve the
converter.<br>
I may contribute to solve it. However, I do
not use to use Matlab or Octave. So i don't
know how the ~ placeholder set in the list of
<i>inputs</i> is processed inside the called
function. This message is a call for
information about this topic.<br>
<br>
Ignoring an output is trivial. As suggested by
Stéphane, the ans variable is a good candidate
as replacement for ~,<br>
just as a fake recipient, as in "[~, ia] =
unique(A)" => "[ans, ia] = unique(A)"<br>
</p>
<p>The meaning of ignoring an input is a priori
completely different, at least from a Scilab
point of view.<br>
</p>
<p>This leads to the fact that, on the "function
..." line, the converter will have to
distinguish the list of inputs from the list
of outputs, and then process the same ~
character in 2 different ways.<br>
This processing would have to run also when
the "function ..." line is split on several
rows with the "..." continuation marks.<br>
<br>
First, i will need an actual example of
function call with ~ in the input list,
runnable in Octave.<br>
Any compact suggestion is welcome.<br>
At least 2 use cases are expected: one calling
a function written in Octave/Matlab language
(improperly called "macros" in Scilab), the
other one calling a hard-coded function.<br>
</p>
<p>Let's consider the first case, with a
"macro":<br>
</p>
<ul>
<li>What does the ~ sent placeholder pass to
the function? How is it detected/detectable
inside the macro ?<br>
</li>
<li>How is it processed by the function? Is
there a generic default processing, as
replacing it with the empty matrix [], or
whatever else?<br>
</li>
</ul>
</blockquote>
<p>Where is the crowd of matlabers?<br>
</p>
<div>The page describing this feature:<a
class="x_-2142421898moz-txt-link-freetext"
href="https://fr.mathworks.com/help/matlab/matlab_prog/ignore-function-inputs.html"
target="_blank" moz-do-not-send="true">https://fr.mathworks.com/help/matlab/matlab_prog/ignore-function-inputs.html</a><br>
</div>
<div>But i do not clearly understand it.<br>
</div>
<div>Apparently, "canceling" an input is done
(only?) at the function definition, not when
calling it, unlike for the outputs.<br>
</div>
<div>If so, then <i>ans</i> could also be used as
a replacement, meaning that anyway this input
won't be used inside the function.<br>
</div>
<div><br>
</div>
<p>A test of call with Octave yields an error:<br>
</p>
<p><span style="" class="x_-860490224size">>>
function [r, s] = funtest(a,b,c)<br>
end<br>
>> funtest(1,~,3)<br>
parse error:<br>
invalid use of empty argument (~) in index
expression<br>
>>> funtest(1,~,3)<br>
^<br>
>><br>
</span></p>
<div>Any further insight is welcome.<br>
</div>
<div>Samuel<br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div>_______________________________________________<br>
</div>
<div>users mailing list <br>
</div>
<div><a target="_blank"
href="mailto:users@lists.scilab.org"
class="x_-860490224moz-txt-link-abbreviated"
moz-do-not-send="true">users@lists.scilab.org</a>
<br>
</div>
<div><a target="_blank"
href="http://lists.scilab.org/mailman/listinfo/users"
class="x_-860490224moz-txt-link-freetext"
moz-do-not-send="true">http://lists.scilab.org/mailman/listinfo/users</a>
<br>
</div>
</blockquote>
</div>
<div><br>
</div>
</div>
<br>
<br>
<pre class="x_-860490224moz-quote-pre">_______________________________________________
users mailing list
<a target="_blank" href="mailto:users@lists.scilab.org" class="x_-860490224moz-txt-link-abbreviated" moz-do-not-send="true">users@lists.scilab.org</a>
<a target="_blank" href="http://lists.scilab.org/mailman/listinfo/users" class="x_-860490224moz-txt-link-freetext" moz-do-not-send="true">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
</blockquote>
</div>
<div><br>
</div>
</div>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
</body>
</html>