ok - thanks for pointing out that discussion.
   Christoph

On Saturday, 29 November 2014 21:51:55 UTC, Milan Bouchet-Valat wrote:
>
> Le samedi 29 novembre 2014 à 12:46 -0800, Christoph Ortner a écrit : 
> > 
> > 
> > When I want to just write a quick script to test and idea, then I 
> > don't want to check that I've created my indices, array lengths etc as 
> > the correct type. I think for functions such as linspace not 
> > performing an automatic type conversion is a big mistake. 
> > 
> > 
> > I thought that in previous Julia verions   `int32(1.1)`  would throw 
> > an error (maybe I misremember this). Now it just converts it to 1. I 
> > then agree that this is a bit dangerous. It should throw an error 
> > because 1.1 cannot be converted  to int. This would resolve the issue 
> > --- but of course there may be others that I don't appreciate. 
> The future of int32(), int() and the like is not completely clear at the 
> moment, especially with regard to the fact that they currently coerce, 
> i.e. don't fail when exact conversion is not possible. See 
> https://github.com/JuliaLang/julia/issues/1470 
>
>
> Regards 
>
> > 
> >    Christoph 
> > 
> > 
> > 
> > 
> > On Saturday, 29 November 2014 13:22:05 UTC, Tamas Papp wrote: 
> >         In general, I am more concerned about the following scenario: 
> >         type A 
> >         makes sense, type B in general, does not, yet a subset of type 
> >         B values 
> >         can be converted to A in a reasonable way, so an the 
> >         implementation 
> >         performs this silently and everything seems fine. 
> >         
> >         But at the same time, had I known that I left a type B value 
> >         in there, I 
> >         would be concerned, eg because I am assuming that it is exact 
> >         when it 
> >         isn't (integers vs floats) is problematic, or that conversion 
> >         is 
> >         possible only for a subset of the domain, and other values are 
> >         possible 
> >         but rare enough for my unit tests not to discover them, and 
> >         will strike 
> >         me on the nose at some future point like a rake carelessly 
> >         left in the 
> >         grass. 
> >         
> >         Best, 
> >         
> >         Tamas 
> >         
> >         On Sat, Nov 29 2014, Stefan Karpinski <[email protected]> 
> >         wrote: 
> >         
> >         > Our conversions throw errors when the value cannot be 
> >         converted exactly these days so it could be done pretty 
> >         safely. But yes, this is just because there's no applicable 
> >         method of linspace. 
> >         > 
> >         > 
> >         >> On Nov 29, 2014, at 7:07 AM, Tamas Papp <[email protected]> 
> >         wrote: 
> >         >> 
> >         >> I think of this as a feature: using a float when only an 
> >         integer makes 
> >         >> sense is most likely a bug in my code. Automatic conversion 
> >         would mask 
> >         >> the problem. 
> >         >> 
> >         >> Best, 
> >         >> 
> >         >> Tamas 
> >         >> 
> >         >>> On Sat, Nov 29 2014, [email protected] wrote: 
> >         >>> 
> >         >>> One of the primary paradigms of Julia is the use of 
> >         multiple dispatch, that 
> >         >>> is choosing which method to call based on the types of the 
> >         parameters 
> >         >>> provided.  To quote from the manual 
> >         >>> 
> >         
> http://docs.julialang.org/en/latest/manual/methods/#defining-methods "No 
> >         >>> automatic casting or conversion of function arguments is 
> >         ever performed: 
> >         >>> all conversion in Julia is non-magical and completely 
> >         explicit." 
> >         >>> 
> >         >>> Cheers 
> >         >>> Lex 
> >         >>> 
> >         >>>> On Saturday, November 29, 2014 8:17:26 PM UTC+10, 
> >         Christoph Ortner wrote: 
> >         >>>> 
> >         >>>> 
> >         >>>> In Julia 3.3  `linspace(0, 1, 10) `  works, but 
> >          `linspace(0, 1, 10.)` 
> >         >>>> does not. 
> >         >>>> 
> >         >>>> Why is the type not automatically converted to Int when 
> >         possible? Is this 
> >         >>>> intended or a bug? 
> >         >>>> 
> >         >>>>    Christoph 
> >         >>>> 
> >         >>>> 
> >         >>>> 
> >         >>>> 
> >         >>>> 
> >         >>>> 
> >         >>>> 
> >         >>>> 
>
>

Reply via email to