[Cuis-dev] Naming conventions

Juan Vuletich juan at jvuletich.org
Tue Apr 28 06:52:08 PDT 2020


On 4/28/2020 1:16 AM, Luciano Notarfrancesco wrote:
> Sounds great! But the convention
>     `PackageName1@#ClassName` new
> looks a bit ugly to me, how about using upper case messages via the 
> DNU mechanism? Say, a package PackageName1 is already a global in the 
> Smalltalk system dictionary, then you can do send ClassName as a 
> message to it:
>     PackageName1 ClassName new

Yes, this is cleaner.

> And regarding the back ticks, normally the compiled methods would have 
> a reference to the association, but if you resolve it to a class at 
> compile time and a class is replaced by a new one in the package, the 
> compiled method outside would keep the reference to the old class.

Without backticks, we'd need to add packages as globals, so they can be 
resolved at runtime. With the backticks we can avoid that, because we 
can give the Compiler the context to resolve package names if in a 
required package, just like class names, at compile time.

Additionally, using DNU instead of #@ has a significant performance 
penalty. I would only use DNU if in backticks, so there is no additional 
cost in every method run.

WRT the class being recreated, yes, we need track and recompile 
references. Not a big deal.

So, I think there are three alternatives:

a)  `PackageName1@#ClassName` new         #@ message send, package name 
is required, no global needed. Evaluated at compile time.
b)  (PackageName1@#ClassName) new         #@ message send. Package name 
is a global. Evaluated at method run time.
c)   `PackageName1 ClassName` new             DNU mechanism. Backticks 
used for performance. No global needed.

I think I prefer option c). It looks clean, has no performance penalty, 
and doesn't need additional globals.

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



More information about the Cuis-dev mailing list