[Scilab-users] [SEP] [boolean integer_class] concatenations

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

[Scilab-users] [SEP] [boolean integer_class] concatenations

Hello,

Surprisingly, as reported in http://bugzilla.scilab.org/15534, after 30 years, Scilab still does not know how to concatenate booleans with encoded integers.
For instance :

--> [%f int8(-3)]

Undefined operation for the given operands.
check or define function %b_c_i for overloading.
It is surprising, because
  • For some languages like Octave, booleans are actually some numbers restricted to 0|1, and such simple concatenations are available.
  • Implementing it in Scilab is trivial and does not really set any question, since both 0 and 1 are present in all Scilab integer classes.

An implementation is proposed for Scilab 6.1 (see the bugzilla report).

Comments are welcome.

Samuel

PS : Please do not comment here about the concatenation of distinct integer classes together (like [int8(-3) uint16(10)]), or with decimal numbers. A dedicated report and thread will be opened for them. A survey of how other similar languages process such concatenations is in progress.


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

Re: [SEP] [boolean integer_class] concatenations

Le 17/04/2018 à 18:49, Samuel Gougeon a écrit :

Hello,

Surprisingly, as reported in http://bugzilla.scilab.org/15534, after 30 years, Scilab still does not know how to concatenate booleans with encoded integers.
For instance :

--> [%f int8(-3)]

Undefined operation for the given operands.
check or define function %b_c_i for overloading.
It is surprising, because
  • For some languages like Octave, booleans are actually some numbers restricted to 0|1, and such simple concatenations are available.
  • Implementing it in Scilab is trivial and does not really set any question, since both 0 and 1 are present in all Scilab integer classes.

An implementation is proposed for Scilab 6.1 (see the bugzilla report).

Comments are welcome.


No comments?

The only reason i have found to understand why this is still not implemented would be to let the user define its own overloads. But which alternative to casting %f=>0 %t=>1 could we have?
The first and may be only one we could imagine would be to cast integers into booleans, as in
[%t int8([0 -5])] => [%t %f %t]

Why not choosing this, instead of [%t int8([0 -5])] => int8([1 0 -5])?
It's a poorer result, that can be obtained in a straightforward way as
[%t int8([0 -5])]  =>  int8([1 0 -5])~=0
 
Regards
SG


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

Re: {EXT} Re: [SEP] [boolean integer_class] concatenations

Hello Samuel,

> De la part de Samuel Gougeon
> Envoyé : dimanche 22 avril 2018 16:06
>
> http://bugzilla.scilab.org/15534 [...]
> --> [%f int8(-3)]
> [...]
>
> No comments?

Unfortunately, I don't have any use of this kind of mix between booleans and integers
so my opinion would not help very much.

Are there some known applications where this is useful?

I can imagine that integers between 0 and 1 can be used for fuzzy logic
but I don't figure otherwise how the mix between different type of data,
except for a list, can be interesting.

Regards

--
Christophe Dang Ngoc Chan
[hidden email]
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
_______________________________________________
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: [SEP] [boolean integer_class] concatenations

In reply to this post by Samuel GOUGEON
Hello Samuel,

Le dimanche 22 avril 2018 à 16:06 +0200, Samuel Gougeon a écrit :

> Le 17/04/2018 à 18:49, Samuel Gougeon a écrit :
> > Hello,
> > Surprisingly, as reported in http://bugzilla.scilab.org/15534, after 30 years, Scilab still does
> > not know how to concatenate booleans with encoded integers.
> > For instance :
> > --> [%f int8(-3)]
> >
> > Undefined operation for the given operands.
> > check or define function %b_c_i for overloading.
> > It is surprising, because
> > For some languages like Octave, booleans are actually some numbers restricted to 0|1, and such
> > simple concatenations are available.
> > Implementing it in Scilab is trivial and does not really set any question, since both 0 and 1
> > are present in all Scilab integer classes.
> > An implementation is proposed for Scilab 6.1 (see the bugzilla report).
> > Comments are welcome.
>  
> No comments?
>
> The only reason i have found to understand why this is still not implemented would be to let the
> user define its own overloads. But which alternative to casting %f=>0 %t=>1 could we have?
> The first and may be only one we could imagine would be to cast integers into booleans, as in
> [%t int8([0 -5])] => [%t %f %t]
>
> Why not choosing this, instead of [%t int8([0 -5])] => int8([1 0 -5])?
> It's a poorer result, that can be obtained in a straightforward way as
> [%t int8([0 -5])]  =>  int8([1 0 -5])~=0

To me the whole remark is in the (still open) type conversion topic : promotion or coercion to
another type. Currently in Scilab most of the operations consume doubles and output doubles ; as
most of our users are not computer scientists I prefer to have promotion to double whenever possible
 as it is currently rather than complex type coercion rules per operations (see the current
implementation in modules/ast/src/cpp/operations).

For exemple, using your proposal I am not sure about user expectation on:

 [%f int8(-3)]
 [int8(0) %t]
 [%f 1.]         // promotion to double !

Thanks,

--
Clément
 



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