Java's modules rock? (was Re: election details *PLEASE READ*)

Andrew Tween amtween at hotmail.com
Sun Mar 11 23:20:45 UTC 2007


Hi all,
Since Shout has been mentioned, I'll jump in here.

>----- Original Message ----- 
>From: "Andreas Raab" <andreas.raab at gmx.de>


> Lex Spoon wrote:
> > Yes, that is fair generalization.  I would like the default module
> > format to allow unanticipated reuse.  Just look at the packages
> > Squeakers post for each other, and you will see all kinds of things
> > that modify the system.  How could you write something like Shout if a
> > module cannot change the system text editor?

This is slightly ambiguous, do you (Lex) mean...
Switch the system text editor to an alternative system text editor?
Or modify the code of the existing system text editor?

>
> Err, by refactoring it in a way so that you can? We have already various
> abstractions (AppRegistry) and there is nothing wrong to have one that
> allows for syntax highlighting - with a common protocol that allows
> other clients to hook into it, instead of hacking the system text editor
> directly.

When installled, Shout registers PluggableShoutMorph as the default
MorphicTextEditor under AppRegistry.
PluggableShoutMorph has a 'styler' instance variable which holds an
SHTextStylerST80. When the text changes, the styler is instructed to parse, and
style, the Text.

Now, if the styler instance variable were in PluggableTextMorph (or higher), any
alternative syntax highlighter could be plugged in. It would just need to
implement the public interface of SHTextStylerST80...
    #style: <Text>
    #styleInBackgroundProcess:<Text>
    #format: <Text>
    #unstyledTextFrom: <Text>
.. and PluggableTextMorph would need to include the hacks (!?) from
PluggableShoutMorph to update its contents from the re-styled Text.

> Coincidentally, this is *precisely* what I referred to earlier
> wrt. explicit vs. implicit interactions. As it stands, loading an
> alternative syntax highlighter will (almost necessarily) clash with
> shout;

Not if it registers itself as the default (or an alternative) MorphicTextEditor.
Or, uses Shout, but implements an alternative to SHTextStylerST80.

(Incidently, I think it would be good to have a MorphicCodeEditor in addition to
MorphicTextEditor).

> with that interface both modules could use the same ground rules,
> could be loaded side by side and could be activated depending on the
> context you need them in.

Yes, that would be good.

Cheers,
Andy




More information about the Squeak-dev mailing list