This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros, tables | |
macro echoType(x: typed): untyped = | |
let impl = x.symbol.getImpl() | |
# we're called on some type | |
if impl.kind == nnkTypeDef: | |
echo "type ", toStrLit(impl) | |
# we're called on a variable | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTP/1.1 200 OK | |
Server: nginx | |
Date: Fri, 20 Oct 2017 19:12:15 GMT | |
Content-Type: application/json | |
Transfer-Encoding: chunked | |
Connection: keep-alive | |
X-Powered-By: Express | |
X-Upstream: 127.0.0.1:5080 | |
X-Server-ID: apps-01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#?braces | |
for x in 0..10 { | |
echo x | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
macro doNothing(input: untyped): untyped = | |
echo treeRepr input | |
result = input | |
echo input.toStrLit | |
doNothing: | |
echo "hello world" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros, sequtils, future | |
type | |
Container[T] = concept x | |
for item in x: | |
item is T | |
proc forCompImpl(yieldResult: bool, comp: NimNode): NimNode {.compileTime.} = | |
expectLen(comp, 3) | |
expectKind(comp, nnkInfix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros, strutils, sequtils, future | |
type ForComprehension = distinct object | |
type ForComprehensionYield = distinct object | |
var fc*: ForComprehension | |
proc forCompImpl(yieldResult: bool, comp: NimNode): NimNode {.compileTime.} = | |
expectLen(comp, 3) | |
expectKind(comp, nnkInfix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Generated by Nim Compiler v0.17.3 */ | |
/* (c) 2017 Andreas Rumpf */ | |
/* The generated code is subject to the original license. */ | |
/* Compiled for: Linux, amd64, gcc */ | |
/* Command for C compiler: | |
gcc -c -w -O3 -fno-strict-aliasing -I/home/tiber/nim/lib -o /home/tiber/projects/experiments/nimcache/stdlib_system.o /home/tiber/projects/experiments/nimcache/stdlib_system.c */ | |
#define NIM_NEW_MANGLING_RULES | |
#define NIM_INTBITS 64 | |
#include "nimbase.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Generated by Nim Compiler v0.17.3 */ | |
/* (c) 2017 Andreas Rumpf */ | |
/* The generated code is subject to the original license. */ | |
/* Compiled for: Linux, amd64, gcc */ | |
/* Command for C compiler: | |
gcc -c -w -O3 -fno-strict-aliasing -I/home/tiber/nim/lib -o /home/tiber/projects/experiments/nimcache/ffa.o /home/tiber/projects/experiments/nimcache/ffa.c */ | |
#define NIM_NEW_MANGLING_RULES | |
#define NIM_INTBITS 64 | |
#include "nimbase.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
Comparable = concept a | |
(a < a) is bool | |
proc ada[T: Comparable](a, b: T): T = | |
if a < b: | |
return b | |
else: | |
return a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
Comparable = concept a | |
(a < a) is bool | |
proc myMax(a, b: Comparable): Comparable = | |
if a < b: | |
return b | |
else: | |
return a |