Compile time vs run time -- what is the difference?

thebluepandabear therealbluepandabear at protonmail.com
Wed Dec 28 12:42:24 UTC 2022


On Wednesday, 28 December 2022 at 09:10:38 UTC, 
areYouSureAboutThat wrote:
> On Wednesday, 28 December 2022 at 02:31:45 UTC, 
> thebluepandabear wrote:
>>
>> ..
>> Other errors are only able to be spotted during run time such 
>> as exceptions, dividing by zero, assert blocks.
>
> With regards to the 'assert blocks' you mention, D (like C++) 
> has both static assert and runtime assert.
>
> // ---
> module test;
> @safe:
>
> import std;
>
> void main()
> {
>   string val = "some string";
>   static assert(is(typeof(x) : int)); // assertion fails at 
> compile time.
>   assert(val == "some other string"); // assertion fails at 
> runtime.
> }
> // ---

Before even running the code I get an IDE warning (IntelliJ). 
Does IntelliJ compile the code in the background?


More information about the Digitalmars-d-learn mailing list