Safer casts
Dee Girl
deegirl at noreply.com
Fri May 9 21:57:51 PDT 2008
Janice Caron Wrote:
> On 10/05/2008, Yigal Chripun <yigal100 at gmail.com> wrote:
> > I too do not like the proposed syntax. I'd suggest the following scheme:
> > 1) convert: cast(foo)bar
> > 2) reinterpret: cast!(foo)bar
> > 3) constancy: cast(invariant), cast(mutable)
> > 4) downcast: cast!(foo)bar
>
> Your proposal is better than mine, but I think I can improve it even more:
>
> 1) convert: cast(Foo)bar
> 2) reinterpret: cast!(Foo)bar
> 3) constancy: cast(invariant)bar, cast(!const)bar
> 4) downcast: cast(Foo)bar
With much interest I followed this thread. Forgive my ignorance, but I can not understand one thing. Could this functionality be implemented as library functions all using the built in cast? The syntax will be clumsier though. I see from std.typecons and std.typetraits that D has powerful meta programming. Functions should be able to detect different cases.
Coding standards could prescribe that cast must not be used and only the library functions can be used. Dee Girl
More information about the Digitalmars-d
mailing list