FSReference

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

FSReference

Sean P. DeNigris
Administrator
I'm really enjoying FS (I couldn't wait so I loaded it into 1.3-rc; all working so far).

I keep finding myself writing things like:

FSReference>>doSomething "double dispatch extension method"
  self isDirectory
    ifTrue: [ ... ]
    ifFalse: [ ... ].

I feel dirty every time, but FS doesn't make this piece of a reference's identity explicit. Would it be valuable to have FSFileReference and FSDirectoryReference subclasses? It would certainly make my code cleaner as I could then double dispatch without conditionals.

Thanks.
Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: FSReference

Sean P. DeNigris
Administrator
Sean P. DeNigris wrote
Would it be valuable to have FSFileReference and FSDirectoryReference subclasses?
Another weird ramification of FSReference's identity ambiguity is, on a reference to an existing file:
* #allChildren -> anArray containing only the file itself
* children -> an error
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: FSReference

Sean P. DeNigris
Administrator
In reply to this post by Sean P. DeNigris
More ugly conditionals from inside the FS library...

(self exists: path)
                                ifTrue: [
                                        (self isFile: path)
                                                ifTrue: [ self signalFileExists: path ]
                                                ifFalse: [ self signalDirectoryExists: path ] ].
                        (self isDirectory: parent)
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: FSReference

Stéphane Ducasse
In reply to this post by Sean P. DeNigris
we should record what you find so that we can fix it.


On Nov 3, 2011, at 2:25 PM, Sean P. DeNigris wrote:

>
> Sean P. DeNigris wrote:
>>
>> Would it be valuable to have FSFileReference and FSDirectoryReference
>> subclasses?
>>
>
> Another weird ramification of FSReference's identity ambiguity is, on a
> reference to an existing file:
> * #allChildren -> anArray containing only the file itself
> * children -> an error
>
> --
> View this message in context: http://forum.world.st/FSReference-tp3985640p3985818.html
> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
>