<div dir="ltr">Hi, I got more stuff !!! Not really about the functions in expr, though. The thing is that expr has a hard time managing symbols and numbers in pd. <div><br></div><div><b><u>ISSUE 1</u></b> - Problems with "$1", "$2", etc...</div><div><br></div><div>You can load arguments in expr with no problems IF it is actually being loaded into an abstraction that is receiving arguments. But when it is not receiving arguments you need to be careful on where it is placed, it needs to be placed by itself with spaces before and after.</div><div><br></div><div>For example, if you have [expr $1+1] in an abstraction that is receiving one argument it's ok. But if that's not the case, it won't load the object. The only way you can load the object with no argument being passed to it is like [expr $1 + 1], then $1 will receive a value of "0" like it should, and everything is fine.</div><div><br></div><div>Another example, if you have an "if" expression, such as [expr if($1 == 1, x, y)] - there's no deal if it's not getting an argument. But if you have it as [expr if( $1 == 1, x, y)] is fine! </div><div><br></div><div>I can't think of any good reason why it works when arguments are passed, but if fails when there are no arguments and they're getting values of "0". If it works one way it also should work the other way. So it's a bug for me...</div><div><br></div><div><b><u>ISSUE 2</u> </b>- Problems with $0</div><div><br></div><div>expr can read tables from the patches, and also variables in the [value] object. But when these elements are being used with the local variable "$0" we have issues.</div><div><br></div><div>Influenced by the 13.locality example in Pd, I'm used to create local variables such as "$0-x". But in expr this won't load as a symbol, $0 will become the patch code number "-" will define subtraction and "x" will be considered the variable. I guess it'd make sense if if it worked considering "$0-x" as a symbol (thus, a variable) but I understand expr is actually doing what makes sense to it. I also think it may be a pain trying to make this work. I'm actually fine with it if it turns out to be too troublesome, but it'd be nice to mention this in the documentation or help file.</div><div><br></div><div>But if we need to do this in some other way, we also have a hard time dealing with it. If you try "$0x", "$0.x" or "$0_x" it won't load! Now, I assume this problem might be closely related to the first issue I mentioned here with "$1". So it might be fixable in a similar fashion. </div><div><br></div><div>Continuing, the only way it works is if you put "$0" after a symbol, such as "x$0" or "x_$0". I can't think of a reason why this works and not the other, so looks like a bug for me too.</div><div><br></div><div>But then, is there any problem if you have to do it only like this? Actually, there is! All is fine in the case of [value], it'll load [v x$0] or whatever. All is also fine if you are using a table object, such as [table x$0] or [table x_$0]. The problem emerges when you are using an array not loaded as an object. So, if you're using a table that you need for display, it's quite a headache.</div><div><br></div><div>This is because "array" has issues of his own. If you have an array named "x$0" it won't read in an object like [tabread x$0]! Maybe this is a parallel issue that should be looked into. I guess they way Pd handles $0 in messages is tricky, but it is the opposite issue of expr. The array will work fine with $0 before symbols, but won't work well if it's afterwards. So an array named "x$0" won't work...</div><div><br></div><div>Well, it does work if you set it as "$0-x" for example. But I've already mentioned how it won't load in [expr]...</div><div><br></div><div>So, basically, if you want to do this, you need a somewhat complicated workaround. Since expr will only load something like "x_$0", you need to create an array and replace $0 by the actual number of that patch. Further workarounds may allow you to automatically rename that array when you load the patch, but it's not easy.</div><div><br></div><div>I know arrays are not making it easy, and maybe they could collaborate - but it'd be just fine if expr allowed something like "$0_x" like all other objects do! That'd be great.</div><div><br></div><div><b><u>ISSUE 3</u> </b>- Problems with exponential numbers<br></div><div><br></div><div>Pd will automatically convert "0.00001" to "1e-05". This will work in every object in Pd, but not expr! Because of this, we need workarounds such as putting it in parenthesis, like [expr (0.00001)], or use the pow function in expr, like [expr pow(10, -5)]. But since the behaviour in expr is different than everything else, I consider it a bug that may be worked out.</div><div><br></div><div>Looking forward for the fixes. Please tell me if you think you can work this all out.</div><div><br></div><div>Thanks</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-06-08 12:32 GMT-03:00 Shahrokh Yadegari <span dir="ltr"><<a href="mailto:sdy@ucsd.edu" target="_blank">sdy@ucsd.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thank Alexandre for that detailed list. It is very helpful. I will address them in the next couple of weeks, and now that Miller has suggested a path forward for committing the changes, hopefully the fixes show up in the official releases soon.<div><br></div><div>As for Max/MSP versions, yes I have had plans for a while, and it is on my list to be done this summer, if something else does not take over my allocated time.</div><div><br></div><div>cheers,</div><div>Shahrokh</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jun 7, 2015 at 11:45 PM, Alexandre Torres Porres <span dir="ltr"><<a href="mailto:porres@gmail.com" target="_blank">porres@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello, great to hear from you. Yes, I got that fix, but I never compiled it and was just hoping someday it'd show up as an update, and I'm just worried it never came to be. Sorry to put you on the spot. I'm still learning about the bug reports work and get dealt with in Pd, people in the list were explaining to me today in fact. But since everyone is gathered here, instead of me making a bug report, I'll just post everything I found wrong or funny. I spent a great deal of time testing, here we go:<div><br></div><div>- the help file of [expr] gives the wrong link to expr documentation, it points to <a href="http://www.crca.ucsd.edu/~yadegari/expr.html" target="_blank">http://www.crca.ucsd.edu/~yadegari/expr.html</a> where it should point to the new link <a href="http://yadegari.org/expr/expr.html" target="_blank">http://yadegari.org/expr/expr.html</a></div><div><br></div><div>- The random function is not listed in the documentation link above. But it's great and I always use it. It has a bug in Pd extended 0.42 where [expr random(1000, 100001)] will eventually give negative numbers. But, somehow, this seems to be fixed in vanilla 0.46-6.</div><div><br></div><div>- the "if" function is mentioned twice in the documentation<br></div><div><br></div><div>- The function "Sum" is not working yet.</div><div><br></div><div>- In the code we see other functions for tables that are not mentioned on the </div><div>documentation link They are: "avg", "Avg" and "Store" - but none of which seem to be working as well!</div><div><br></div><div>- there's this "copysig" issue (which is written wrong int the documentation as "copysign") and it seems to not be working.</div><div><br></div><div>- expr will consider integers as integers, so [expr 5 / 4] results in "1". You can do something like [expr 5./ 4] for it to work, or use the float function like this:  [expr float(5) / 4]. Now, this may not be a bug or wrong, but if you use [expr float(1.4)] it'll return you "1" instead of "1.4", and I guess it should be "1.4" anyway...</div><div><br></div><div>- [expr imodf($f1)] and [expr ldexp($f1)] are not loading</div><div><br></div><div>- [expr drem($f1)] loads with one argument, but the documentation says it takes two arguments. Even though it loads, it doesn't seem to be working, it sends lots of errors, such as "error: expr: FUNC_EVAL(1291): bad right type 0 /// expr: bang: unrecognized result 0 /// error: expr: FUNC_EVAL(1291): bad right type 3</div><div><br></div><div>- One's comlpement will load like this [expr $f1 ~ $f2]. Not sure what it's supposed to be, but it seems the second argument doesn't affect it at all.</div><div><br></div><div>- "floor" and "ceil" will load with two arguments, documentation says it was only one! Not sure what they're supposed to be, but it doesn't seem right cause it always returns the 1st argument in both of them.</div><div><br></div><div>- "fmod", wrong number of arguments in the documentation, it takes two!</div><div><br></div><div>- In the documentation, you have "</div><table cellpadding="0" cellspacing="0" border="0" width="100%" style="font-family:Times"><tbody><tr><td valign="middle" width="70"><font face="Helvetica, Arial, sans-serif"><small>atan()</small></font><font face="Helvetica, Arial, sans-serif"><small><br></small></font></td><td valign="top" align="center" width="50"><font face="Helvetica, Arial, sans-serif"><small>1</small></font><font face="Helvetica, Arial, sans-serif"><small><br></small></font></td><td valign="middle" align="left"><font face="Helvetica, Arial, sans-serif"><small>inverse hyperbolic</small></font><font face="Helvetica, Arial, sans-serif"><small> tangent"</small></font></td></tr></tbody></table><div>but I belive it should be "atan<b style="text-decoration:underline"><i>h</i></b>"<br></div><div><br></div><div>- Code says</div><div><br></div><div><div> *      The following are done but not popular enough in math libss</div><div> *      to be included yet</div><div> *              hypoth - Euclidean distance function</div><div> *              trunc</div><div> *              round</div><div> *              nearbyint - </div><div> </div></div><div><br></div><div>So, maybe they are popular enough nowadays? Maybe they're ready to be included?</div><div><br></div><div>Well, that's what I found so far. I'm no mathematician, so I can't find anything else I guess. I could test other functions but I wouldn't know if they are correct.</div><div><br></div><div>Anyway, sorry I can't help more getting into the code issues. I'm at a point now that I wish I know more about programming so I can help Pd development.</div><div><br></div><div>Thanks</div><div><br></div><div><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2015-06-08 3:08 GMT-03:00 Shahrokh Yadegari <span dir="ltr"><<a href="mailto:sdy@ucsd.edu" target="_blank">sdy@ucsd.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Alexandre,<div><br></div><div>This seems to be a bug. I am not sure why I missed the 'n' on the name either. As it seems that this function has never worked, we should fix the name as well. The solution is simple as follows:</div><div><br></div><div>







