Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Description of all the 4 padding functions in the wiki page is not cor (Read 4963 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.


 

Description of all the 4 padding functions in the wiki page is not cor

Reply #2
http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Title_Formatting_Reference#.24pad.28x.2Clen.29
I think the description as of now is not correct.

Change the description to something like (example):
$pad_right(x,len)
Pads x with spaces up to len characters so that x is aligned to the right.

And what exactly is incorrect?

Quote
$pad(x,len)
Pads x from the left with spaces to len characters.

$pad_right(x,len)
Pads x from the right with spaces to len characters.

$pad(x,len,char)
Pads x from the left with char to len characters.

$pad_right(x,len,char)
Pads x from the right with char to len characters.


The current descriptions describe how they work, which doesn't always help in explicitly explaining what they do, but your proposed change is ambiguous as to how and how is more important to someone learning title formatting IMNSHO.

The wording of the page is uniform. Each definition lends itself to understanding the other entries. If people edit it every time they misunderstand something, it will become an overly-worded, jumbled mess.

Description of all the 4 padding functions in the wiki page is not cor

Reply #3
And what exactly is incorrect?

Quote
$pad(x,len)
Pads x from the left with spaces to len characters.

$pad_right(x,len)
Pads x from the right with spaces to len characters.

$pad(x,len,char)
Pads x from the left with char to len characters.

$pad_right(x,len,char)
Pads x from the right with char to len characters.

The problem is that the descriptions are wrong. $pad(x,len) pads from the right (i.e. it adds spaces to the end of x), so that the result has minimum length len (i.e. it's left-aligned), and $pad_right(x,len) pads from the left (i.e. it adds spaces to the beginning of x), so that the result has minimum length len (i.e. it's right-aligned).
It's only audiophile if it's inconvenient.

Description of all the 4 padding functions in the wiki page is not cor

Reply #4
Edit the Wiki and append an example to each item . . . something like this should do the trick:

Quote
$pad(x,len)
Pads x from the left with spaces to len characters. Example: $pad(x,3) → "x<space><space>"

$pad_right(x,len)
Pads x from the right with spaces to len characters. Example: $pad_right(x,3) → "<space><space>x"

$pad(x,len,char)
Pads x from the left with char to len characters. Example: $pad(x,3,y) → "xyy"

$pad_right(x,len,char)
Pads x from the right with char to len characters. Example: $pad_right(x,3,y) → "yyx"

Description of all the 4 padding functions in the wiki page is not cor

Reply #5
The problem is that the descriptions are wrong.


Again, let's not confuse how they work and what they do.

$pad(x,len) counts len from the left of x (i.e. how) and adds up to len spaces to the right (i.e. what) of x.

$pad_right(x,len) counts len from the right of x (i.e. how) and adds up to len spaces to the left (i.e. what) of x.

Description of all the 4 padding functions in the wiki page is not cor

Reply #6
I think we could discuss whether the descriptions are wrong or right or we could see this discussion as a sign that the descriptions are at least ambiguous. I therefore agree they should be replaced with a clearer version. My suggestion is this:
Quote
$pad(x,len) creates a left-aligned version of the string x. If x is shorter than len characters, the function adds spaces to the right of x to make the result len characters long. Otherwise the function returns x unchanged.

Description of all the 4 padding functions in the wiki page is not cor

Reply #7
Again, let's not confuse how they work and what they do.
I'm still confused what you are trying to say. Your suggestions are semantically different from the ones in the wiki, the ones I quoted from the wiki are still simply wrong. They don't describe what happens and they don't describe how the functions work.

I think we could discuss whether the descriptions are wrong or right or we could see this discussion as a sign that the descriptions are at least ambiguous. I therefore agree they should be replaced with a clearer version. My suggestion is this:
Quote
$pad(x,len) creates a left-aligned version of the string x. If x is shorter than len characters, the function adds spaces to the right of x to make the result len characters long. Otherwise the function returns x unchanged.

I changed the title formatting page entries accordingly. Good suggestion.
It's only audiophile if it's inconvenient.

Description of all the 4 padding functions in the wiki page is not cor

Reply #8
I had a look at the Wiki page . . . . and scratched my chin for a while . . . . Sorry, I do not like it!

It is as bad as before but in another sense!
It is unecessarily verbose in a dry technical way and it STILL has an element of confusion ...reminiscent of perplexing legal documents.
The fact of of the matter is that the English language is written from left to right, and every computer user know this.

$pad(x,len) has an obviousness about it which requires nothing more than a few words to describe it.
$pad_right(x,len) if you think about it, is also obvious and relative to the previous function.

IMHO, as a quick clear reference, this would have been a much better change to the Wiki:
Quote
$pad(x,len)
Pads x, appending spaces to len characters.  Example: $pad(x,3) → "x<space><space>"

$pad_right(x,len)
Pads x, prefixing spaces to len characters.  Example: $pad_right(x,3) → "<space><space>x"

$pad(x,len,char)
Pads x, appending chars to len characters.  Example: $pad(x,3,y) → "xyy"

$pad_right(x,len,char)
Pads x, prefixing chars to len characters.  Example: $pad_right(x,3,y) → "yyx"


Description of all the 4 padding functions in the wiki page is not cor

Reply #9
I had a look at the Wiki page . . . . and scratched my chin for a while . . . . Sorry, I do not like it!
Your opinion has been logged.

Quote
It is as bad as before but in another sense!
It is unecessarily verbose in a dry technical way and it STILL has an element of confusion ...reminiscent of perplexing legal documents.
I disagree. I think it makes sure to provide plenty of information so that there is no room for ambiguity.

And I think your suggestions are too brief, do not distinguish between placeholders and words with actual meaning, and do not sufficiently describe the functions for users who do not know the relevant meanings of words like pad.

Quote
The fact of of the matter is that the English language is written from left to right, and every computer user know this.
What do computers have to do with it? Language is not an immutable substance. It can, and should, be bent so as to enable the best descriptions and so forth of the subject at hand. If that means there end up being more words than you personally like, then so be it.

Score my vote as being firmly in favour of what is currently on the page, at least if we compare it to these new suggestions.

Description of all the 4 padding functions in the wiki page is not cor

Reply #10
>> ...are too brief, do not distinguish between placeholders and words with actual meaning...

I disagree with your assessment. Anybody looking at that page knows what "x" can be ...it is obvious to anybody with half a brain.

>> ...users who do not know the relevant meanings of words like pad.

similar answer.

Can anybody reading this topic tell me something . . .
if you read my edition at the Wiki page would you be left scratching your head wanting more information? (I doubt it very much).

Description of all the 4 padding functions in the wiki page is not cor

Reply #11
It is somewhat wordy. It could "shortened" to something like:
Quote
Adds spaces to the right of x to make the result len characters long if x is shorter than len characters, otherwise returns x unchanged.


I don't know about this bit:
Quote
creates a left-aligned version of the string x

as that isn't entirely accurate.  It really depends on where/how it's used. I suppose one could add something like:
Quote
Typically used to align text on its left that would otherwise be flush right.


EDIT: left-align isn't a verb, derp

Description of all the 4 padding functions in the wiki page is not cor

Reply #12
Score my vote (like @db1989 vote) as being in favor of @Kohlrabi wiki update (@foosion's suggestion) which is currently on the page.

I think that we all agree that the descriptions of these functions could have been shorter and this discussion would not exist if the author of these 4 functions used better names for them.
For example - $pad_right should have been called $pad_left (because it pads spaces from the LEFT of x).

Obviously, what was done can't be reversed...

Description of all the 4 padding functions in the wiki page is not cor

Reply #13
LL25255252 - No, I do not agree with your opinion that the author of the function names 'got it wrong' and should have named them 'better'.
The function names translate in a clear literal way if one bothers engaging with nothing more than a drop of logic.

$pad(x...           is self-explanatory; it is saying PAD X.
$pad_right(x..    is self-explanatory; it is saying PAD X TO THE RIGHT.

To anybody with half a brain and just a basic grasp of the English language, this is all plainly obvious.

This whole topic is a storm in a teacup. The only 'mistake' the original author made was using slightly vague wording in his descriptions. My edition solved this by using the words "prefix" and "append". With those words all ambiguity is removed. I also added a example to clarify any doubt. My edition kept to the spirit of the original author .....briefness.

This new edit is verbose pedantic legal-speak and makes a big complex deal out of something simple. It is logic gone mad.
The original edit was short ans sweet, but needed minor update of words used for the definition.

Description of all the 4 padding functions in the wiki page is not cor

Reply #14
Quote
$pad_right should have been called $pad_left
Agreed.

My take:
Quote
$pad(x,len[,char])
Pads (adds characters to) the right side of the input string. If len is shorter than the length of x, the function returns x unchanged. Note that the third argument is optional: if it is not provided, a blank space will be used as the default padding character. Examples:
$pad(%tracknumber%,3,-) → "01-"

$pad_right(x,len[,char])
Pads (adds characters to) the left side of the input string. If len is shorter than the length of x, the function returns x unchanged. Note that the third argument is optional: if it is not provided, a blank space will be used as the default padding character. Examples:
$pad_right(%tracknumber%,3,-) → "-01"
Alessandro

Description of all the 4 padding functions in the wiki page is not cor

Reply #15
I also noticed that specifying a negative len produces weird results. Not sure if it's a bug or the intended behaviour: if the latter perhaps it should be documented.

Alessandro

Description of all the 4 padding functions in the wiki page is not cor

Reply #16
This whole topic is a storm in a teacup. The only 'mistake' the original author made was using slightly vague wording in his descriptions.
The original description was simply wrong. Whether the new verbose one should be preferred over a more concise one I will not decide on my own, but the current one is at least correct, which is an improvement.
It's only audiophile if it's inconvenient.