I think i have had the intention of mentioning that i provide the code link and 
the video's script link at the beginning but then i forgot about it, so it's 
still being only mentioned at the end.

The script is usually about 70-95% the same as what you see in the 
video(sometimes i improvise), i should start mentioning it at the beginning for 
all of you who prefer an offline version(no pictures though, i used to use 
OneNote to write the script of my videos but now i just use Visual Studio Code, 
because copying between the two is a nightmare(invisible spaces/tabs etc)).

On the template part that you could use a proc to get rid of all the if 
statements: Yes you could do that, but your proc would have to have 2 arguments 
for coordinates instead of 1, or vastly more in a more complex example. The 
first template shown takes "coord" as it's argument instead of x and y which is 
what a proc would have to take, and then it simply puts the name you give it 
which after the identifier insertion(all template, macro etc pass is done), 
evaluates player.x, player.y depending on the identifier provided(x, y).

Just in case if you were wondering, if you wanted to pass the template 
something else than the "x" and "y" for it's "coord" argument, you would have 
to obviously add that in the "player" object's definition.

For the generic constrained vs proc:
    
    
    sumGenericConstrained[T: int | float](a, b: T): T =
    sumGenericConstrained(a, b: int | float): int | float =
    
    
    Run

One of the differences is that the first line of code is a "generic" proc while 
the second is NOT. That said the compiler will generate 2 versions of the same 
proc, one for "int" and one for "float", while the non-generic proc will NOT. 
On a quick glance the generic version is heavier on compile-time speed while 
the second non-generic is heavier on the runtime speed. So that being said, if 
you need a proc that will work with MANY types and be complex, it will be 
better to use the generic over the non-generic.

For any other differences you will have to get an answer from someone else, i 
don't know more on this, as i haven't had the need for anything more complex 
yet.

Reply via email to