On 9/8/2015 8:48 AM, Eliot Miranda wrote:
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.
Dolphin uses it to define class and method categories:
!MyClass categoriesFor: #myMethod!accessing!public! !
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,
I think the flexibility was likely known as most (all?) other
implementations at the time did it the same way and Glenn Krasner was
the Vice-Chairman of the committee. However, I think some on the
committee wanted a purely declarative Smalltalk so you couldn't have
anything in the file that evaluated code.
and anyway
they wanted an interchange format, which is not what Squeak and Pharo
chunk readers provide; they provide an extensible format.
Pharo no longer provides an extensible format. I tried to file in some
Dolphin code and instead of defining a few different methods that
returned chunk readers (i.e., methodsFor, categoriesForClass,
categoriesFor:), I had to modify the
ChunkFileFormatParser>>parseNextDeclaration method. This method has hard
coded the different chunk types it accepts.
John Brant