C!! — An aside: owned, shared and weak pointers in the C bang bang programming language

Let’s leave this relatively heady mapping/contract/transformation stuff aside for now. I think we’ve got enough to chew on there for now.

To address one of Jonathan Blow’s requirements, let’s promote unique_ptr, shared_ptr and weak_ptr to first-class language constructs. (Partly because this way, the compiler should be able to step in, and do a better job than compiling down code to generate the same things).

We’ll do this by adding some new keywords that modify pointer declarations – owned, shared and weak – and in the process simplify the syntax for using these in the process.

(more...)

C!! — More Contract specifics...

A couple of friends pointed out that contracts really need to support true duck-typing to be useful in all circumstances. (Not everyone cares all the time about ultra-high performance code). Yet I still want to make sure that they’re high performance if you want to pass them around as types. So let’s see if we can find a happy medium.

(more...)

C!! — Mappings, Versioning and the Transformation Assignment operator in the C bang bang programming language

A mapping in C!! is the definition of a transformation between two types or two contracts (and, by extension, define mappings between two types that honor the contracts in the mapping). Boy, that’s a mouthful. Oh, and I’m not done figuring out the syntax for this – so beware, it’s going to be very rough around the edges.

So let’s say you have Type A (or Contract A) and Type B (or Contract B).

You can define a mapping between them like this:

struct A
{
int a;
string firstname;
string lastname;
string middlename;
}

struct B
{
float value;
string firstname;
string middlename;
string lastname;
string playaname;

}

loose * mapping A ==> B
{
value = (float)in.a;
}

loose * mapping B ==> A // this is the reverse mapping
{
a = (int)in.value;
}

(more...)

C!! — Contracts, Duck-Typing and the Transformation Assignment Operator in the C bang bang programming language

One of the features I’d like to add to C++ is duck-typing. In this case, what I mean is, if an object has all of the named methods or variables you care about, you can treat it as “one of those things”.

The way you specify what an object has to have for it to be of a given duck-type is through a contract. Here’s an example of one:

contract(loose) PhysicsComponentContract
{
   vector3 position;
   vector3 velocity;
   float mass;

   void UpdatePhysicsState( float deltaT );
}

(more...)

C!! — Striped Pointers, Structures-of-Arrays and Arrays-of-Structures in the C bang bang programming language

Let’s start this ballgame out with something close to my heart – structures of arrays versus arrays of structures.

It’d be great if there was a good way of implementing these in a nice, succinct, low-cost fashion. Preferably without having to define multiple different structures to do it, or jump through too many crazy hoops.

So what can we come up with?

(more...)

subscribe via RSS