[Cuis-dev] Language constructs

Juan Vuletich juan at jvuletich.org
Fri May 1 07:41:25 PDT 2020


Hi Erik,

On 5/1/2020 4:45 AM, Erik Stel via Cuis-dev wrote:
> Maybe I wasn’t clear (because it was part of another topic, see below) 
> or tread on a sensitive subject, but I’m still eager to hear the 
> reasoning for having backticks (which are not in Squeak nor Pharo) 
> from the simplicity point of view. Would anyone care to elaborate?

Not from the simplicity point of view, but from the consistency one...

One of the nice properties of Smalltalk is that there is no special 
objects. Your objects are on par with what the system provides. (Compare 
with Java or C++ primitive types, etc). This is an ideal, but Smalltalk 
gets pretty close to it.

A literal is an object that is built by the Compiler when compiling the 
method. It is not created on method execution. It is a single instance 
that will be reused in every method invocation. In Smalltalk-80, 
literals can be Strings, Symbols, Integers, Floats and Arrays of these. 
But not Fractions. Or Points. Or instances of your own classes. All 
these require message sending to be created, each time. Backticks are a 
way to change that. So you can have literals of any class. In some cases 
it can improve performance or reduce memory usage. But the deeper reason 
is to put all classes in equal footing with those privileged ones that 
are known by the Compiler.

Many times the question 'what is the best option?' doesn't have an 
obvious answer, and it is about tradeoffs. The question is not 'what is 
the simplest option?' but 'does this complexity carry its own weight?' 
This is more difficult to answer!

> I am also eager to know what others think about language constructs 
> such as #(), {} and `` for daily usage. And I mean this in the sense 
> ‘Do you use these often? Could you live without them?’. I do 
> understand how they can be used and what their meaning is ;-). And I 
> can also lookup their current use in the default image, but that does 
> not answer how you/we use them in our (application) code.
>
> Kind regards,
> Erik

I use {} a lot. Not for modeling suff, but for example as a debugging 
aid.When trying to understand what some code does, I might insert a line 
like:
{ 'what is this stuff?'. someObject. 'and here...'. some message send } 
print.

I use #() for more system level code. For example the implementors of 
#is: . The reason here is efficiency.

I use `` for stuff that could be literals if we had syntax for them. 
Constant points are the obvious example. But there might be others. 
Perhaps `Float pi` is a good example. Why would 1.0 be a literal but 
Float pi needs to be evaluated every time? Doesn't make sense to me. 
Both are Float constants.

In other message you talk about Sets. Backticks means we don't need a 
specific syntax for Sets: `{ 1. 3. 5. 7. 11. 13} asSet` will do.

Cheers,

-- 
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/20200501/0b16e16f/attachment.htm>


More information about the Cuis-dev mailing list