[squeak-dev] Re: [Pharo-dev] chunk file format (unrecoverable changes)

Eliot Miranda eliot.miranda at gmail.com
Tue Sep 8 13:48:38 UTC 2015


Hi Nicolai,

On Mon, Sep 7, 2015 at 1:21 PM, Nicolai Hess <nicolaihess at web.de> wrote:

>
>
> 2015-09-07 20:10 GMT+02:00 Eliot Miranda <eliot.miranda at gmail.com>:
>
>>
>>
>> On Sun, Sep 6, 2015 at 12:56 PM, Nicolai Hess <nicolaihess at web.de> wrote:
>>
>>> Do we have a documentation about the format of
>>> - class definitions
>>> - methods
>>> - class comments
>>> for the changes file ?
>>>
>>
>>
>> Google "specification of smalltalk chunk format" and you will see:
>>
>> Overviews: Chunk File Format
>> <https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB8QFjAAahUKEwi25caEwuXHAhXNo4gKHTchAls&url=http%3A%2F%2Fwww.mimuw.edu.pl%2F~sl%2Fteaching%2F00_01%2FDelfin_EC%2FOverviews%2FChunkFileFormat.htm&usg=AFQjCNHOEmXwKdKmSJyT8fbhIuZbySOMUg&sig2=vV8q_t-VuMCJVzfl5UB7Bw>
>> Smalltalk Interchange Format - Draft Smalltalk Standard v1.9
>> <https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0CCUQFjABahUKEwi25caEwuXHAhXNo4gKHTchAls&url=http%3A%2F%2Fwww.math.rsu.ru%2Fsmalltalk%2Fstandard%2Fchapter4.html.en&usg=AFQjCNErBLKk5ii5-z0Y78vglNmR6EfptQ&sig2=Gs4qAQeeVblVgXaKJLW1uQ>
>> The Smalltalk fileOut format - 1
>> <https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&ved=0CCsQFjACahUKEwi25caEwuXHAhXNo4gKHTchAls&url=http%3A%2F%2Flive.exept.de%2Fdoc%2Fonline%2Fenglish%2Fprogramming%2FfileoutFormat.html&usg=AFQjCNEhzg6OFoLkIwmVAvuSuNU_u9L87w&sig2=_UzQF2Ns_Rwj-5RcXcvFFA>
>>
>> and more.
>>
>
>
> Thank you eliot
> (should have google that myself !)
>
>
>>
>>
>>>
>>> I am asking because some entries are using two separator
>>> "! !"
>>> and some only one
>>> "!"
>>>
>>
>> Indeed.  It's in the spec.  ! ! ends a run of methods in the same
>> protocol.  ! ends a method or a doit, etc.  Read the spec.
>>
>
> ah! grouping multiple methods for one protocol.
>

Forgive me, I don't mean to complain, but...  It's rather sad now I look at
it that the specification misses a very cool thing about the format.  Glenn
Krasner invented it and he's no dummy.  What the specs miss out is that the
syntax for a protocol is actually a general escape mechanism.  For example
in

!Object methodsFor: 'testing'!
isUnderstood
    ^false! !

the fileIn parser evaluates

    Object methodsFor: 'testing'

and then asks that object to scanFrom: the stream.  And the above answers a
ClassCategoryReader that reads chunks, compiling them and adding them to
the relevant category, until it finds an empty chunk (hence ! ! is not
special syntax, but actually a chunk followed by an empty chunk).

So one /could/, if one wanted, add another kind of reader, for example

!Preferences loadSavedPreferences!
beCool true!
beKnowledgeable true!
rememberOnersHistorytLestOneWishesToRepeatIt true! !

and have this not file in, but store preferences. I think that's neat, and
it's very sad that the ANSI standard did;t define this but reduced the
mechanism to support only protocols, and thence cause people to wonder why
the syntax was so weird, when in fact it was very simple and wonderfully
extensible.

Now I'm not blaming the standards process; the real problem here is that
the scheme wasn't documented other than by its implementation and so the
flexibility was never made apparent to the standardizers, and anyway they
wanted an interchange format, which is not what Squeak and Pharo chunk
readers provide; they provide an extensible format.  The ANSI standard
/could/ however have specified that the syntax is indeed extensible as
described, but that conforming implementations are only expected to provide
ClassCategoryReaders, and are expected to raise an error if given
expressions they don't recognize, or some such.

Also, given this history you can see why a single ! following a method
definition isn't seen anymore; we've put the stamp information in the
ClassCategoryreader so it can only parse a single method.  If we'd done
something like this (and I'm not suggesting that's a good idea)

!Object methodsFor: 'testing'!
[stamp: 'mad 01/04/2015 12:00']
isUnderstood
    ^#barely!

[stamp: 'mad 01/04/2015 12:01']
isMisunderstood
    ^#almostCertainly! !

we'd still see the single !'s after methods.

Two key points for me are
- specify carefully and visibly
- extensible standards are better than fixed standards

And we have a problem with the "Recover lost changes" browser
>>> (https://pharo.fogbugz.com/f/cases/16498/unrecoverable-changes)
>>> and I am not sure if this is a bug on the code importer
>>> or if it is a bug on how we write changes to the changes file.
>>>
>>
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20150908/c016ee41/attachment.htm


More information about the Squeak-dev mailing list