But that has a constant format string, and is a great example on how to use 
@sprintf. The question here is about non-constant format strings (as far as 
I can tell).

kl. 14:59:06 UTC+1 torsdag 4. desember 2014 skrev Mike Innes følgende:
>
> To clarify, I meant something like
>
> function printnums(x,y,z)
>   @sprintf("%.2f %.2f %.2f", x, y, z)
> end
>
> Which will both be type safe and have good performance. It doesn't solve 
> all the issues, but as I said, it does solve the specific issue of 
> repetition of format strings.
>
> On 4 December 2014 at 13:49, Ivar Nesje <iva...@gmail.com <javascript:>> 
> wrote:
>
>> A function wrapping Julia @sprintf will be typesafe, but will have 
>> terrible performance. One could cache the generated functions though, so 
>> that the format string will only be used as a lookup in a hash table that 
>> points to the specialized (typesafe) function for that format string.
>>
>> kl. 13:49:09 UTC+1 torsdag 4. desember 2014 skrev Mike Innes følgende:
>>>
>>> I'm not sure I understand – C's sprintf certainly has problems with type 
>>> safety, but a function wrapping Julia's @sprintf can't *not* be 
>>> strongly typed. No?
>>>
>>> On 3 December 2014 at 23:43, <ele...@gmail.com> wrote:
>>>
>>>>
>>>> As Stefan said above, the problem with traditional (s)printf functions 
>>>> is type safety.
>>>>
>>>> On Thursday, December 4, 2014 4:53:17 AM UTC+10, Mike Innes wrote:
>>>>>
>>>>> #9423 <https://github.com/JuliaLang/julia/pull/9243> should help with 
>>>>> the repetition of format strings issue. It occurs to me now that you can 
>>>>> always just write a function wrapper for `@sprintf` to solve that issue 
>>>>> but 
>>>>> this might still be useful.
>>>>>
>>>>> [...]
>>>>
>>>
>>>
>

Reply via email to