Useless instructions: Difference between revisions

Added Wren
m (don't include NOPs)
(Added Wren)
Line 23:
=={{header|8086 Assembly}}==
<code>xor ax,ax</code> (or any other data register) takes fewer bytes to encode than <code>mov ax,0</code> and achieves the same result. The only difference is that <code>mov ax,0</code> doesn't set the flags, which can be used to the programmer's advantage when sequencing operations.
 
=={{header|Wren}}==
There are no language features or standard library methods in Wren which are completely redundant either by design or due to subsequent developments. However, it's not difficult to think of instances where some of them can used in a redundant way as in the following script.
 
For good measure I've also included something which looks useless but isn't in fact.
<lang ecmascript>var uselessFunc = Fn.new { |uselessParam| // required but never used
if (true) {
// do something
} else {
System.print("Never called")
}
 
for (e in []) {
System.print("Never called")
}
 
while (false) {
System.print("Never called")
}
 
System.write("") // no visible effect
 
return // redundant as function would return 'naturally' anyway
}
 
class NotCompletelyUseless {
/*
On the face of it this class is useless because:
(1) it has no methods
(2) although it inherits from Object, static methods are not inherited
 
However, it's not in fact completely useless because:
(3) a Class object is still created and accessible
(4) it can be used as an abstract base class for other classes
*/
}
 
uselessFunc.call(0)
System.print(NotCompletelyUseless) // prints the string representation of the Class object</lang>
 
{{out}}
<pre>
NotCompletelyUseless
</pre>
 
=={{header|x86 Assembly}}==
9,485

edits