<div dir="auto">I think that ##(2@3) notation of Dolphin (compile time literal send) or [2@3] once of Visualworks by Travis Griggs did solve the same problem, so it means that there is a demand for it. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mar. 10 sept. 2019 à 12:59, Juan Vuletich via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st">cuis-dev@lists.cuis.st</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Some time ago, Phil didn't like (neither do I) that we say stuff like 'a <br>
:= 2@3', 'a := Float pi', or 'a := { blah. blah. blah}', we are calling <br>
instance creation methods all the time, and allocating new objects that <br>
won't be modified. But not when we do 'a := 7.0' or 'a := #(1 2 3)', <br>
because in these cases the objects are created at compile time. I came <br>
up with the backtick idea and implemented it in Cuis. It is a rather <br>
nice addition, other Smalltalks could follow.<br>
<br>
For Philip, (and weak references in general) making these 'literals' <br>
true literals means that the CompiledMethod will hold a strong reference <br>
to them, so they won't vanish when needed.<br>
<br>
Someway related to this is that all that literal objects should be <br>
immutable. This was not done yet, but we'd do it some day.<br>
<br>
Cheers,<br>
<br>
-- <br>
Juan Vuletich<br>
<a href="http://www.cuis-smalltalk.org" rel="noreferrer noreferrer" target="_blank">www.cuis-smalltalk.org</a><br>
<a href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev" rel="noreferrer noreferrer" target="_blank">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a><br>
<a href="https://github.com/jvuletich" rel="noreferrer noreferrer" target="_blank">https://github.com/jvuletich</a><br>
<a href="https://www.linkedin.com/in/juan-vuletich-75611b3" rel="noreferrer noreferrer" target="_blank">https://www.linkedin.com/in/juan-vuletich-75611b3</a><br>
@JuanVuletich<br>
<br>
<br>
On 9/9/2019 10:43 PM, Casey Ransberger via Cuis-dev wrote:<br>
> Hey Juan, is the backticks thing specific to Cuis, or is this yet another magic feature of Smalltalk that I didn’t know about?<br>
><br>
> —Casey<br>
><br>
>> On Sep 9, 2019, at 6:04 AM, Juan Vuletich via Cuis-dev<<a href="mailto:cuis-dev@lists.cuis.st" target="_blank" rel="noreferrer">cuis-dev@lists.cuis.st</a>> wrote:<br>
>><br>
>>> On 9/9/2019 3:17 AM, Philip Bernhart via Cuis-dev wrote:<br>
>>> Hello,<br>
>>><br>
>>> I noticed that when I register events with when:send:to:with: with collections<br>
>>> as the with: paramater the contents of the collection the collection<br>
>>> becomes nil on the actually triggered event. Maybe that has something<br>
>>> todo with WeakMessageSend. Anyway an example tells better what I mean:<br>
>>><br>
>>><br>
>>> browserMorph<br>
>>> setProperty: #editItemAction<br>
>>> toValue: [:repository :record|<br>
>>> | flashcardMorph card mapping |<br>
>>> flashcardMorph _ FlashcardMorph new.<br>
>>> card _ Flashcard new.<br>
>>> card question: (record at: #question ifAbsent: '').<br>
>>> card answer: (record at: #answer ifAbsent: '').<br>
>>><br>
>>> card when: #changed<br>
>>> send: #saveRecordMappingWith:<br>
>>> to: browser<br>
>>> with: {card. record}.<br>
>>><br>
>>> flashcardMorph model: card.<br>
>>> flashcardMorph showAnswer.<br>
>>> flashcardMorph enableEditing.<br>
>>> flashcardMorph openInWorld ].<br>
>>><br>
>>> Then in Flashcard there is a foo method which does:<br>
>>> self triggerEvent: #changed.<br>
>>><br>
>>> Here the {card. record} becomes for some reason (weak reference?) nil<br>
>>> and causes that the event isn't triggered. So #saveRecordMappingWith:<br>
>>> isn't called.<br>
>>><br>
>>> With simple datatypes like Integers this works, with static arrays this<br>
>>> seems to work too.<br>
>>><br>
>>> Maybe this style of doing that isn't the right one, maybe I'm using the<br>
>>> event system for things which it wasn't supposed to do.<br>
>>><br>
>>> Suggestions?<br>
>>><br>
>>><br>
>>> Thanks for your time,<br>
>>> Philip<br>
>> Hi Philip,<br>
>><br>
>> I believe the event system uses WeakMessageSend in all Smalltalk dialects. Folks, please correct me if I'm wrong.<br>
>><br>
>> An easy way to fix the problem is to turn your collection into a literal, using backticks:<br>
>><br>
>> card when: #changed<br>
>> send: #saveRecordMappingWith:<br>
>> to: browser<br>
>> with: `{card. record}`.<br>
>><br>
>><br>
>> Cheers,<br>
>><br>
>> -- <br>
>> Juan Vuletich<br>
>> <a href="http://www.cuis-smalltalk.org" rel="noreferrer noreferrer" target="_blank">www.cuis-smalltalk.org</a><br>
>> <a href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev" rel="noreferrer noreferrer" target="_blank">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a><br>
>> <a href="https://github.com/jvuletich" rel="noreferrer noreferrer" target="_blank">https://github.com/jvuletich</a><br>
>> <a href="https://www.linkedin.com/in/juan-vuletich-75611b3" rel="noreferrer noreferrer" target="_blank">https://www.linkedin.com/in/juan-vuletich-75611b3</a><br>
>> @JuanVuletich<br>
>><br>
>> -- <br>
>> Cuis-dev mailing list<br>
>> <a href="mailto:Cuis-dev@lists.cuis.st" target="_blank" rel="noreferrer">Cuis-dev@lists.cuis.st</a><br>
>> <a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
<br>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank" rel="noreferrer">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div>