Hi
I have a file /Users/ducasse/PharoMooc/Subtitles/W1/C019SD-W1-sous-titres-EN/EN_C019SD-W1-S1.srt and I would like to generate a new one with a different extension /Users/ducasse/PharoMooc/Subtitles/W1/C019SD-W1-sous-titres-EN/EN_C019SD-W1-S1.vtt Now I'm browsing FileReference and I do not find an easy way to do it. I had to peek and poke to get (self parent / self basenameWithoutExtension) withExtension: 'vtt' I analyse a bit why I was slow discovering it: I did not really find a nice way to obtain /Users/ducasse/PharoMooc/Subtitles/W1/C019SD-W1-sous-titres-EN/ or /Users/ducasse/PharoMooc/Subtitles/W1/C019SD-W1-sous-titres-EN/EN_C019SD-W1-S1 Proposal one: We could add withoutExtension withoutExtension ^ (self parent / self basenameWithoutExtension) Proposal two: We could add withoutBasename withoutBasename ^ self parent Proposal three: Not sure that it is worth (note that this is not a rename) withNewExtension: anExtension ^ self parent / self basenameWithoutExtension withExtension: anExtension So what do you think? Stef |
On Wed, Aug 17, 2016 at 9:44 PM, stepharo <[hidden email]> wrote: Hi Why not just myFile withExtension: 'vtt' e.g. f := '/tmp/file.txt' asFileReference. "File @ /tmp/file.txt" f withExtension: 'log' "File @ /tmp/file.log"
It's an AbstractFileReference method.
Why not just #parent? Some languages also use #dirname. /Users/ducasse/PharoMooc/Subti This one is the one hard to get… but how often do you need it? Is it worth the extra method in the API? If just for changing the extension, then there's #withExtension: Proposal one: What is the use case for this?
I don't see a point of this method, why not just use #parent? Proposal three: Is this somehow different than using #withExtension: directly? Peter |
Le 17/8/16 à 22:11, Peter Uhnák a
écrit :
If you see my code you will see that I could not guess that it was working on a fullpath. Of course since I did not add a proper comment to this method, there is none and learning is always more difficult. I really hate that we have to read and understand the implementation of a method to understand what is does. To get everything except the extension. Is it not obvious? How do you did it else? This is a helper. parent is good for navigation now withoutBasename is good for manipulation of parts. It took me a while to think that I should use parent because I was looking for something else. You convinced me this library is perfect and I will keep these extensions for me. It is the same. I will add a real comment to this method. I hate so much libraries that do not have comments (I'm fed up to lose my time documenting undocumented library). Since I stupidly wrote also the FS chapter I missed such scenario since I was exhausted to reverse engineer and comment. So now this is not in the documentation. Easy and revealing the poor coverage of our documentation. Obviously since I'm with Sven one of the few persons that seem concerned with such aspect. Now I will not work on documenting others code anymore.
|
On Thu, Aug 18, 2016 at 09:35:28AM +0200, stepharo wrote:
Just so you don't misunderstand… I am not opposing those changes, I am just asking. > > > > Proposal one: > > > > We could add withoutExtension > > > > withoutExtension > > > > ^ (self parent / self basenameWithoutExtension) > > > > > > What is the use case for this? > To get everything except the extension. Is it not obvious? > How do you did it else? What I mean is, when would you use such method? The only use case I can see (after using FS libs for years) is to change extension, but we already have a method for that. > > > Proposal two: > > > > We could add withoutBasename > > > > withoutBasename > > > > ^ self parent > > > > > > I don't see a point of this method, why not just use #parent? > This is a helper. > parent is good for navigation now withoutBasename is good for manipulation > of parts. > It took me a while to think that I should use parent because I was looking > for something else. So the problem then is a documentational one. > You convinced me this library is perfect and I will keep these extensions > for me. My point is, do we want to add every possible variation and helper for every use case a person can think of? I believe last year there was a lot of effort put into cleaning up String api; did String end up where it is with similar approach? I don't know, I haven't been here, that's why I am asking. Also in other languages it is common to use `dirname` instead of parent => "asking for the directory name of what you have". But as you point out in another thread, this is a documentational issue, and not a missing method. > > > > Proposal three: > > > > Not sure that it is worth > > > > (note that this is not a rename) > > > > withNewExtension: anExtension > > ^ self parent / self basenameWithoutExtension > > withExtension: anExtension > > > > > > Is this somehow different than using #withExtension: directly? > Obviously since I'm with Sven one of the few persons that seem concerned > with such aspect. Please, just so there is no misunderstanding. I do care about it and I am not fundamentally against it. You sent your proposals, I've added my view, and I expect other people will add theirs, so we can collectively discuss this and act on it. Peter |
>>> Proposal two:
No I do not want to read a pdf to get it.
>>> >>> We could add withoutBasename >>> >>> withoutBasename >>> >>> ^ self parent >>> >>> >>> I don't see a point of this method, why not just use #parent? >> This is a helper. >> parent is good for navigation now withoutBasename is good for manipulation >> of parts. >> It took me a while to think that I should use parent because I was looking >> for something else. > So the problem then is a documentational one. > >> You convinced me this library is perfect and I will keep these extensions >> for me. > My point is, do we want to add every possible variation and helper for every use case a person can think of? > I believe last year there was a lot of effort put into cleaning up String api; did String end up where it is with similar approach? I don't know, I haven't been here, that's why I am asking. > > Also in other languages it is common to use `dirname` instead of parent => "asking for the directory name of what you have". > > But as you point out in another thread, this is a documentational issue, and not a missing method. I do not want to be forced to read a doc to use a system. The system itself should be discoverable and it is not in this case. This is why I will not write documentation of others code anymore. >>> Proposal three: >>> >>> Not sure that it is worth >>> >>> (note that this is not a rename) >>> >>> withNewExtension: anExtension >>> ^ self parent / self basenameWithoutExtension >>> withExtension: anExtension >>> >>> >>> Is this somehow different than using #withExtension: directly? >> Obviously since I'm with Sven one of the few persons that seem concerned >> with such aspect. > Please, just so there is no misunderstanding. I do care about it and I am not fundamentally against it. > You sent your proposals, I've added my view, and I expect other people will add theirs, so we can collectively discuss this and act on it. You see I could have pushed this change without discussing. I can understand that proposal 3 is useless since this is the same. But the others have a value to me. Now I added them in my private extensions and this is good. > > Peter > > |
Free forum by Nabble | Edit this page |