pharo-vcs / tonel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TonelReader should offer a super simple API to load one single file!!!!

Ducasse opened this issue · comments

The current on:fileName: API is bad. We should be able to do

(TonelReader new filenamed: 'ffo.st') loadDefinitions.

I should be super stupid.... I cannot make this reader working.
The API is plain bad.
Why I cannot simply say

TonelReader loadFileName: 'Comix/SeriePrinter.class.st'

I have a folder with my files and none of the expressions below work.

TonelReader
on: (FileSystem workingDirectory / 'Comix') asFileReference
fileName: 'SeriePrinter.class.st'

TonelReader
on: 'Comix' asFileReference
fileName: 'SeriePrinter.class.st'

This also raises uncomprehensible errors:

(TonelReader
on: 'Comix' asFileReference
fileName: 'SeriePrinter.class.st') loadDefinitions

Telling that the directory does not exist! Of course this is a file that I pass.
So to me this API REALLY sucks.

At the end I will have lost 3 hours and feel like shit and forced to do everything by hand.
Or hack the reader which I do not want to do.

This is because you are trying to use it in a different way as it was meant for. TonelReader is a special kind of Monticello reader, hence it was meant to read packages, not classes.
And the API is inherited from Monticello.

In your case, if you do:

(TonelReader
    on: '.' asFileReference
    fileName: 'Comix') 
    loadDefinitions

it will work as expected (loading the definitions of the full "Comix" package).

This does not means we should not expand the API to allow simple file-in/file-out of classes (and even methods), but well... we need to implement it, since the original purpose of Tonel was not exactly that.

Ok I understand now.
You should think that Tonel will be in the future the default format for Pharo source
so it should be really easy to use. And you should add this to the class comment.

Tonel is realllllly important. I was waiting for it since 2002.

Esteban if fileName: was packageName: then it would be a lot clearer.

(TonelReader
onFolder: '.' asFileReference
package: 'Comix')
loadDefinitions

yes, we should add that api (but not rename the other, since is needed for compatibility with monticello)

Ok even better. This MC API sucks :)