<p>extra/expr~/vexp_fun.c</p>
<p>188c188</p>
<p><         {"copysign",    ex_copysign,    2},</p>
<p>---</p>
<p>>         {"copysig",     ex_copysign,    1},</p><p><br></p><p>I checked the mailing list (I am sorry that I am not a regular reader) and I see some concerns about the maintenance of the code. I am happy to fix the problems and I thought I sent you a fix for the last problem you had found in 2009. Can somebody point me to a document or a webpage that explains what the best way is to introduce new changes to the pd source base.  Miller, should I pass the fixes to you, or is there another repository?</p><p>In the meanwhile, if there are other bugs in expr that anybody else knows, please send them to me and I will fix them as soon as I can.</p><p>best,<br>Shahrokh</p></div></div><div class="gmail_extra"><div><div><br><div class="gmail_quote">On Sun, Jun 7, 2015 at 12:57 PM, Alexandre Torres Porres <span dir="ltr"><<a href="mailto:porres@gmail.com" target="_blank">porres@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">hi there, I was checking the source of expr (find it attached) and saw this "copysign" function that I needed for a formula, but I can't get it to work/load.<div><br></div><div>I'm trying something like [expr copysign($f1)] and it's not happening. The expr manual page in <a href="http://yadegari.org/expr/expr.html" target="_blank">http://yadegari.org/expr/expr.html</a> tells about this function as well, here it is:</div><div><br></div><div><table cellpadding="0" cellspacing="0" border="0" width="100%" style="font-family:Times"><tbody><tr><td valign="top" align="left"><small><font face="Helvetica, Arial, sans-serif">copysign()<br></font></small></td><td valign="top" align="center"><small><font face="Helvetica, Arial, sans-serif">1<small><br></small></font></small></td><td valign="top"><small><font face="Helvetica, Arial, sans-serif">copy sign of a number</font><font face="Helvetica, Arial, sans-serif">(added in version 0.4)<br></font></small></td></tr></tbody></table></div><div><br></div><div>So it seems I'm supposedly doing the right thing... is it a bug? I'm on extended 0.42 and it says that it's expr version 0.4 when it loads.</div><div><br></div><div>cheers</div></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span><font color="#888888">-- <br><div><div dir="ltr">Shahrokh Yadegari<br>Professor of Composition and Sound Design,<br>Theatre and Dance Department<br>University of California, San Diego<br>Director, Initiative for Digital Exploration of Arts and Science, (IDEAS)<br>California Institute for Telecommunications and Information Technologies (Calit2)<br>Email: <a href="mailto:sdy@ucsd.edu" target="_blank">sdy@ucsd.edu</a><br>Web: <a href="http://yadegari.org" target="_blank">http://yadegari.org</a><br>Tel: <a href="tel:%28858%29%20822-4113" value="+18588224113" target="_blank">(858) 822-4113</a><br>Fax: <a href="tel:%28858%29%20534-1080" value="+18585341080" target="_blank">(858) 534-1080</a><br><br></div></div>
</font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr">Shahrokh Yadegari<br>Professor of Composition and Sound Design,<br>Theatre and Dance Department<br>University of California, San Diego<br>Director, Initiative for Digital Exploration of Arts and Science, (IDEAS)<br>California Institute for Telecommunications and Information Technologies (Calit2)<br>Email: <a href="mailto:sdy@ucsd.edu" target="_blank">sdy@ucsd.edu</a><br>Web: <a href="http://yadegari.org" target="_blank">http://yadegari.org</a><br>Tel: (858) 822-4113<br>Fax: (858) 534-1080<br><br></div></div>
</div>
</div></div></blockquote></div><br></div>