-
Notifications
You must be signed in to change notification settings - Fork 23
RFC: Adding a sfmt simple format function #8
Comments
Sorry for the delayed response, Scott. I come from the perspective where there are a few very common things to do, and those should be as easy as possible:
I also feel like it should be clear (just by reading the code) what the operation is doing. So As an exercise, lets try out some possible method calls and the resulting string that we would expect:
If there is no ambiguity in arguments (by mixing ints, symbols, and keyword args) then we can support arbitrary reordering of arguments as well as default values. As well we could keep global defaults that can be changed by the user like:
|
@tbreloff I think there are already, in the very nice |
I agree that the major functionality is already there... this RFC is just to specify a nicer way to call it. Remember that the I would prefer to split |
Actually the memoization already happens (see |
Splitting them up into C-like, Python-like, and best practices Julian way sounds like a great idea, as well as doing memoization. Thanks for all the great ideas! (Are you able to do some work on them yourself? 😀 I'm just doing stuff as I find I need it...) |
Yes I can do some of this, however my use-case is limited to technical applications in the US. Maybe I'll fork and make a first pass at this, then ask for comments on julia-users? |
Sounds good! Which are you mostly interested in working on, the |
My goal is to be as julian as possible. I only really care about the |
Also regarding the existence of |
Hehe... yes, I agree about the horror... why else do you think I'm so active with Julia, which I only discovered 3 months ago 😀? |
The one thing I dislike about the current |
Agreed... I would like the option of doing something like:
This particular example might not be a big win, but it could be nice for more complicated stuff. |
Ok I threw together a preview in my fork: https://github.com/tbreloff/Formatting.jl/tree/tom_fmt This doesn't touch the python formatting or formatting more complex strings... it's only for formatting individual values right now. Here's a sample of how you use it:
Note the use of symbols also could let us set "themes"... for example I could see doing:
I'm looking forward to comments... |
I like, I like! 👍 |
see pull request #10 |
I had an idea to add a simple formatter, which could have different methods for different types of values:
sfmt( value [, format [, format arguments] ] )
The reason to have the value first, is that you could have methods added to have a default format for specific types.
For example, the C
sprintf(buf, “%*s”, 8, string)
would become something like:sfmt( string, “*s”, 8)
I realize this duplicates functionality already present, it is just an attempt to make the syntax simpler and easier to use... (note: I'd originally suggested naming it
fmt
, before I found out thatFormatting.jl
already had a function with that name... unfortunately, at least in the case offmt(string, string)
, it would be ambiguous).The text was updated successfully, but these errors were encountered: