Perils of a newbie player

 I first encountered disc golf back in 2017.  I played a little bit and then for reasons I don't remember, I kind of walked away.   Skip...

January 20, 2020

More Scala, More Questions

I've started on the Scala Exercises and have learned some tiny tidbits, which lead to more questions.

One thing that was stated in a section titled "Functional Loops", is that you may use '@tailrec' to enforce using a tail call.  I had never seen this, or quite honestly, thought of such a thing myself.  I find this pretty interesting.  The page says "In Scala, only directly recursive calls to the current function are optimized."  So, it is mostly (only) about optimizations, which is more to say memory requirements will stay constant since the stack won't grow out of control.  I suspect I mostly won't notice any issues surrounding this, but ya never know.

Here's an example of the above:



I'm ready to start muddling through a project so I can learn more about how things are tested, and how to start working with Scala in something slightly bigger than tiny little trivial functions. In a section titled "Lexical Scoping" I learned that you can add a 'package' declaration to control which definitions are seen where. So, you might add a 'package foo' to a file forcing all definitions in that file under the 'foo' package and thereby limiting the scope so other packages cannot accidentally see definitions they shouldn't. The example indicated that you might have a function "Bar" in a file "foo/Bar.scala", with a 'package foo' declaration. Ok, but is that file structure enforced? My suspicion is that it is enforced, because this ends up on the JVM.

This brings up another question. Is there a utility to generate a "correct" project structure? Elixir has the 'mix' tool for this (and many other) uses. I'm only aware of the 'sbt' (Scala Build Tool) at the moment. Judging from this old SO question it isn't the solved problem I was hoping for, but I don't know much so it might be once I learn what G8 is, I guess.

Time for some more Scala.

1 comment:

  1. Such regulation 우리카지노 generally results in gambling tourism and illegal gambling in the areas the place it isn't allowed. The involvement of governments, via regulation and taxation, has led to an in depth connection between many governments and gambling organizations, the place authorized gambling provides important authorities income, corresponding to in Monaco and Macau, China. Bettors wagered greater than $411.27 million during the interval from Sept. 1 via Sept. 31, for a median of $13.26 million per day, based on data offered by the Virginia Lottery. It additionally marked the primary time sports betting topped the $400 million mark in Virginia since March and the fourth time in 2022. The remarks came after Caesars’ third-quarter results beat expectations as the company returned to profit, helped by sales made from on-line sports betting — a section the company has promoted aggressively in latest months.

    ReplyDelete