nim - how to make a proc available compile time and run time

I have a nim proc that dedents a multiline string based on the whitespaceof the first indented line:import strutilsproc dedent(s: string): string {.noSideEffect.} = var prefix = "" for line in s.splitLines(keepEol=true): if prefix == "" and line.len > 0: for j in 0..<line.len: if line[j] != ' ': prefix = line[0..j-1] break if line.startsWith(prefix): result.add(line[prefix.len .. high(line)]) else: result.add(line)when isMai...Read more

strongname - Binding redirect at compile time for strong named assembly

We have a question about assembly binding redirection at compile time:Team V (the Veterans) is developing Product P1P1 is continuously developed by Team V in two branches (branch 1.6.x and 1.7.x), so the version from Product P1 is incrementing over time in both branchesTeam NG (New Generation) has built a Product P2 based on Product P1 (using certain assemblies from P1 branch 1.7)Product P2 contains an Assembly A2 (strongly named) that helps implementing any Product (P2, P3...) that is based on P1Team NG created a Nuget Package for Assembly A2 ...Read more

Memory allocation to static variables (Compile time memory allocation)

Memory allocation to static variables is done at compile time. If I compile my application number of times, will memory be allocated every time? If yes, then by the time, it may consume complete memory of my computer. Practically, it never happens, How?Also, when we run the executable of the same application on some other computer, It runs successfully. How it finds the static variables in other computer's memory, if it was compiled on other computer.Also, If I start many instances of the same application, will copy of static variables be creat...Read more

How to echo/print at compile time in Nim?

When working on compile time features it would be nice to echo something at compile time. If an echo is withing a macro it is already executed at compile time. But is it also possible to print something at compile time e.g. from the global scope? I'm looking for a function like echoStatic in this:echoStatic "Compiling 1. set of macros..."# some macro definitionsechoStatic "Compiling 2. set of macros..."# more macro definitions...Read more

avr gcc - How to implement a compile-time [dispatch] table for AVR?

I have the same prerequisites as Dave Durbin in How can I implement a dynamic dispatch table in C... except my target is AVR. Here are my constraints:modules are to be picked in a list, much like Linux compiled-in kernel modulesthe number of C (can be C++) modules is known at compile-timemodules are to be statically linked (obviously)I want the table in program memory, not in SRAMTypically, the table should comprise items of this type:typedef struct jump_item { uint16_t function_id; void (*callback)(void);} jump_item_t;I have tried using ...Read more

code golf - "Hello, World", Even before it runs

Warning: This challenge is only valid for languages with a compiler.Make a program (which is perfectly valid code) that outputs Hello, World, even before runtime.How? Let me explain.Many languages have a compiler. Some operations are made in the compile-time, and others, in runtime. You trick the compiler to output the text Hello, World in compile-time. The text can be anywhere, like the build log.(Not errors. sorry for invalidating all those answers. at least theres pragma tho) You can use C, C++ or C#, but I wouldn't encourage you to. It's s...Read more

Enhanced Builder Pattern, verified at compile time

Question: can you design a Builder Pattern API which verifies at compile time that every field is set exactly once?To be eligible, the size of the compiler output should not be exponential in the number of fields. The best solution will be the shortest implementation for a class of 22 fields.Example of a possible surface API in javaGiven an class for immutable data structure such as this one:public class Human { private final String name; private final Int age; private final Double money; public Human(String name, Int age, Double money) { ...Read more