Report a bug
		
				If you spot a problem with this page, click here to create a Bugzilla issue.
		
			Improve this page
		
			Quickly fork, edit online, and submit a pull request for this page.
			Requires a signed-in GitHub account. This works well for small changes.
			If you'd like to make larger changes you may want to consider using
			a local clone.
		
	dmd.sideeffect
Find side-effects of expressions.
Authors: 
License: 
Source sideeffect.d
Documentation https://dlang.org/phobos/dmd_sideeffect.html
- boolisTrivialExp(Expressione);
- Front-end expression rewriting should create temporary variables for non trivial sub-expressions in order to:- save evaluation order
- prevent sharing of sub-expression in AST
 
- boolhasSideEffect(Expressione, boolassumeImpureCalls= false);
- Determine if Expression has any side effects.Parameters:Expression ethe expression bool assumeImpureCallswhether function calls should always be assumed to be impure (e.g. debug is allowed to violate purity) 
- intcallSideEffectLevel(FuncDeclarationf);
- Determine if the call of f, or function type or delegate type t1, has any side effects.Returns:0 has any side effects 1 nothrow + strongly pure 2 nothrow + strongly pure + only immutable indirections in the return type
- booldiscardValue(Expressione);
- The result of this expression will be discarded. Print error messages if the operation has no side effects (and hence is meaningless).Returns:true if expression has no side effects
- VarDeclarationcopyToTemp(STCstc, const char[]name, Expressione);
- Build a temporary variable to copy the value of e into.Parameters:STC stcstorage classes will be added to the made temporary variable char[] namename for temporary variable Expression eoriginal expression Returns:Newly created temporary variable.
- ExpressionextractSideEffect(Scope*sc, const char[]name, ref Expressione0, Expressione, boolalwaysCopy= false);
- Build a temporary variable to extract e's evaluation, if e is not trivial.Parameters:Scope* scscope char[] namename for temporary variable Expression e0a new side effect part will be appended to it. Expression eoriginal expression bool alwaysCopyif true, build new temporary variable even if e is trivial. Returns:When e is trivial and alwaysCopy == false, e itself is returned. Otherwise, a new VarExp is returned.Note e's lvalue-ness will be handled well by STC.ref_ or STC.rvalue. 
Copyright © 1999-2025 by the D Language Foundation | Page generated by
Ddoc on Fri Oct 10 22:08:01 2025