Is there a way to remove the requirement for parenthesis?

Daniel Keep daniel.keep.lists at gmail.com
Wed Jan 28 16:22:13 PST 2009



Charles Hixson wrote:
> Suppose that you have four types, equivalent to, say, float.
> Call one of them Horiz, one Vertic, one Radians, and one Radius.
> These are all floats, but when you specify, say,
> float dist (Horiz x, Vert y)
> {  return sqrt(x * x + y * y);  }
> It's important that the arguments aren't Radius and Radians.  Or Horiz
> and Horiz.
> 
> [snip]

There's no problem with that: make them structs that implement the
appropriate operators.

See, what I don't get (note: this is how I perceive it) is the desire to
have this sort of type protection, but require the compiler to somehow
be psychic in order to know when and where you don't care and throw it away.

You either have distinct types that aren't automatically compatible, or
you don't.

  -- Daniel


More information about the Digitalmars-d-learn mailing list