The compiler will optimize away things you don’t use.
This is an example of the compiler optimizing away something which you didn’t use.
fun puts( string_to_display: String ): Void = printf "%s\n" string_to_display; # Simply having this line doesn't break it. "foo";
The first line of the function says that it should return Void. It looks like it’s returning “foo”, so you may expect this code to generate an error. It doesn’t! named_value is optimized away when it isn’t actually used.
If we change it to actually use `named_value , Mythryl no longer optimizes it away and it will now generate an error:
fun puts( string_to_display:String ):Void = printf "%s\n" string_to_display; # Simply having this line doesn't break it. "foo"; named_value = puts( "Hello, World!" );
printf "%s\n" named_value;
:2.1-15.2 Error: Operator and operand do not agree [typ mismatch]
operator domain: String
operand: Void
in expression:
(fn arg1: String; =>
(sfprintf::printf' "%s\n")
(STRING arg1: String; ! NIL))
named_value: Void;
