Is there a way to get a printf() or sprintf() function in Julia?

631 views
Skip to first unread message

Daniel Carrera

unread,
May 3, 2015, 9:43:22 AM5/3/15
to julia...@googlegroups.com
Hello,

My biggest pet-peeve in Julia is that @sprintf is a macro and not a function. That makes it very annoying to use at times because I cannot put a format string in a variable, or make a wrapper `printf()` function. I don't understand why this is an issue, since several other languages have a printf() function.

Is there any chance that I might see a printf() function in Julia in the future?

I should clarify that I am aware of the "Formatting" module. I do not want to use Python-style formatting strings. I don't like them, I think they are confusing, and other languages that I use have traditional C-style printf() functions, so I want to stick to those. I realize that the "Formatting" module has one function called "sprintf1()" but that function only accepts one parameter, so it is not especially useful.

Cheers,
Daniel.

Patrick O'Leary

unread,
May 3, 2015, 10:17:48 AM5/3/15
to julia...@googlegroups.com
There are a few issues that get a bit into why this is harder than it looks. I'll start you off at https://github.com/JuliaLang/julia/issues/5866, and you can see where things stand now over at https://github.com/JuliaLang/julia/issues/10610. If you search around (maybe here, maybe the dev list, don't recall exactly) I think there's at least one mailing list thread as well that has further discussion.

Tim Holy

unread,
May 3, 2015, 10:41:38 AM5/3/15
to julia...@googlegroups.com

Daniel Carrera

unread,
May 3, 2015, 1:06:33 PM5/3/15
to julia...@googlegroups.com
Thanks.

On 3 May 2015 at 16:17, Patrick O'Leary <patrick...@gmail.com> wrote:
There are a few issues that get a bit into why this is harder than it looks. I'll start you off at https://github.com/JuliaLang/julia/issues/5866, and you can see where things stand now over at https://github.com/JuliaLang/julia/issues/10610. If you search around (maybe here, maybe the dev list, don't recall exactly) I think there's at least one mailing list thread as well that has further discussion.



--
When an engineer says that something can't be done, it's a code phrase that means it's not fun to do.

Daniel Carrera

unread,
May 3, 2015, 1:08:46 PM5/3/15
to julia...@googlegroups.com
Hello Tim,

I appreciate the effort. I know about the Formatting module, but it does not provide printf() or sprintf() -- it only has sprintf1() which only takes 1 parameter -- and I am really not keen on using the Python formatting method. But thanks for the link.

Cheers,
Daniel.

Dominique Orban

unread,
May 3, 2015, 4:58:58 PM5/3/15
to julia...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages