Is it possible to emulate a C union structure using Scala? In this case variables are overwritten each other.
Following is a list of characteristics that might be possible:
With the same variable allow to use different types.
Variables use the same memory location.
Any way to know what types are stored.
I think that the second char...
Hello,
I have some classes with the same super-type. Therefore all of this classes have to override the same methods. Now I can call a method and commit it an object of the common super-type. But it is not always useful to react to each committed type therefore an exception is thrown. First i tried to solve this behaviour like this:
de...
Hi
I am absolutely happy with Scala and just love it :)
But sometimes I really want to go a bit more "low level", without a JVM and using "cool" CPU-Features like SSE etc.
So what would be a good second language besides Scala?
It should be:
Compiled to machine code
Easy usage of C-libraries
Possible to program very close to the har...
I'm running into a standard problem as a newbie to Scala: How do I define two classes in such a way that I can make an instance of one that the other as member variable, which in turn points back to the first instance?
I would like to end up with
an instance of Game
which has a member of type Dealer
which has a member of ...
I'm using Scala 2.7.7
I'm experiencing difficulties with access to the documentation, so code snippets would be greate.
Context
I parse an IP address of 4 or 16 bytes in length. I need an array of bytes, to pass into java.net.InetAddress. The result of String.split(separator).map(_.toByte) returns me an instance of Iterable.
I see tw...
I used InetAddress to parse IP addresses, but now there is a need to store hostname if IP is unavailable. So I introduced a class Host.
case class Host(name:String, ip:InetAddress) {
import Host.{addressToBytes, compareSeqs}
override def toString:String = if (ip!=null) {ip.getHostName} else {name}
}
object Host {
implicit d...
I'm a Java dev thinking about investing time in learning Scala to develop future apps. I've read quite a bit about the advantages of Scala over Java, but they're a bit abstract to really sell it to me emotionally.
Can someone suggest an example of an application that would really suit being developed with Scala, as opposed to Java?
...
This is something I've wondered about for a while. I see this pattern a lot:
if (pf.isDefinedAt(in)) pf(in)
By breaking this up into two separate calls, all of the patterns that were evaluated in #isDefinedAt are then also evaluated in #apply. For example:
object Ex1 {
def unapply(in: Int) : Option[String] = {
println("Ex1")
...
I was taught about formal systems at university, but I was disappointed how they didn't seem to be used in the real word.
I like the idea of being able to know that some code (object, function, whatever) works, not by testing, but by proof.
I'm sure we're all familiar with the parallels that don't exist between physical engineering and...