[Scilab-users] [SEP] [boolean integer_class] concatenations
Clément David
Clement.David at esi-group.com
Mon Apr 23 10:38:46 CEST 2018
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
More information about the users
mailing list