diff options
author | Zahary Karadjov <zahary@gmail.com> | 2013-08-22 19:22:28 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2013-08-23 01:10:20 +0300 |
commit | fee2a7ecfa883d100e1177b1cc7d738c6cfeaa83 (patch) | |
tree | 3e78d3bb91a49552d746192296f1c327942e3ccb /compiler/semmagic.nim | |
parent | a8c8a85135e73777ea2c115bf1352456c1dd69aa (diff) | |
download | Nim-fee2a7ecfa883d100e1177b1cc7d738c6cfeaa83.tar.gz |
Experimental support for delayed instantiation of generics
This postpones the semantic pass over the generic's body until the generic is instantiated. There are several pros and cons for this method and the capabilities that it enables may still be possible in the old framework if we teach it a few new trick. Such an attempt will follow in the next commits. pros: 1) It allows macros to be expanded during generic instantiation that will provide the body of the generic. See ``tmacrogenerics``. 2) The instantiation code is dramatically simplified. Dealing with unknown types in the generic's body pre-pass requires a lot of hacky code and error silencing in semTypeNode. See ``tgenericshardcases``. cons: 1) There is a performance penalty of roughly 5% when bootstrapping. 2) Certain errors that used to be detected in the previous pre-pass won't be detected with the new scheme until instantiation.
Diffstat (limited to 'compiler/semmagic.nim')
-rw-r--r-- | compiler/semmagic.nim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim index 41c379133..b9ef8b008 100644 --- a/compiler/semmagic.nim +++ b/compiler/semmagic.nim @@ -40,7 +40,7 @@ proc semTypeTraits(c: PContext, n: PNode): PNode = (typArg.kind == skParam and typArg.typ.sonsLen > 0): # This is either a type known to sem or a typedesc # param to a regular proc (again, known at instantiation) - result = evalTypeTrait(n, GetCurrOwner()) + result = evalTypeTrait(n[0], n[1], GetCurrOwner()) else: # a typedesc variable, pass unmodified to evals result = n |