Feature Request: Hashed Based Assertion

qznc via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 27 13:30:08 PST 2015

On Friday, 27 November 2015 at 20:19:40 UTC, tcak wrote:
> if(1) doSomething();
> if(1) { doSomething(); }
> You are correct here about hash calculation, but unless someone 
> touches to codes, this never happens, and no hash changes would 
> be seen. If someone is touching it as you exampled, checking 
> the documentation about what has happened would be the correct 
> approach. Importance of behaviour change is perceptional, 
> computer cannot know that already.

If you really want to integrate this into the language, you 
should consider future improvements.

Hashing the tokens is a conservative approximation of "behavior 
change", as the example above shows. Another example would be 
variable renames. The specification of the hash algorithm should 
provide the freedom that both variants above get the same hash, 
but still be correct in the sense that different behavior always 
yields different hashes.

Overall, I'm not convinced that this needs to be a language 
extension or trait. It could simple a static analysis tool 
independent of the compiler.

More information about the Digitalmars-d mailing list