[squeak-dev] DynamicObjects

Fabio Niephaus lists at fniephaus.com
Mon Apr 27 07:21:53 UTC 2020


Instead of DynamicObject, couldn't you just introduce a very slim subclass
of Dictionary, because such objects are really just dictionaries? I'm
assuming you're just redirecting calls via DNU anyway? Something like a
MessageDictionary or DispatchingDictionary maybe?

Fabio

On Mon, 27 Apr 2020 at 9:05 am, Marcel Taeumel <marcel.taeumel at hpi.de>
wrote:

> Hi Christoph.
>
> > And you should *really* only use this in tests :-)
>
> Then, as a first step, re-design (and re-name) DynamicObject to not be
> confused with other use cases. What about mapping the idea of Dictionary
> class >> #newFrom: to Class or ClassDescription? Make it easier to
> add/remove methods to/from classes in scripts and tests.
>
> Best,
> Marcel
>
> Am 26.04.2020 20:10:15 schrieb Thiede, Christoph <
> christoph.thiede at student.hpi.uni-potsdam.de>:
>
> I agree with all your comments about confusion.
>
> Still, there is one thing you could do with this approach of
> "DynamicObjects" which our usual meta protocol does not support afaik:
>
>
> d := DynamicObject withMethods: {
>     'somePrefix*' -> [:sel | sel allButFirst: 'somePrefix' size].
>     'selector(Regex)+' asRegex -> [:match | match size - 'selector' size /
> 'Regex' size]
> } asDictionary.
> d somePrefixBanana. "'Banana'"
> d selectorRegexRegexRegex. "3"
>
>
> And you should *really* only use this in tests :-)
>
> @Torge: Interesting point. I could only find a ReverseTrampoline
> <http://www.metaobject.com/downloads/Squeak/HOM.cs> (by googling for
> smalltalk "subclass trampoline"). :-)
>
> Best,
> Christoph
>
> ------------------------------
> *Von:* Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im
> Auftrag von Taeumel, Marcel
> *Gesendet:* Montag, 20. April 2020 11:03 Uhr
> *An:* gettimothy via Squeak-dev
> *Betreff:* Re: [squeak-dev] DynamicObjects
>
> Uhh! This feels like JavaScript ... :o) I would rather work on improving
> Squeak's meta-object protocol and with it class construction and
> refinement. Especially for tests. Let's not undermine the idea of having
> classes in Smalltalk.
>
> -1 for DynamicObject.
>
> Objects in Squeak/Smalltalk are quite dynamic already. That name is
> misleading. :-)
>
> Best,
> Marcel
>
> Am 18.04.2020 19:55:05 schrieb Thiede, Christoph <
> christoph.thiede at student.hpi.uni-potsdam.de>:
>
> d := DynamicObject withMethods: {
>
> #origin -> [2 @ 3].
>
> #corner -> [3 @ 7] } asDictionary.
>
> d origin "2 at 3"
>
>
> Did we already have something like this for Squeak? May this become a
> pattern for situations where you actually don't need a class (e. g., when
> writing very small mock objects for tests)?
>
>
> d := DynamicObject new.
>
> d xxxMethodAt: #foo put: [self inform: 'Hi!'].
>
> d xxxMethodAt: #foo: put: [:x | x halt].
>
> d foo: 3.
>
>
> Best,
> Christoph
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200427/004fd36a/attachment.html>


More information about the Squeak-dev mailing list