[squeak-dev] Shadowing Considered Useful (was Re: Shadows (was: The Trunk: Morphic-eem.1742.mcz))
Tony Garnock-Jones
tonyg at leastfixedpoint.com
Mon Apr 19 08:54:21 UTC 2021
On 4/19/21 10:47 AM, Marcel Taeumel wrote:
> Hmm.... I wonder if that would be actually a "big hammer" or just an
> indication that you favor larger pieces of code (i.e. long methods) over
> short ones. In modules composed of many short(-ish) methods, I tend to
> focus on object messaging and higher-level control flow. There, I do not
> think about lexical scoping as an important design element.
Yeah. Note that this code is the output of a code generator that avoids
the need for most user-visible explicit references to thisTurn. User
code would be shorter and simpler, something like
spawn: [
assert: (Presence new userName: 'me').
assert: (Observe new
label: #Presence;
observer: (
onAsserted: [:p :handle | ...];
onRetracted: [:handle | ...]))]
And it's still an open (research) question as to whether Smalltalk is
well-suited to this style of programming at all. Overuse of blocks
(especially blocks as state, i.e. callbacks!) makes for poor integration
with tooling and bad interactions with edits to methods. In a parallel
track I'm trying to figure out a way of avoiding blocks and using
methods more (that is, trying to find a different way of expressing my
DSL that fits better with Smalltalk as-is).
I'd still want to hide thisTurn where possible though, just like
thisContext is hidden.
> In Vivide, I use DynamicVariable to scope relevant domain objects (i.e.
> active vivide, active profile, active organization, active script, ...). :-)
Ah! Thanks, I'll check that out, see if I can take inspiration from it!
Regards,
Tony
More information about the Squeak-dev
mailing list
|