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.
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...
Subscribe to:
Post Comments (Atom)
-
My meetup to learn Haskell was a success in the sense of meeting new people. There have been a core 5-6 that have shown up with varying leve...
-
Since my last post, I have spent a fair amount of time getting familiar with Elixir. I did a little work through The Daily Drip . That did...
-
A long time ago, I read Gary Taube's book Bad Calories, Good Calories . I found it a bit difficult to get through and totally understa...
No comments:
Post a Comment