4 ms·
Don't really know Crystal but it seems to me that it is statically compiled which means you need to find the type of 'a' at compile time. The approach you sugge
by mvitorino 11y ago
Don't really know Crystal but it seems to me that it is statically compiled which means you need to find the type of 'a' at compile time. The approach you suggest is more commonly used in dynamic languages and involves keeping at runtime a tag on every single value that indicates it's type (memory and speed overhead). You would be trading compile time with run time. Also it seems that not only it is statically compiled, it produces a static binary in the target platform. If, like others suggest in this thread, you were to optimize at runtime instead of generating the alternate paths, you would need a bytecode representation of the program embedded in the executable and very likely a virtual machine with the optimiser and capability to hot reload code. Any of these options would be a substantial departure of the current path the language is taking.