Well, it's not restricted to pointers - In general I would think that the type annotation for Some | None would be left alone. I just used pointer as an example because pointers exclude a value, 0x0, from the valid set. In which case None is encoded as 0x0. Thanks for the bit about polymorphism in the context of what a compiler would see - clients that do not see the hypothetical additional annotation for that specific type to allow a format wouldn't have the augmented operational needs to work on such an instance correctly. Got it! On Tue, Aug 18, 2015 at 2:57 PM, Hendrik Boom wrote: > On Tue, Aug 18, 2015 at 01:06:55PM -0400, Kenneth Adam Miller wrote: > > I was wondering if cases where format control is possible in typing > > constructs can allow things like restricting the implementation size > after > > compilation of a specific variant type. Say, for instance that I wanted > to > > have a malloc implementation instead of returning a Some 'a | None type > > that compiles down to a boxed case of first a word and then the > subsequent > > 'a instance, down to the 'a instance, where in the values of the word > enum > > (or tag) are not present in the possibilities of the 'a instance. > > > > Maybe it sounds silly, but in really tight loops you want to squeeze for > > efficiency. So I was wondering if maybe the same actual code be used with > > the same sanity of type checking, but some annotation provided at the > type > > declaration to allow such optimization to take place. > > Let's see. OCaml steals a bit to indicate whether a valus is a pointer > or not, right? Could that bit see duual usage for the option type? So > that if it's an optional pointer type, the bit is left off, and if it's > an optional nonpointer type, it's turned on (and set to point to > location zero, which the GC couls check for)? > > THe proble I see with this is if the 'a is passed to a generic function > where iti isn't statically known where it's a pinter or not. The > conpiler will not know whether to test for absence or presence of the > bit. > > -- hendrik >