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
var funcs: seq[proc (): int {.closure.}] = @[] | |
proc main() = | |
var i = 0 | |
while i <= 10: | |
funcs.add((proc (): int = | |
var x = i | |
return x * x)) | |
inc i |
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
proc outer = | |
var x = 0 | |
proc innerB() = | |
capture x | |
while true: | |
var y = 0 | |
proc innerA = |
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
Nimrod is a statically typed, imperative programming language that tries to | |
give the programmer ultimate power without compromises on runtime efficiency. | |
This means it focuses on compile-time mechanisms in all its | |
various forms. Beneath a nice infix/indentation based syntax with a | |
powerful (AST based, hygienic) macro system lies a semantic model that supports | |
a soft realtime GC on thread local heaps. Asynchronous message passing is used | |
between threads, so no "stop the world" mechanism is necessary. An unsafe | |
shared memory heap is also provided for the increased efficiency that results | |
from that model. |
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
if a of Z: | |
echo "Z" | |
elif a of Y: | |
echo "Y" | |
elif a of X: | |
echo "X" | |
'of' is expensive and will become MORE expensive for proper DLL support | |
(string comparisons!). Thus we reserve a slot for the exact matched object |
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
# module A | |
var a: int | |
template tmp*(): expr = | |
# declaration context: the 'a' from module A | |
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
# Compile with nimrod c -d:release --passC:-fopenmp --passL:-fopenmp PN.nim | |
import os, strutils, unsigned | |
const | |
TileDim = 50'i32 | |
Miw = 2 | |
MaxWid = 8 | |
NumLevs = 800 |
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
proc test() = | |
asm """ | |
".byte 0xCC\n" | |
"push %rcx\n" | |
"push %rdx\n" | |
"push %r8\n" | |
"mov `navmBackendS1`, %rax\n" | |
"mov `navmBackendS2`, %r8\n" | |
"mov `navmBackendTempAdr`, %rdx\n" | |
"call *%rdx\n" |
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
REM - Run the full testsuite; tests\testament\tester all | |
REM - Uncomment the list of changes in news.txt | |
REM - write a news ticker entry | |
REM - Update the version | |
REM - Generate the full docs; koch web0 | |
REM - Generate the installers; | |
REM - Update the version in system.nim | |
REM - Test the installers |
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 | |
VTable = object | |
methodA: proc (this: MyObject; a, b: int) | |
methodB: proc (this: MyObject; a, b: string) | |
OtherObject = object | |
fieldA: int | |
fieldB: int | |
MyObject = object | |
vtab {.delegate(this).}: ptr VTable |
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
const CacheLineSize = 32 # true for most archs | |
type | |
Barrier = object | |
entered: int | |
cv: Semaphore # Semaphore takes 3 words at least | |
when sizeof(int) < 8: | |
cacheAlign: array[CacheLineSize-4*sizeof(int), byte] | |
left: int | |
cacheAlign2: array[CacheLineSize-sizeof(int), byte] |