assert semantic change proposal
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Tue Aug 5 14:26:03 PDT 2014
On 8/5/2014 12:25 PM, Araq wrote:
> 'assume' is not nearly powerful enough for this and in no way "revolutionary".
More in the near-term realm of possibility are asserts that constrain the range
of values for a variable, which can subsequently eliminate the extra code needed
to handle the full range of the type.
One case is the one that started off this whole discussion - constraining the
range of values so that an overflow-checking-multiply need not actually check
the overflow, because an overflow might be impossible.
This kind of situation can come up in generic code, where the generic code is
written conservatively and defensively, then relying on the caller to provide a
few asserts which will in effect "customize" the generic code.
What's exciting about this is it'll give us a lever we can use to generate
better code than other languages are capable of.
More information about the Digitalmars-d
mailing list