Abotu FileReference objects as autoevaluating ones

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

Abotu FileReference objects as autoevaluating ones

stepharo
about
https://pharo.fogbugz.com/f/cases/18956/FileReference-printString-should-be-auto-evaluable


'tmp/foo.txt' asFileReference
 >
File @ tmp/foo.txt

and it would be much much better to get back
'tmp/foo.txt' asFileReference

So that we can get
{ 'tmp/foo.txt' asFileReference }
 > { 'tmp/foo.txt' asFileReference }

and not
  "an Array(File @ tmp/foo.txt)"


In addition we should turn the current printOn: method into a
displayString method so that
a list of fileReference can be well display with File @ tmp/foo.txt for
example


Reply | Threaded
Open this post in threaded view
|

Re: Abotu FileReference objects as autoevaluating ones

Richard Sargent
Administrator
stepharo wrote
about
https://pharo.fogbugz.com/f/cases/18956/FileReference-printString-should-be-auto-evaluable


'tmp/foo.txt' asFileReference
 >
File @ tmp/foo.txt

and it would be much much better to get back
'tmp/foo.txt' asFileReference

So that we can get
{ 'tmp/foo.txt' asFileReference }
 > { 'tmp/foo.txt' asFileReference }

and not
  "an Array(File @ tmp/foo.txt)"


In addition we should turn the current printOn: method into a
displayString method so that
a list of fileReference can be well display with File @ tmp/foo.txt for
example
In many Smalltalk implementations, there are (at least) three behaviours for this kind of thing: #storeString, #printString, and #displayString. I would argue against conflating them.


Examples:
(I am not saying this is how each should work, just providing examples of how each might differ to suit the different constituencies for each one's use case.)

1) #displayString
'/directory/file' asFileReference displayString ==> '/directory/file'
'/directory' asFileReference displayString ==> '/directory/'

2) #storeString
'/directory/file' asFileReference storeString==> '/directory/file' asFileReference
'/directory' asFileReference storeString==> '/directory/' asFileReference

3) #printString
'/directory/file' asFileReference printString ==> FileReference(/directory/file)
'/directory' asFileReference printString ==> FileReference(/directory/)

Reply | Threaded
Open this post in threaded view
|

Re: Abotu FileReference objects as autoevaluating ones

Sean P. DeNigris
Administrator
Richard Sargent wrote
In many Smalltalk implementations, there are (at least) three behaviours for this kind of thing: #storeString, #printString, and #displayString. I would argue against conflating them.
+1. There was a reason we added the "File @" prefix (although I don't remember the details at the moment)
Cheers,
Sean