concepts_stuff, generics, and template_stuff
+18 −3 · 3 files changed
-
concepts_stuff.nim+5 −0 -
generics1.nim+11 −2 -
templates_stuff.nim+2 −1
@@ -0,0 +1,5 @@ +#Copyright 2019. +#Imports + +## About concepts: +## decipher https://gist.github.com/dustinlacewell/d89d210778c449aff6496a7d6ad5d645 @@ -1,5 +1,14 @@ -# Generics are Nim's means to parametrize procs -# Type safe containers. +## About generics: +## * Generics are Nim's means to parametrize procs +## * Type safe containers. +## * Generics are checked when you instantiate them mostly. +## * Generics are duck typed and very macro like. +## * Generics are obeying module scope. +## * Generics are a type based macro system on top of another macro system. +## * Generics are some what similar to c++ templates +## * Generics are typechecked after expansion. +## * Generics are a way to create code that works on a range of type. +## * The usage of T within the generic function is what defines the typeclass so to speak. proc `+`(a,b: string): string = a & b @@ -21,7 +21,8 @@ from os import sleep ## * A template is not a proc. return doesn't work as you expect it to. ## * A template is a way to use one function in multiple scenarios. ## * Document precisely the variables that are injected by the template. - +## * Templates are big quasi quotes +## * Templates and macros are metaprogramming which is basically writing code that writes code. ## Example: ##