file truncate
Brian T. Rice
water at tunes.org
Thu Jul 29 19:45:56 PDT 2004
Lendvai Attila wrote:
> and currently the vm generation only works if there is a vm.c/h.
> therefore there's a withNewNamed:do: in the patch, too.
I didn't like this solution (which means I don't like withOpenNamed:do:,
really), so I cooked up my changes to make File access more Flow-style
(well, okay, Flow hasn't ever done this, but it seems like what Craig
Latta would do if he were involved in Slate at all).
What I'm about to commit will make:
Mode objects, to have persistent #open parameters on the File objects
themselves.
E.g.: File Read, File Write, File ReadWrite, File CreateWrite (all as
slots on the traits object)
"File newNamed: &mode:" makes a new File object (with a given mode or
the same as default / first argument), and does NOT open it.
This means that you can grab some File object, and repeatedly call #open
and #close on it consistently, even across image-saves (which is where
you want some automation for it anyway).
So, to replace this method, sessionDo: takes an ExternalResource (not
just a File) and runs:
r@(ExternalResource traits) sessionDo: block
"Calls the block with the resource object as input, opening and closing
it transparently in an error-tolerant way. The return value of the block
is answered if it completes without error."
[
[r open.
block applyWith: r]
ensure: [r isOpen ifTrue: [r commit. r close]]
].
This is even simpler than withOpenNamed:do: and avoids the "did the code
fail creating the object in the first place?" uncertainty. In fact you
can implement with- with sessionDo:.
Unfortunately, it'll take an image rebuild to incorporate these changes,
as far as I can tell. At least, this is the case for a lot of code
critical to the image operation until forwardTo: usage is standardized
into things like addPrototype:derivedFrom:.
PS: Also, I finally am changing atEnd to isAtEnd, as requested some
months ago.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: water.vcf
Type: text/x-vcard
Size: 208 bytes
Desc: not available
Url : /archives/slate/attachments/20040729/72f1f891/water.vcf
More information about the Slate
mailing list