On 09 Jul 2016, at 15:31, Esteban Lorenzano <estebanlm@gmail.com> wrote:
it is not inconsistent, last option is incorrect and should not be used.
yes - I believe as well that we discussed this some time ago ...
what you do there is to declare: directory âtmp', file âa/b/c.txtâ is casual that it coincides with a real path, but it is not semantically correct, thatâs why x ~= z
there was an issue around to explicitly forbid to declare a file like that, but I was (and still am) not sure it should be forbidden⦠is not the spirit of smalltalk⦠you know, great power/great responsibility thing :)
but it causes confusions (as this one), so at least needs to be correctly explained somewhere :)
cheers, Esteban
On 09 Jul 2016, at 13:11, Peter Uhnák <i.uhnak@gmail.com> wrote:
Imagine that you have
'/tmp/a/b' folder containing 'c' file
'/tmp/a/b' asFileReference ensureCreateDirectory. '/tmp/a/b/c' asFileReference writeStreamDo: [ :s | s nextPutAll: 'contents' ].
now there are three ways how you can see the contents of the c file
x := '/tmp/a/b/c.txt' asFileReference. y := '/tmp' asFileReference / 'a' / 'b' / 'c.txt'. z := '/tmp' asFileReference / 'a/b/c.txt'.
They clearly all point to the same file:
x contents = y contents "true" x contents = z contents "true"
Yet the last option is different
x = y "true" x = z "false"
Why is that? Because the parent is different:
x parent pathString "'/tmp/a/b'" y parent pathString "'/tmp/a/b'" z parent pathString "'/tmp'"
So the parent is based on how the reference was constructed, not what it is actually pointing to, which is stupid.
Is this a bug? Is this a (nasty) expected behavior?
Peter