C++ strongly typed typedef
I’ve been trying to think of a way of declaring strongly typed typedefs, to catch a certain class of bugs in the compilation stage. It’s often the case that I’ll typedef an int into several types of ids, or a vector to position or velocity:
Why do we have to tell printf() the type of data in C?
Let’s consider this C code:
Why can’t the Scala compiler give pattern matching warning for nonsealed classes/traits?
If I use an unsealed trait
or abstract class
in Scala and then use pattern matching, I wonder, does the compiler not know at compile time for this particular patternmatch what possible implementations of this trait/class are available? So, if it does, could it not give pattern match warnings even though that the trait
/abstract class
is not sealed because he knows which types could be used, by checking all the possible dependencies/imports?
Is it possible to “bake dimension into a type” in haskell?
Suppose I want to write a library that deals with vectors and matrices. Is it possible to bake the dimensions into the types, so that operations of incompatible dimensions generate an error at compile time?
Is it possible to “bake dimension into a type” in haskell?
Suppose I want to write a library that deals with vectors and matrices. Is it possible to bake the dimensions into the types, so that operations of incompatible dimensions generate an error at compile time?
Why is XML type safe?
Why do they say that XML provides type safety and how is it expressed in the XML itself?
How do I model this relationship so that it is valid by construction?
Imagine a device
class that represents a physical real world mobile device, with fields like Enabled
, Platform
, Model
IMEI
, etc. Then, an operation
class, which is something that needs to be done to a certain device, like DeviceEnablementOperation
or LockOperation
. This is a ‘one device to many operations’ relationship, and an operation cannot exist without being related to an existing device. Can I model this in such a way that the system will not allow certain types of operations to devices with certain platforms? For example, an Android device would not allow a DeviceEnablementOperation
attached to it, while a Windows Phone device would.
How do I model this relationship so that it is valid by construction?
Imagine a device
class that represents a physical real world mobile device, with fields like Enabled
, Platform
, Model
IMEI
, etc. Then, an operation
class, which is something that needs to be done to a certain device, like DeviceEnablementOperation
or LockOperation
. This is a ‘one device to many operations’ relationship, and an operation cannot exist without being related to an existing device. Can I model this in such a way that the system will not allow certain types of operations to devices with certain platforms? For example, an Android device would not allow a DeviceEnablementOperation
attached to it, while a Windows Phone device would.
How to deal with implementation specific implementation accross interface boundaries
What to do if you end up in the following situation
Is there a way to introduce some basic type safety around IntPtrs returned from PInvoke’d methods?
I have a C-Style API with methods that return pointers to native objects, e.g.