Sunday, 7 August 2011

More types and attributes

I've been thinking some more about different attributes, namely, how they interact with primitive types. Previously, I had conceptually viewed attributes as a kind of "view" on to a type. Now, however, I'm re-considering that PoV. For example, if the Const attribute didn't ship with the language- then how could I define how Const interacts with primitives? If I define a user-defined Portable attribute or Tested attribute, then I might obviously say that every primitive and Standard function is Portable and Tested, even if not Tested by me, but I can't actually do that because they're immutable.

So, attributes are going to have to be copies- that is, when you have a type T, then a Const T is a completely separate type, and if T was locked, then Const T is not locked and can be modified arbitrarily. This would mean that when you have a Portable attribute, then when you talk about a Portable int, it's a copy and you can do what you wish with it- even though it's obviously illegal to talk about modifying int itself. This should also make life easier in terms of caching and parallelising attributes, as only one copy need exist at any one time.

I've also decided to go with the .NET/Java list of numerical sizes- byte, 8bit, short/char 16bit, int 32bit, long 64bit, all signed as default. Not going to have the variable-size primitives mess, and definitely not the char-is-it-signed-or-not mess.

Specification: I will define all of the primitive types as user-defined types. The "DeadMG++" Standard will not distinguish between UDTs and primitives in any way. A primitive is just a class with hardware support. If I find any property or behaviour of primitives that cannot be specified as UDTs, then I have created my language wrong. Except maybe literals, I might forgive that.

No comments:

Post a Comment