[Cuis-dev] Fwd: Language constructs

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Sat May 9 02:39:03 PDT 2020


Sorry, this was for public discussion, I often forget to check reply all...

---------- Forwarded message ---------
De : Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>
Date: sam. 9 mai 2020 à 11:36
Subject: Re: [Cuis-dev] Language constructs
To: Juan Vuletich <juan at jvuletich.org>


Le mer. 6 mai 2020 à 16:22, Juan Vuletich <juan at jvuletich.org> a écrit :

> On 5/1/2020 12:53 PM, Nicolas Cellier via Cuis-dev wrote:
> > For myself, I find the { } syntax very short and useful. I use it a
> > lot even if it reduces a bit portability.
> > Also note that the construct is supported by dedicated byteCodes.
> >
> > I like the Float64Array extension #[ 1.0 3.5 ], maybe it should be
> > generalized in Squeak/Pharo.
>
> Yes!
>
> > But we should also optimize the class with same set as primitives as
> > FloatArray, which is IMO even more useful.
>
> I agree that having the FloatArrays primitives would be great.
> Especially #floatAt: and #floatAt:put:, the simplest ones.
>
> > Note the alternative to backticks that can be used in Squeak: ^[ 0 at 0 ]
> > once.
> > It does not require a new syntax, just an elegant trick.
> > But it costs 3 message send and 2 Dictionary lookup at runtime though...
> > With pre-existing Dolphin ##( 0 at 0 ) we now have at least 2 syntaxes
> > and 3 ways to achieve the same effect in Smalltalk, which is not ideal...
> >
> > I would vote for immutability of all literals including backticks.
> > That's the least surprising.
> > Otherwise, if you mutate the literal, then the code shows a non
> > corresponding value, which is misleading.
>
> I completely agree. Do you know what is the status of immutability in
> Squeak and Pharo? Wasn't the VM work done by Clement a few years ago?
>
>
Yes, the VM work has been accomplished for some time now.
Literal immutability supported by VM primitives has been introduced very
recently in Squeak trunk (post the 5.3 release).
We had relatively few hickups with the existing code base, so good news,
Squeak mostly do not depend on literal mutability, I would be amazed if it
were different in Cuis - I expect cleaner, or at least much more controlled
code in Cuis :)

See #setIsReadOnlyObject: (primitive 164) and senders (there are few,
mostly Encoder>>#setReadOnlyIfAppropriate:).
Concerning Pharo, I did not check for a while.

> The first time I was bitten with this was in st80 in the late eighties...
> > I discovered that I could write (WriteStream on: 'some literal') which
> > was much shorter than (WriteStream on String new; nextPutAll: 'same
> > literal'; yourself).
> > But WriteStream did use a become: under the hood when writing past the
> > destination size, and as a newbie, it tooks me some time to understand
> > why my nicer code would not give the expected result twice :)
> >
>
> Yes... Immutable literals would be great.
>
> Thanks,
>
> --
> Juan Vuletich
> www.cuis-smalltalk.org
> https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
> https://github.com/jvuletich
> https://www.linkedin.com/in/juan-vuletich-75611b3
> @JuanVuletich
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20200509/b3eeda4b/attachment.htm>


More information about the Cuis-dev mailing list