[Scilab-users] slight bug in exists()

classic Classic list List threaded Threaded
4 messages Options
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] slight bug in exists()


Dear all,

I had already mentioned this a while ago (http://mailinglists.scilab.org/Scilab-users-exists-yields-double-tt4039853.html), but as I guess we are in the update season, it would be good opportunity to fix this (if there isn't strong opposition, or a good reason for this behavior, of course).

I'm referring to the fact that the function exists() should by nature yield a Boolean result such as T or F. However, it yields 1 or 0. While this is not a big deal, similar functions performing a binary decision on their arguments, such as isreal(), isvector(), isfile() and many others, yield Boolean results. 

Regards,

Federico Miyara 


Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Antoine Monmayrant Antoine Monmayrant
Reply | Threaded
Open this post in threaded view
|

Re: slight bug in exists()

Hello Federico,

I agree with you that this would make more sense.
Could such a change be implemented for a point release?
I assume it would introduce some bugs in existing code relying on the (unusual) double output...

Antoine

On 09/02/2021 03:24, Federico Miyara wrote:

Dear all,

I had already mentioned this a while ago (http://mailinglists.scilab.org/Scilab-users-exists-yields-double-tt4039853.html), but as I guess we are in the update season, it would be good opportunity to fix this (if there isn't strong opposition, or a good reason for this behavior, of course).

I'm referring to the fact that the function exists() should by nature yield a Boolean result such as T or F. However, it yields 1 or 0. While this is not a big deal, similar functions performing a binary decision on their arguments, such as isreal(), isvector(), isfile() and many others, yield Boolean results. 

Regards,

Federico Miyara 


Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Clément David-3 Clément David-3
Reply | Threaded
Open this post in threaded view
|

Re: slight bug in exists()

Hello all,

 

Indeed this would probably break some code. We should carefully check the exist() usage within Scilab to ensure the output value is not passed to macros/gateways checking for a “double” datatype. Code using exists() output value as index or as condition might not be affected.

 

Don’t hesitate to push such a change on the master branch I will review it.

 

Thanks,

 

Clément

 

From: users <[hidden email]> On Behalf Of Antoine Monmayrant
Sent: Tuesday, February 9, 2021 4:28 AM
To: [hidden email]
Subject: Re: [Scilab-users] slight bug in exists()

 

Hello Federico,

I agree with you that this would make more sense.
Could such a change be implemented for a point release?
I assume it would introduce some bugs in existing code relying on the (unusual) double output...

Antoine

On 09/02/2021 03:24, Federico Miyara wrote:


Dear all,

I had already mentioned this a while ago (http://mailinglists.scilab.org/Scilab-users-exists-yields-double-tt4039853.html), but as I guess we are in the update season, it would be good opportunity to fix this (if there isn't strong opposition, or a good reason for this behavior, of course).

I'm referring to the fact that the function exists() should by nature yield a Boolean result such as T or F. However, it yields 1 or 0. While this is not a big deal, similar functions performing a binary decision on their arguments, such as isreal(), isvector(), isfile() and many others, yield Boolean results. 

Regards,

Federico Miyara 

 

Image removed by sender.

Libre de virus. www.avast.com



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

Re: slight bug in exists()

In reply to this post by Antoine Monmayrant

Antoine,

Well, to be sure, there are some functions that do not work on booleans. For instance, mean(), max() and mean() will cause error; but not sum() and prod().

However, I think exists() is used mostly in conditionals, where both types work fine. And if getting errors, they can be easily solved by using double() to convert to double. This workaround could be included in the documentation.

If not fixed in this release, a warning could be issued in the documentation that the current output argument type will be changed to boolean in the next release.

Federico Miyara
 

On 09/02/2021 00:27, Antoine Monmayrant wrote:

Hello Federico,

I agree with you that this would make more sense.
Could such a change be implemented for a point release?
I assume it would introduce some bugs in existing code relying on the (unusual) double output...

Antoine

On 09/02/2021 03:24, Federico Miyara wrote:

Dear all,

I had already mentioned this a while ago (http://mailinglists.scilab.org/Scilab-users-exists-yields-double-tt4039853.html), but as I guess we are in the update season, it would be good opportunity to fix this (if there isn't strong opposition, or a good reason for this behavior, of course).

I'm referring to the fact that the function exists() should by nature yield a Boolean result such as T or F. However, it yields 1 or 0. While this is not a big deal, similar functions performing a binary decision on their arguments, such as isreal(), isvector(), isfile() and many others, yield Boolean results. 

Regards,

Federico Miyara 


Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users